diff --git a/typescript/option/docs/main.md b/typescript/option/docs/main.md index db1f2ec..7609ce1 100644 --- a/typescript/option/docs/main.md +++ b/typescript/option/docs/main.md @@ -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: (value: [T] | []) => Option +``` + +### 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_**