1
Fork 0

typescript(option): feat: added the fromArray function to the docs

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-20 15:00:09 +02:00 committed by prescientmoon
parent 15f54ea45f
commit 7c143655ae
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -17,6 +17,7 @@
- [fold](#Fold)
- [foldback](#Foldback)
- [forall](#Forall)
- [fromArray](#FromArray)
# General
@ -206,4 +207,23 @@ fromNullable(7) // Some(7)
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_**