1
Fork 0

typescript(option): fix: fixed wrong types for bind, bindAsync, and probably other helpers as well

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-23 15:00:29 +02:00 committed by prescientmoon
parent ff81096e6f
commit 0abd53917b
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
17 changed files with 169 additions and 4 deletions

36
typescript/option/lib/index.amd.d.ts vendored Normal file
View file

@ -0,0 +1,36 @@
import { Brand } from "utility-types";
declare const none: unique symbol;
declare const some: unique symbol;
declare type None = Brand<void, typeof none>;
declare type Some<T> = Brand<T, typeof some>;
declare type Option<T> = Some<T> | None;
declare const None: Brand<void, typeof none>;
declare const Some: <T>(value: T) => Option<T>;
declare const isNone: <T>(option: Option<T>) => boolean;
declare const isSome: <T>(option: Option<T>) => boolean;
declare type Mapper<T, U> = (v: T) => U;
declare type Binder<T, U> = (v: T) => Option<U>;
declare type Predicate<T> = (v: T) => boolean;
declare type Folder<T, U> = (s: U, v: T) => U;
declare type BackFolder<T, U> = (v: T, s: U) => U;
declare type Nullable<T> = T | null;
declare const bind: <T, U>(binder: Binder<T, U>, option: Option<T>) => Option<U>;
declare const bindAsync: <T, U>(binder: Mapper<T, Promise<Option<U>>>, option: Option<T>) => Promise<Option<U>>;
declare const count: <T>(option: Option<T>) => number;
declare const exists: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const filter: <T>(predicate: Predicate<T>, option: Option<T>) => Option<T>;
declare const flat: <T>(option: Option<Option<T>>) => Option<T>;
declare const fold: <T, U>(folder: Folder<T, U>, initial: U, option: Option<T>) => U;
declare const foldback: <T, U>(folder: BackFolder<T, U>, option: Option<T>, initial: U) => U;
declare const forall: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const fromArray: <T>(value: [T] | []) => Option<T>;
declare const fromNullable: <T>(value: Nullable<T>) => Option<T>;
declare const get: <T>(option: Option<T>) => T;
declare const iter: <T>(mapper: Mapper<T, void>, option: Option<T>) => void;
declare const map: <T, U>(mapper: Mapper<T, U>, option: Option<T>) => Option<U>;
declare const mapAsync: <T, U>(mapper: Mapper<T, Promise<U>>, option: Option<T>) => Promise<Option<U>>;
declare const toArray: <T>(option: Option<T>) => T[];
declare const toNullable: <T>(option: Option<T>) => T | null;
declare const withDefault: <T>(_default: T, option: Option<T>) => T;
export { bind, bindAsync, count, exists, filter, flat, fold, foldback, forall, fromArray, fromNullable, get, isNone, isSome, iter, map, mapAsync, toArray, toNullable, withDefault, Option, None, Some };
//# sourceMappingURL=index.amd.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.amd.d.ts","sourceRoot":"","sources":["../src/internals.ts","../src/types.ts","../src/helpers/isNone.ts","../src/helpers/isSome.ts","../src/internalTypes.ts","../src/helpers/match.ts","../src/helpers/bind.ts","../src/helpers/bindAsync.ts","../src/helpers/count.ts","../src/helpers/exists.ts","../src/helpers/filter.ts","../src/helpers/flat.ts","../src/helpers/fold.ts","../src/helpers/foldback.ts","../src/helpers/forall.ts","../src/helpers/fromArray.ts","../src/helpers/fromNullable.ts","../src/helpers/get.ts","../src/helpers/iter.ts","../src/helpers/map.ts","../src/helpers/mapAsync.ts","../src/helpers/toArray.ts","../src/helpers/toNullable.ts","../src/helpers/withDefault.ts","../src/helpers/external.ts","../src/index.ts"],"names":[],"mappings":"AAAA,QAAO,MAAM,QAAQ,gBAAiB,CAAA;AAEtC,QAAO,MAAM,IAAI,eAAiB,CAAAAAIA,OAAO,CAAC,MAAM,IAAI,EAAE,OAAO,MAAM,CAAA;AAEjC,aAAK,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,CAAA;AACpC,aAAK,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,CAAA;AAEpC,aAAY,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;AAEtC,QAAO,MAAM,IAAI,0BAGR,CAAA;AACT,QAAO,MAAM,IAAI,4BAAyC,CAAAAAGA,QAAO,MAAM,MAAM,mCAAoD,CAAAAAGA,QAAO,MAAM,MAAM,mCAA4C,CAAAAAEA,aAAY,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AACtC,aAAY,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAA;AAC9C,aAAY,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAA;AAC5C,aAAY,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AAC5C,aAAY,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AAChD,aAAY,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAAAAIA,QAAO,MAAM,KAAK,qEAUjB,CAAAAAIA,QAAO,MAAM,IAAI,8DAKhB,CAAAAAIA,QAAO,MAAM,SAAS,wFAKrB,CAAAAAGA,QAAO,MAAM,KAAK,kCAAmD,CAAAAAIA,QAAO,MAAM,MAAM,4DAElB,CAAAAAIA,QAAO,MAAM,MAAM,8DAElB,CAAAAAIA,QAAO,MAAM,IAAI,6CAEhB,CAAAAAIA,QAAO,MAAM,IAAI,kEAMhB,CAAAAAIA,QAAO,MAAM,QAAQ,sEAMpB,CAAAAAIA,QAAO,MAAM,MAAM,4DAElB,CAAAAAEA,QAAO,MAAM,SAAS,mCAErB,CAAAAAGA,QAAO,MAAM,YAAY,sCAExB,CAAAAAGA,QAAO,MAAM,GAAG,6BAMf,CAAAAAIA,QAAO,MAAM,IAAI,yDAIhB,CAAAAAIA,QAAO,MAAM,GAAG,8DAKf,CAAAAAIA,QAAO,MAAM,QAAQ,gFASpB,CAAAAAGA,QAAO,MAAM,OAAO,+BAEnB,CAAAAAIA,QAAO,MAAM,UAAU,oCAEtB,CAAAAAIA,QAAO,MAAM,WAAW,0CAEvB,CAAA"}

