diff --git a/typescript/option/src/helpers.ts b/typescript/option/src/helpers.ts index 629e830..296edd2 100644 --- a/typescript/option/src/helpers.ts +++ b/typescript/option/src/helpers.ts @@ -116,3 +116,7 @@ export const flat = <T, U>(option: Option<T>): Option<U> => { export const fromNullable = <T>(value: Nullable<T>): Option<T> => { return value === null ? None : Some(value) } + +export const fromArray = <T>(value: [T] | []): Option<T> => { + return value[0] === undefined ? None : Some(value[0]) +}