typescript(option): feat: added the fromArray function to the docs
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
15f54ea45f
commit
7c143655ae
|
@ -17,6 +17,7 @@
|
||||||
- [fold](#Fold)
|
- [fold](#Fold)
|
||||||
- [foldback](#Foldback)
|
- [foldback](#Foldback)
|
||||||
- [forall](#Forall)
|
- [forall](#Forall)
|
||||||
|
- [fromArray](#FromArray)
|
||||||
|
|
||||||
# General
|
# General
|
||||||
|
|
||||||
|
@ -206,4 +207,23 @@ fromNullable(7) // Some(7)
|
||||||
fromNullable(null) // None
|
fromNullable(null) // None
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## FromArray
|
||||||
|
|
||||||
|
A function to create options from arrays. If the given array is empty produces None, else Some of the first element.
|
||||||
|
|
||||||
|
### Signature
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const fromArray: <T>(value: [T] | []) => Option<T>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { Some, None, fromArray } from '@adrielus/option'
|
||||||
|
|
||||||
|
fromArray([7]) // Some(7)
|
||||||
|
fromArray([]) // None
|
||||||
|
```
|
||||||
|
|
||||||
**_This is still work in progress, right now only covering about 60% of the library. Contributions are welcome_**
|
**_This is still work in progress, right now only covering about 60% of the library. Contributions are welcome_**
|
||||||
|
|
Loading…
Reference in a new issue