View file

@ -0,0 +1,2 @@
define(["exports"],(function(e){"use strict";const o=e=>e,r=Symbol("none"),n={__brand:r,toString:()=>"None"},t=o,l=e=>e.__brand===r,i=e=>!l(e),a=(e,o,r)=>i(r)?e(r):o,s=(e,o)=>a(e,n,o);e.None=n,e.Some=t,e.bind=s,e.bindAsync=(e,o)=>a(e,Promise.resolve(n),o),e.count=e=>Number(i(e)),e.exists=(e,o)=>a(e,!1,o),e.filter=(e,o)=>a(o=>e(o)?t(o):n,n,o),e.flat=e=>s(o,e),e.fold=(e,o,r)=>a(r=>e(o,r),o,r),e.foldback=(e,o,r)=>a(o=>e(o,r),r,o),e.forall=(e,o)=>a(e,!0,o),e.fromArray=e=>void 0===e[0]?n:t(e[0]),e.fromNullable=e=>null===e?n:t(e),e.get=e=>{if(i(e))return e;throw new Error("Cannot get value of None")},e.isNone=l,e.isSome=i,e.iter=(e,o)=>{i(o)&&e(o)},e.map=(e,o)=>a(o=>t(e(o)),n,o),e.mapAsync=(e,o)=>a(o=>e(o).then(t),Promise.resolve(n),o),e.toArray=e=>a(e=>[e],[],e),e.toNullable=e=>a(o,null,e),e.withDefault=(e,r)=>a(o,e,r),Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.amd.js.map

File diff suppressed because one or more lines are too long

36
typescript/option/lib/index.cjs.d.ts vendored Normal file
View file

@ -0,0 +1,36 @@
import { Brand } from "utility-types";
declare const none: unique symbol;
declare const some: unique symbol;
declare type None = Brand<void, typeof none>;
declare type Some<T> = Brand<T, typeof some>;
declare type Option<T> = Some<T> | None;
declare const None: Brand<void, typeof none>;
declare const Some: <T>(value: T) => Option<T>;
declare const isNone: <T>(option: Option<T>) => boolean;
declare const isSome: <T>(option: Option<T>) => boolean;
declare type Mapper<T, U> = (v: T) => U;
declare type Binder<T, U> = (v: T) => Option<U>;
declare type Predicate<T> = (v: T) => boolean;
declare type Folder<T, U> = (s: U, v: T) => U;
declare type BackFolder<T, U> = (v: T, s: U) => U;
declare type Nullable<T> = T | null;
declare const bind: <T, U>(binder: Binder<T, U>, option: Option<T>) => Option<U>;
declare const bindAsync: <T, U>(binder: Mapper<T, Promise<Option<U>>>, option: Option<T>) => Promise<Option<U>>;
declare const count: <T>(option: Option<T>) => number;
declare const exists: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const filter: <T>(predicate: Predicate<T>, option: Option<T>) => Option<T>;
declare const flat: <T>(option: Option<Option<T>>) => Option<T>;
declare const fold: <T, U>(folder: Folder<T, U>, initial: U, option: Option<T>) => U;
declare const foldback: <T, U>(folder: BackFolder<T, U>, option: Option<T>, initial: U) => U;
declare const forall: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const fromArray: <T>(value: [T] | []) => Option<T>;
declare const fromNullable: <T>(value: Nullable<T>) => Option<T>;
declare const get: <T>(option: Option<T>) => T;
declare const iter: <T>(mapper: Mapper<T, void>, option: Option<T>) => void;
declare const map: <T, U>(mapper: Mapper<T, U>, option: Option<T>) => Option<U>;
declare const mapAsync: <T, U>(mapper: Mapper<T, Promise<U>>, option: Option<T>) => Promise<Option<U>>;
declare const toArray: <T>(option: Option<T>) => T[];
declare const toNullable: <T>(option: Option<T>) => T | null;
declare const withDefault: <T>(_default: T, option: Option<T>) => T;
export { bind, bindAsync, count, exists, filter, flat, fold, foldback, forall, fromArray, fromNullable, get, isNone, isSome, iter, map, mapAsync, toArray, toNullable, withDefault, Option, None, Some };
//# sourceMappingURL=index.cjs.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.cjs.d.ts","sourceRoot":"","sources":["../src/internals.ts","../src/types.ts","../src/helpers/isNone.ts","../src/helpers/isSome.ts","../src/internalTypes.ts","../src/helpers/match.ts","../src/helpers/bind.ts","../src/helpers/bindAsync.ts","../src/helpers/count.ts","../src/helpers/exists.ts","../src/helpers/filter.ts","../src/helpers/flat.ts","../src/helpers/fold.ts","../src/helpers/foldback.ts","../src/helpers/forall.ts","../src/helpers/fromArray.ts","../src/helpers/fromNullable.ts","../src/helpers/get.ts","../src/helpers/iter.ts","../src/helpers/map.ts","../src/helpers/mapAsync.ts","../src/helpers/toArray.ts","../src/helpers/toNullable.ts","../src/helpers/withDefault.ts","../src/helpers/external.ts","../src/index.ts"],"names":[],"mappings":"AAAA,QAAO,MAAM,QAAQ,gBAAiB,CAAA;AAEtC,QAAO,MAAM,IAAI,eAAiB,CAAAAAIA,OAAO,CAAC,MAAM,IAAI,EAAE,OAAO,MAAM,CAAA;AAEjC,aAAK,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,CAAA;AACpC,aAAK,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,CAAA;AAEpC,aAAY,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;AAEtC,QAAO,MAAM,IAAI,0BAGR,CAAA;AACT,QAAO,MAAM,IAAI,4BAAyC,CAAAAAGA,QAAO,MAAM,MAAM,mCAAoD,CAAAAAGA,QAAO,MAAM,MAAM,mCAA4C,CAAAAAEA,aAAY,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AACtC,aAAY,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAA;AAC9C,aAAY,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAA;AAC5C,aAAY,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AAC5C,aAAY,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AAChD,aAAY,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAAAAIA,QAAO,MAAM,KAAK,qEAUjB,CAAAAAIA,QAAO,MAAM,IAAI,8DAKhB,CAAAAAIA,QAAO,MAAM,SAAS,wFAKrB,CAAAAAGA,QAAO,MAAM,KAAK,kCAAmD,CAAAAAIA,QAAO,MAAM,MAAM,4DAElB,CAAAAAIA,QAAO,MAAM,MAAM,8DAElB,CAAAAAIA,QAAO,MAAM,IAAI,6CAEhB,CAAAAAIA,QAAO,MAAM,IAAI,kEAMhB,CAAAAAIA,QAAO,MAAM,QAAQ,sEAMpB,CAAAAAIA,QAAO,MAAM,MAAM,4DAElB,CAAAAAEA,QAAO,MAAM,SAAS,mCAErB,CAAAAAGA,QAAO,MAAM,YAAY,sCAExB,CAAAAAGA,QAAO,MAAM,GAAG,6BAMf,CAAAAAIA,QAAO,MAAM,IAAI,yDAIhB,CAAAAAIA,QAAO,MAAM,GAAG,8DAKf,CAAAAAIA,QAAO,MAAM,QAAQ,gFASpB,CAAAAAGA,QAAO,MAAM,OAAO,+BAEnB,CAAAAAIA,QAAO,MAAM,UAAU,oCAEtB,CAAAAAIA,QAAO,MAAM,WAAW,0CAEvB,CAAA"}

View file

@ -0,0 +1,2 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const identity=e=>e,none=Symbol("none"),None={__brand:none,toString:()=>"None"},Some=identity,isNone=e=>e.__brand===none,isSome=e=>!isNone(e),match=(e,o,t)=>isSome(t)?e(t):o,bind=(e,o)=>match(e,None,o),bindAsync=(e,o)=>match(e,Promise.resolve(None),o),count=e=>Number(isSome(e)),exists=(e,o)=>match(e,!1,o),filter=(e,o)=>match(o=>e(o)?Some(o):None,None,o),flat=e=>bind(identity,e),fold=(e,o,t)=>match(t=>e(o,t),o,t),foldback=(e,o,t)=>match(o=>e(o,t),t,o),forall=(e,o)=>match(e,!0,o),fromArray=e=>void 0===e[0]?None:Some(e[0]),fromNullable=e=>null===e?None:Some(e),get=e=>{if(isSome(e))return e;throw new Error("Cannot get value of None")},iter=(e,o)=>{isSome(o)&&e(o)},map=(e,o)=>match(o=>Some(e(o)),None,o),mapAsync=(e,o)=>match(o=>e(o).then(Some),Promise.resolve(None),o),toArray=e=>match(e=>[e],[],e),toNullable=e=>match(identity,null,e),withDefault=(e,o)=>match(identity,e,o);exports.None=None,exports.Some=Some,exports.bind=bind,exports.bindAsync=bindAsync,exports.count=count,exports.exists=exists,exports.filter=filter,exports.flat=flat,exports.fold=fold,exports.foldback=foldback,exports.forall=forall,exports.fromArray=fromArray,exports.fromNullable=fromNullable,exports.get=get,exports.isNone=isNone,exports.isSome=isSome,exports.iter=iter,exports.map=map,exports.mapAsync=mapAsync,exports.toArray=toArray,exports.toNullable=toNullable,exports.withDefault=withDefault;
//# sourceMappingURL=index.cjs.js.map

File diff suppressed because one or more lines are too long

34
typescript/option/lib/index.d.ts vendored Normal file
View file

@ -0,0 +1,34 @@
import { Brand } from "utility-types";
declare const none: unique symbol;
declare const some: unique symbol;
declare type None = Brand<void, typeof none>;
declare type Some<T> = Brand<T, typeof some>;
declare type Option<T> = Some<T> | None;
declare const None: Brand<void, typeof none>;
declare const Some: <T>(value: T) => Option<T>;
declare const isNone: <T>(option: Option<T>) => boolean;
declare const isSome: <T>(option: Option<T>) => boolean;
declare type Mapper<T, U> = (v: T) => U;
declare type Binder<T, U> = (v: T) => Option<U>;
declare type Predicate<T> = (v: T) => boolean;
declare type Folder<T, U> = (s: U, v: T) => U;
declare type BackFolder<T, U> = (v: T, s: U) => U;
declare const bind: <T, U>(binder: Binder<T, U>, option: Option<T>) => Option<U>;
declare const bindAsync: <T, U>(binder: Mapper<T, Promise<Option<U>>>, option: Option<T>) => Promise<Option<U>>;
declare const count: <T>(option: Option<T>) => number;
declare const exists: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const filter: <T>(predicate: Predicate<T>, option: Option<T>) => Option<T>;
declare const flat: <T>(option: Option<Option<T>>) => Option<T>;
declare const fold: <T, U>(folder: Folder<T, U>, initial: U, option: Option<T>) => U;
declare const foldback: <T, U>(folder: BackFolder<T, U>, option: Option<T>, initial: U) => U;
declare const forall: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const fromArray: <T>(value: [T] | []) => Option<T>;
declare const fromNullable: <T>(value: T) => Option<T>;
declare const get: <T>(option: Option<T>) => T;
declare const iter: <T>(mapper: Mapper<T, void>, option: Option<T>) => void;
declare const map: <T, U>(mapper: Mapper<T, U>, option: Option<T>) => Option<U>;
declare const mapAsync: <T, U>(mapper: Mapper<T, Promise<U>>, option: Option<T>) => Promise<Option<U>>;
declare const toArray: <T>(option: Option<T>) => T[];
declare const toNullable: <T>(option: Option<T>) => T;
declare const withDefault: <T>(_default: T, option: Option<T>) => T;
export { bind, bindAsync, count, exists, filter, flat, fold, foldback, forall, fromArray, fromNullable, get, isNone, isSome, iter, map, mapAsync, toArray, toNullable, withDefault, Option, None, Some };

34
typescript/option/lib/index.esm.d.ts vendored Normal file
View file

@ -0,0 +1,34 @@
import { Brand } from "utility-types";
declare const none: unique symbol;
declare const some: unique symbol;
declare type None = Brand<void, typeof none>;
declare type Some<T> = Brand<T, typeof some>;
declare type Option<T> = Some<T> | None;
declare const None: Brand<void, typeof none>;
declare const Some: <T>(value: T) => Option<T>;
declare const isNone: <T>(option: Option<T>) => boolean;
declare const isSome: <T>(option: Option<T>) => boolean;
declare type Mapper<T, U> = (v: T) => U;
declare type Binder<T, U> = (v: T) => Option<U>;
declare type Predicate<T> = (v: T) => boolean;
declare type Folder<T, U> = (s: U, v: T) => U;
declare type BackFolder<T, U> = (v: T, s: U) => U;
declare const bind: <T, U>(binder: Binder<T, U>, option: Option<T>) => Option<U>;
declare const bindAsync: <T, U>(binder: Mapper<T, Promise<Option<U>>>, option: Option<T>) => Promise<Option<U>>;
declare const count: <T>(option: Option<T>) => number;
declare const exists: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const filter: <T>(predicate: Predicate<T>, option: Option<T>) => Option<T>;
declare const flat: <T>(option: Option<Option<T>>) => Option<T>;
declare const fold: <T, U>(folder: Folder<T, U>, initial: U, option: Option<T>) => U;
declare const foldback: <T, U>(folder: BackFolder<T, U>, option: Option<T>, initial: U) => U;
declare const forall: <T>(predicate: Predicate<T>, option: Option<T>) => boolean;
declare const fromArray: <T>(value: [T] | []) => Option<T>;
declare const fromNullable: <T>(value: T) => Option<T>;
declare const get: <T>(option: Option<T>) => T;
declare const iter: <T>(mapper: Mapper<T, void>, option: Option<T>) => void;
declare const map: <T, U>(mapper: Mapper<T, U>, option: Option<T>) => Option<U>;
declare const mapAsync: <T, U>(mapper: Mapper<T, Promise<U>>, option: Option<T>) => Promise<Option<U>>;
declare const toArray: <T>(option: Option<T>) => T[];
declare const toNullable: <T>(option: Option<T>) => T;
declare const withDefault: <T>(_default: T, option: Option<T>) => T;
export { bind, bindAsync, count, exists, filter, flat, fold, foldback, forall, fromArray, fromNullable, get, isNone, isSome, iter, map, mapAsync, toArray, toNullable, withDefault, Option, None, Some };

View file

@ -0,0 +1,2 @@
var n=function(n){return n},r=Symbol("none"),t={__brand:r,toString:function(){return"None"}},u=n,o=function(n){return n.__brand===r},e=function(n){return!o(n)},i=function(n,r,t){return e(t)?n(t):r},f=function(n,r){return i(n,t,r)},c=function(n,r){return i(n,Promise.resolve(t),r)},l=function(n){return Number(e(n))},a=function(n,r){return i(n,!1,r)},v=function(n,r){return i((function(r){return n(r)?u(r):t}),t,r)},b=function(r){return f(n,r)},m=function(n,r,t){return i((function(t){return n(r,t)}),r,t)},s=function(n,r,t){return i((function(r){return n(r,t)}),t,r)},_=function(n,r){return i(n,!0,r)},d=function(n){return void 0===n[0]?t:u(n[0])},N=function(n){return null===n?t:u(n)},g=function(n){if(e(n))return n;throw new Error("Cannot get value of None")},h=function(n,r){e(r)&&n(r)},w=function(n,r){return i((function(r){return u(n(r))}),t,r)},P=function(n,r){return i((function(r){return n(r).then(u)}),Promise.resolve(t),r)},S=function(n){return i((function(n){return[n]}),[],n)},p=function(r){return i(n,null,r)},x=function(r,t){return i(n,r,t)};export{t as None,u as Some,f as bind,c as bindAsync,l as count,a as exists,v as filter,b as flat,m as fold,s as foldback,_ as forall,d as fromArray,N as fromNullable,g as get,o as isNone,e as isSome,h as iter,w as map,P as mapAsync,S as toArray,p as toNullable,x as withDefault};
//# sourceMappingURL=index.esm.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
var n=function(n){return n},r=Symbol("none"),t={__brand:r,toString:function(){return"None"}},u=n,o=function(n){return n.__brand===r},e=function(n){return!o(n)},i=function(n,r,t){return e(t)?n(t):r},f=function(n,r){return i(n,t,r)},c=function(n,r){return i(n,Promise.resolve(t),r)},l=function(n){return Number(e(n))},a=function(n,r){return i(n,!1,r)},v=function(n,r){return i((function(r){return n(r)?u(r):t}),t,r)},b=function(r){return f(n,r)},m=function(n,r,t){return i((function(t){return n(r,t)}),r,t)},s=function(n,r,t){return i((function(r){return n(r,t)}),t,r)},_=function(n,r){return i(n,!0,r)},d=function(n){return void 0===n[0]?t:u(n[0])},N=function(n){return null===n?t:u(n)},g=function(n){if(e(n))return n;throw new Error("Cannot get value of None")},h=function(n,r){e(r)&&n(r)},w=function(n,r){return i((function(r){return u(n(r))}),t,r)},P=function(n,r){return i((function(r){return n(r).then(u)}),Promise.resolve(t),r)},S=function(n){return i((function(n){return[n]}),[],n)},p=function(r){return i(n,null,r)},x=function(r,t){return i(n,r,t)};export{t as None,u as Some,f as bind,c as bindAsync,l as count,a as exists,v as filter,b as flat,m as fold,s as foldback,_ as forall,d as fromArray,N as fromNullable,g as get,o as isNone,e as isSome,h as iter,w as map,P as mapAsync,S as toArray,p as toNullable,x as withDefault};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.7.0"
}
]
}

