1
Fork 0

typescript(option): docs: wrote docs for the 'withDefault' helper

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-26 16:04:09 +02:00 committed by prescientmoon
parent 668c33b9fb
commit 089ba6148f
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -2,6 +2,12 @@ import { match } from './match'
import { identity } from '@thi.ng/compose' import { identity } from '@thi.ng/compose'
import { Option } from '../types' import { Option } from '../types'
/**
* Provide a default value, turning an optional value into a normal value.
*
* @param _default The default value to use.
* @param option The option to get the default of.
*/
export const withDefault = <T>(_default: T, option: Option<T>) => { export const withDefault = <T>(_default: T, option: Option<T>) => {
return match(identity, _default, option) return match(identity, _default, option)
} }