typescript(option): feat: added a withDefault hepler
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
0458b226c7
commit
4ebe549c29
2 changed files with 6 additions and 0 deletions
typescript/option/src
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue