docs(type_utils): add some documentation
This commit is contained in:
parent
84b17382c1
commit
7a3de79e36
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
* Copyright (C) 2022 WYATT GROUP
|
* Copyright (C) 2023 WYATT GROUP
|
||||||
* Please see the AUTHORS file for details.
|
* Please see the AUTHORS file for details.
|
||||||
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -16,18 +16,14 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Dart - Wyatt Type Utils
|
# Dart - Wyatt Type Utils
|
||||||
|
|
||||||
<p align="left">
|
<p align="left">
|
||||||
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis">
|
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
|
||||||
<img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" />
|
|
||||||
</a>
|
|
||||||
<img src="https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square" alt="SDK: Dart & Flutter" />
|
<img src="https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square" alt="SDK: Dart & Flutter" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Type Utils for Dart & Flutter.
|
Either, Option and other useful types and extensions for Dart (and Flutter).
|
||||||
|
|
||||||
## Option\<T>
|
## Option\<T>
|
||||||
|
|
||||||
@ -62,8 +58,8 @@ print('`rand` contains 10 ? => ${rand.contains(10)}');
|
|||||||
*E.g. null reference exception or index out of bounds are not related to domain - they rather indicate a defect.*
|
*E.g. null reference exception or index out of bounds are not related to domain - they rather indicate a defect.*
|
||||||
|
|
||||||
Either is defined as a generic type with two branches
|
Either is defined as a generic type with two branches
|
||||||
- success with **T**
|
* success with **T**
|
||||||
- failure with **E**
|
* failure with **E**
|
||||||
|
|
||||||
It can appear in two forms, where it contains an object of **Ok**, or where it contains an object of **Err**. It cannot appear in both states at once, or in none of them. Therefore, if one possesses an **Result** instance, it either contains a successfully produced result, or contains an error object.
|
It can appear in two forms, where it contains an object of **Ok**, or where it contains an object of **Err**. It cannot appear in both states at once, or in none of them. Therefore, if one possesses an **Result** instance, it either contains a successfully produced result, or contains an error object.
|
||||||
|
|
||||||
@ -95,20 +91,20 @@ print(myList); // prints '[42, 16]'
|
|||||||
|
|
||||||
This package also provides extensions for Dart types.
|
This package also provides extensions for Dart types.
|
||||||
|
|
||||||
- Object
|
* Object
|
||||||
- isNull
|
+ isNull
|
||||||
- isNotNull
|
+ isNotNull
|
||||||
- log
|
+ log
|
||||||
- Iterable
|
* Iterable
|
||||||
- isNullOrEmpty
|
+ isNullOrEmpty
|
||||||
- isNotNullOrEmpty
|
+ isNotNullOrEmpty
|
||||||
- For bytes iterables
|
+ For bytes iterables
|
||||||
- toTypedList
|
- toTypedList
|
||||||
- toStr
|
- toStr
|
||||||
- String
|
* String
|
||||||
- isNullOrEmpty
|
+ isNullOrEmpty
|
||||||
- isNotNullOrEmpty
|
+ isNotNullOrEmpty
|
||||||
- toBytes
|
+ toBytes
|
||||||
|
|
||||||
String 🔁 Uint8List works with encoding:
|
String 🔁 Uint8List works with encoding:
|
||||||
|
|
||||||
@ -118,27 +114,27 @@ final Uint8List bytes = myString.toBytes(from : Encoding.utf16);
|
|||||||
print(bytes.toStr(to : Encoding.utf16)); // prints 'abc'
|
print(bytes.toStr(to : Encoding.utf16)); // prints 'abc'
|
||||||
```
|
```
|
||||||
|
|
||||||
- DateTime
|
* DateTime
|
||||||
- fromSecondsSinceEpoch
|
+ fromSecondsSinceEpoch
|
||||||
- secondsSinceEpoch
|
+ secondsSinceEpoch
|
||||||
- timestamp
|
+ timestamp
|
||||||
- tomorrow
|
+ tomorrow
|
||||||
- yesterday
|
+ yesterday
|
||||||
- today
|
+ today
|
||||||
- add/sub/set
|
+ add/sub/set
|
||||||
- nextDay
|
+ nextDay
|
||||||
- previousDay
|
+ previousDay
|
||||||
- nextMonth
|
+ nextMonth
|
||||||
- previousMonth
|
+ previousMonth
|
||||||
- nextYear
|
+ nextYear
|
||||||
- previousYear
|
+ previousYear
|
||||||
- nextWeek
|
+ nextWeek
|
||||||
- previousWeek
|
+ previousWeek
|
||||||
- isFuture
|
+ isFuture
|
||||||
- isPast
|
+ isPast
|
||||||
- isLeapYear
|
+ isLeapYear
|
||||||
- format
|
+ format
|
||||||
- operators
|
+ operators
|
||||||
|
|
||||||
The date formatter works with `String` formatter:
|
The date formatter works with `String` formatter:
|
||||||
|
|
||||||
|
@ -171,8 +171,11 @@ abstract class Option<T> extends _EitherBase<T, void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// {@template value}
|
||||||
|
/// Contains the non-null value of the [Option].
|
||||||
|
/// {@endtemplate}
|
||||||
class Value<T> extends Option<T> with _Left<T, void> {
|
class Value<T> extends Option<T> with _Left<T, void> {
|
||||||
/// {@macro ok}
|
/// {@macro value}
|
||||||
const Value(this.value) : super._();
|
const Value(this.value) : super._();
|
||||||
final T value;
|
final T value;
|
||||||
|
|
||||||
@ -236,8 +239,11 @@ class Value<T> extends Option<T> with _Left<T, void> {
|
|||||||
_EitherBase<T, F> _or<F>(_EitherBase<T, F> res) => this as _EitherBase<T, F>;
|
_EitherBase<T, F> _or<F>(_EitherBase<T, F> res) => this as _EitherBase<T, F>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// {@template none}
|
||||||
|
/// Contains no value.
|
||||||
|
/// {@endtemplate}
|
||||||
class None<T> extends Option<T> with _Right<T, void> {
|
class None<T> extends Option<T> with _Right<T, void> {
|
||||||
/// {@macro ok}
|
/// {@macro none}
|
||||||
const None() : super._();
|
const None() : super._();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/// Defines different text encoding types.
|
||||||
enum Encoding {
|
enum Encoding {
|
||||||
utf8,
|
utf8,
|
||||||
utf16,
|
utf16,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
name: wyatt_type_utils
|
name: wyatt_type_utils
|
||||||
description: Either, Option and other useful types.
|
description: Either, Option and other useful types and extensions.
|
||||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_type_utils
|
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_type_utils
|
||||||
version: 0.0.4
|
version: 0.0.4
|
||||||
|
|
||||||
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.17.0 <3.0.0'
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test: ^1.22.0
|
test: ^1.22.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user