View file

@ -1,4 +1,5 @@
export * from './bind' export * from './bind'
export * from './bindAsync'
export * from './count' export * from './count'
export * from './exists' export * from './exists'
export * from './filter' export * from './filter'
@ -13,8 +14,7 @@ export * from './isNone'
export * from './isSome' export * from './isSome'
export * from './iter' export * from './iter'
export * from './map' export * from './map'
export * from './mapAsync'
export * from './toArray' export * from './toArray'
export * from './toNullable' export * from './toNullable'
export * from './withDefault' export * from './withDefault'
export * from './mapAsync'
export * from './bindAsync'

View file

@ -1,8 +1,8 @@
import { Option } from './types' import { Option } from './types'
export type Mapper<T, U> = (v: T) => U export type Mapper<T, U> = (v: T) => U
export type Binder<T, U> = Mapper<T, Option<U>> export type Binder<T, U> = (v: T) => Option<U>
export type Predicate<T> = Mapper<T, boolean> export type Predicate<T> = (v: T) => boolean
export type Folder<T, U> = (s: U, v: T) => U export type Folder<T, U> = (s: U, v: T) => U
export type BackFolder<T, U> = (v: T, s: U) => U export type BackFolder<T, U> = (v: T, s: U) => U
export type Nullable<T> = T | null export type Nullable<T> = T | null