typescript(option): feat: added a fromNullable helper
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
aa18688c7a
commit
1f1afc0f28
|
@ -105,3 +105,7 @@ export const flat = <T, U>(option: Option<T>): Option<U> => {
|
||||||
always(None)
|
always(None)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const fromNullable = <T>(value: null | T): Option<T> => {
|
||||||
|
return value === null ? None : Some(value)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue