From 1f1afc0f28f309462cbd4a0b27883a6b77213722 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Fri, 20 Dec 2019 14:44:42 +0200 Subject: [PATCH] typescript(option): feat: added a fromNullable helper Signed-off-by: prescientmoon --- typescript/option/src/helpers.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/typescript/option/src/helpers.ts b/typescript/option/src/helpers.ts index fb87ce1..09a419f 100644 --- a/typescript/option/src/helpers.ts +++ b/typescript/option/src/helpers.ts @@ -105,3 +105,7 @@ export const flat = (option: Option): Option => { always(None) ) } + +export const fromNullable = (value: null | T): Option => { + return value === null ? None : Some(value) +}