From b16272a3aa2a4404a3f11d70ce2cc2c217069f36 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 23 Dec 2019 13:31:56 +0200 Subject: [PATCH] typescript(option): feat: added a bindAsync helper Signed-off-by: prescientmoon --- typescript/option/src/helpers/bindAsync.ts | 10 ++++++++++ typescript/option/src/helpers/external.ts | 1 + 2 files changed, 11 insertions(+) create mode 100644 typescript/option/src/helpers/bindAsync.ts diff --git a/typescript/option/src/helpers/bindAsync.ts b/typescript/option/src/helpers/bindAsync.ts new file mode 100644 index 0000000..30f8955 --- /dev/null +++ b/typescript/option/src/helpers/bindAsync.ts @@ -0,0 +1,10 @@ +import { Mapper } from '../internalTypes' +import { Option, None } from '../types' +import { match } from './match' + +export const bindAsync = ( + binder: Mapper>>, + option: Option +): Promise> => { + return match(binder, Promise.resolve(None), option) +} diff --git a/typescript/option/src/helpers/external.ts b/typescript/option/src/helpers/external.ts index 408312a..25ca3d8 100644 --- a/typescript/option/src/helpers/external.ts +++ b/typescript/option/src/helpers/external.ts @@ -17,3 +17,4 @@ export * from './toArray' export * from './toNullable' export * from './withDefault' export * from './mapAsync' +export * from './bindAsync'