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 = (option: Option): Option => { export const fromNullable = (value: Nullable): Option => { return value === null ? None : Some(value) } + +export const fromArray = (value: [T] | []): Option => { + return value[0] === undefined ? None : Some(value[0]) +}