1
Fork 0

typescript(option): feat: added a withDefault hepler

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-19 14:20:47 +02:00 committed by prescientmoon
parent 0458b226c7
commit 4ebe549c29
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
2 changed files with 6 additions and 0 deletions
typescript/option/src

View file

@ -85,3 +85,7 @@ export const toArray = <T>(option: Option<T>) => {
export const toNullable = <T>(option: Option<T>) => {
return match(option, identity, always(null))
}
export const withDefault = <T>(_default: T, option: Option<T>) => {
return match(option, identity, always(_default))
}