typescript(option): docs: wrote docs for the 'withDefault' helper
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
668c33b9fb
commit
089ba6148f
|
@ -2,6 +2,12 @@ import { match } from './match'
|
|||
import { identity } from '@thi.ng/compose'
|
||||
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>) => {
|
||||
return match(identity, _default, option)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue