1
Fork 0

typescript(option): feat: added a fromNullable helper

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-20 14:44:42 +02:00 committed by prescientmoon
parent aa18688c7a
commit 1f1afc0f28
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -105,3 +105,7 @@ export const flat = <T, U>(option: Option<T>): Option<U> => {
always(None)
)
}
export const fromNullable = <T>(value: null | T): Option<T> => {
return value === null ? None : Some(value)
}