1
Fork 0

typescript(option): feat: added a bindAsync helper

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-23 13:31:56 +02:00 committed by prescientmoon
parent 9236bade0c
commit b16272a3aa
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
2 changed files with 11 additions and 0 deletions

View file

@ -0,0 +1,10 @@
import { Mapper } from '../internalTypes'
import { Option, None } from '../types'
import { match } from './match'
export const bindAsync = <T, U>(
binder: Mapper<T, Promise<Option<U>>>,
option: Option<T>
): Promise<Option<U>> => {
return match(binder, Promise.resolve(None), option)
}

View file

@ -17,3 +17,4 @@ export * from './toArray'
export * from './toNullable'
export * from './withDefault'
export * from './mapAsync'
export * from './bindAsync'