From 7c143655aecb0fe02e25af139dab0e4b8b1dcdfa Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Fri, 20 Dec 2019 15:00:09 +0200 Subject: [PATCH] typescript(option): feat: added the fromArray function to the docs Signed-off-by: prescientmoon --- typescript/option/docs/main.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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_**