@carbonteq/fp 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/option.d.ts +19 -5
- package/lib/option.d.ts.map +1 -1
- package/lib/result.d.ts +42 -15
- package/lib/result.d.ts.map +1 -1
- package/lib/tuple.d.ts +9 -0
- package/lib/tuple.d.ts.map +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const UNIT=Symbol.for("UNIT");function _define_property$1(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}class UnwrappedErrWithOk extends Error{constructor(r){super(`Attempted to call unwrapErr on an okay value: <${r}>`)}}class UnwrappedOkWithErr extends Error{constructor(r){super(`Attempted to call unwrap on an Err value: <${r}>`)}}
|
|
1
|
+
"use strict";var types=require("node:util/types");const UNIT=Symbol.for("UNIT");function _define_property$1(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}class UnwrappedErrWithOk extends Error{constructor(r){super(`Attempted to call unwrapErr on an okay value: <${r}>`)}}class UnwrappedOkWithErr extends Error{constructor(r){super(`Attempted to call unwrap on an Err value: <${r}>`)}}const preds=[el=>el.isOk(),el=>el.isErr()],Sentinel=Symbol.for("ResultSentinel");class Result{static Ok(val){return new Result(val,Sentinel)}static Err(err){return new Result(Sentinel,err)}isOk(){return this.val!==Sentinel}isErr(){return this.error!==Sentinel}isUnit(){return this.val===UNIT}toString(){return this.val!==Sentinel?`Result::Ok<${this.val}>`:`Result::Err<${this.error}>`}unwrap(){if(this.val===Sentinel){if(this.error instanceof Error)throw this.error;throw new UnwrappedOkWithErr(this)}return this.val}unwrapOr(def){return this.val===Sentinel?def:this.val}unwrapOrElse(def){return this.val===Sentinel?def():this.val}safeUnwrap(){return this.val===Sentinel?null:this.val}unwrapErr(){if(this.isOk())throw new UnwrappedErrWithOk(this);return this.error}safeUnwrapErr(){return this.error===Sentinel?null:this.error}map(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return types.isPromise(r)?r.then(val=>Result.Ok(val)):Result.Ok(r)}mapErr(fn){if(this.error!==Sentinel){let mappedErr=fn(this.error);return Result.Err(mappedErr)}return Result.Ok(this.val)}mapOr(default_,fn){return this.val===Sentinel?default_:fn(this.val)}mapOrAsync(default_,fn){return this.val===Sentinel?Promise.resolve(default_):fn(this.val)}and(r){return this.isErr()?this:r.isErr()?r:Result.Ok([this.val,r.val])}flatMap(fn){return this.val!==Sentinel?fn(this.val):Result.Err(this.error)}bind(fn){return this.val!==Sentinel?fn(this.val):Result.Err(this.error)}zipErr(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return types.isPromise(r)?r.then(result=>result.map(_=>this.val)):r.map(_=>this.val)}tap(fn){return this.val!==Sentinel&&fn(this.val),this}async tapAsync(fn){return this.val!==Sentinel&&await fn(this.val),this}zip(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return types.isPromise(r)?r.then(u=>Result.Ok([this.val,u])):Result.Ok([this.val,r])}flatZip(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return types.isPromise(r)?r.then(other=>other.map(u=>[this.val,u])):r.map(u=>[this.val,u])}static all(c,seq){let pred=preds[Number("ok"===c)];for(let el of seq)if(!pred(el))return!1;return!0}static any(c,seq){let pred=preds[Number("ok"===c)];for(let el of seq)if(pred(el))return!0;return!1}static sequence(...results){let vals=[];for(let r of results){if(r.isErr())return r;vals.push(r.unwrap())}return Result.Ok(vals)}static async lift(r){return r.isErr()?Promise.resolve(Result.Err(r.error)):r.val.then(v=>Result.Ok(v))}innerMap(mapper){if(this.val===Sentinel)return this;if(Array.isArray(this.val))return Result.Ok(this.val.map(mapper));throw Error("Can only be called for Result<Array<T>, E>")}pipe(...fns){let res=this;for(let fn of fns)res=res.map(fn);return res}constructor(val,error){_define_property$1(this,"val",void 0),_define_property$1(this,"error",void 0),this.val=val,this.error=error}}function _define_property(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}_define_property$1(Result,"UNIT_RESULT",new Result(UNIT,null));class UnwrappedNone extends Error{constructor(){super("Unwrapped Option<None>")}}const UNWRAPPED_NONE_ERR=new UnwrappedNone,NONE_VAL=Symbol.for("None");class Option{static Some(val){return new Option(val)}static fromNullable(val){return null===val?Option.None:Option.Some(val)}isSome(){return this.val!==NONE_VAL}isNone(){return this.val===NONE_VAL}isUnit(){return this.val===UNIT}unwrap(){if(this.val!==NONE_VAL)return this.val;throw UNWRAPPED_NONE_ERR}safeUnwrap(){return this.val!==NONE_VAL?this.val:null}toString(){return this.isNone()?"Option::None":`Option::Some(${this.val})`}map(fn){if(this.isNone())return Option.None;let val=fn(this.val);return types.isPromise(val)?val.then(u=>Option.Some(u)):Option.Some(val)}mapOr(def,fn){if(this.isNone())return Option.Some(def);let val=fn(this.val);return types.isPromise(val)?val.then(u=>Option.Some(u)):Option.Some(val)}flatMap(fn){return this.val!==NONE_VAL?fn(this.val):Option.None}bind(fn){return this.val!==NONE_VAL?fn(this.val):Option.None}and(opt){return this.val!==NONE_VAL&&opt.val!==NONE_VAL?Option.Some([this.val,opt.val]):Option.None}tap(fn){return this.val!==NONE_VAL&&fn(this.val),this}async tapAsync(fn){return this.val!==NONE_VAL&&await fn(this.val),this}zip(fn){if(this.val===NONE_VAL)return Option.None;let r=fn(this.val);return types.isPromise(r)?r.then(u=>Option.Some([this.val,u])):Option.Some([this.val,r])}flatZip(fn){if(this.val===NONE_VAL)return Option.None;let r=fn(this.val);return types.isPromise(r)?r.then(opt=>opt.map(u=>[this.val,u])):r.map(u=>[this.val,u])}static any(seq){for(let el of seq)if(el.val!==NONE_VAL)return!0;return!1}static all(seq){for(let el of seq)if(el.val===NONE_VAL)return!1;return!0}static sequence(...options){let vals=[];for(let opt of options){if(opt.val===NONE_VAL)return Option.None;vals.push(opt.val)}return Option.Some(vals)}static async lift(opt){return opt.isNone()?Promise.resolve(Option.None):opt.val.then(val=>Option.Some(val))}innerMap(mapper){if(this.val===NONE_VAL)return this;if(Array.isArray(this.val))return Option.Some(this.val.map(mapper));throw Error("Can only be called for Option<Array<T>>")}pipe(...fns){let x=this;for(let fn of fns)x=x.map(fn);return x}constructor(val){_define_property(this,"val",void 0),this.val=val}}_define_property(Option,"None",new Option(NONE_VAL)),_define_property(Option,"UNIT_OPT",new Option(UNIT)),exports.Option=Option,exports.Result=Result,exports.UNIT=UNIT,exports.UnwrappedErrWithOk=UnwrappedErrWithOk,exports.UnwrappedNone=UnwrappedNone,exports.UnwrappedOkWithErr=UnwrappedOkWithErr,exports.matchOpt=(o,branches)=>o.isSome()?branches.Some(o.unwrap()):branches.None(),exports.matchRes=(r,branches)=>r.isOk()?branches.Ok(r.unwrap()):branches.Err(r.unwrapErr());
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let UNIT=Symbol.for("UNIT");function _define_property$1(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}class UnwrappedErrWithOk extends Error{constructor(r){super(`Attempted to call unwrapErr on an okay value: <${r}>`)}}class UnwrappedOkWithErr extends Error{constructor(r){super(`Attempted to call unwrap on an Err value: <${r}>`)}}
|
|
1
|
+
import{isPromise}from"node:util/types";let UNIT=Symbol.for("UNIT");function _define_property$1(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}class UnwrappedErrWithOk extends Error{constructor(r){super(`Attempted to call unwrapErr on an okay value: <${r}>`)}}class UnwrappedOkWithErr extends Error{constructor(r){super(`Attempted to call unwrap on an Err value: <${r}>`)}}let preds=[el=>el.isOk(),el=>el.isErr()],Sentinel=Symbol.for("ResultSentinel");class Result{static Ok(val){return new Result(val,Sentinel)}static Err(err){return new Result(Sentinel,err)}isOk(){return this.val!==Sentinel}isErr(){return this.error!==Sentinel}isUnit(){return this.val===UNIT}toString(){return this.val!==Sentinel?`Result::Ok<${this.val}>`:`Result::Err<${this.error}>`}unwrap(){if(this.val===Sentinel){if(this.error instanceof Error)throw this.error;throw new UnwrappedOkWithErr(this)}return this.val}unwrapOr(def){return this.val===Sentinel?def:this.val}unwrapOrElse(def){return this.val===Sentinel?def():this.val}safeUnwrap(){return this.val===Sentinel?null:this.val}unwrapErr(){if(this.isOk())throw new UnwrappedErrWithOk(this);return this.error}safeUnwrapErr(){return this.error===Sentinel?null:this.error}map(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return isPromise(r)?r.then(val=>Result.Ok(val)):Result.Ok(r)}mapErr(fn){if(this.error!==Sentinel){let mappedErr=fn(this.error);return Result.Err(mappedErr)}return Result.Ok(this.val)}mapOr(default_,fn){return this.val===Sentinel?default_:fn(this.val)}mapOrAsync(default_,fn){return this.val===Sentinel?Promise.resolve(default_):fn(this.val)}and(r){return this.isErr()?this:r.isErr()?r:Result.Ok([this.val,r.val])}flatMap(fn){return this.val!==Sentinel?fn(this.val):Result.Err(this.error)}bind(fn){return this.val!==Sentinel?fn(this.val):Result.Err(this.error)}zipErr(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return isPromise(r)?r.then(result=>result.map(_=>this.val)):r.map(_=>this.val)}tap(fn){return this.val!==Sentinel&&fn(this.val),this}async tapAsync(fn){return this.val!==Sentinel&&await fn(this.val),this}zip(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return isPromise(r)?r.then(u=>Result.Ok([this.val,u])):Result.Ok([this.val,r])}flatZip(fn){if(this.val===Sentinel)return Result.Err(this.error);let r=fn(this.val);return isPromise(r)?r.then(other=>other.map(u=>[this.val,u])):r.map(u=>[this.val,u])}static all(c,seq){let pred=preds[Number("ok"===c)];for(let el of seq)if(!pred(el))return!1;return!0}static any(c,seq){let pred=preds[Number("ok"===c)];for(let el of seq)if(pred(el))return!0;return!1}static sequence(...results){let vals=[];for(let r of results){if(r.isErr())return r;vals.push(r.unwrap())}return Result.Ok(vals)}static async lift(r){return r.isErr()?Promise.resolve(Result.Err(r.error)):r.val.then(v=>Result.Ok(v))}innerMap(mapper){if(this.val===Sentinel)return this;if(Array.isArray(this.val))return Result.Ok(this.val.map(mapper));throw Error("Can only be called for Result<Array<T>, E>")}pipe(...fns){let res=this;for(let fn of fns)res=res.map(fn);return res}constructor(val,error){_define_property$1(this,"val",void 0),_define_property$1(this,"error",void 0),this.val=val,this.error=error}}function _define_property(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}_define_property$1(Result,"UNIT_RESULT",new Result(UNIT,null));class UnwrappedNone extends Error{constructor(){super("Unwrapped Option<None>")}}let UNWRAPPED_NONE_ERR=new UnwrappedNone,NONE_VAL=Symbol.for("None");class Option{static Some(val){return new Option(val)}static fromNullable(val){return null===val?Option.None:Option.Some(val)}isSome(){return this.val!==NONE_VAL}isNone(){return this.val===NONE_VAL}isUnit(){return this.val===UNIT}unwrap(){if(this.val!==NONE_VAL)return this.val;throw UNWRAPPED_NONE_ERR}safeUnwrap(){return this.val!==NONE_VAL?this.val:null}toString(){return this.isNone()?"Option::None":`Option::Some(${this.val})`}map(fn){if(this.isNone())return Option.None;let val=fn(this.val);return isPromise(val)?val.then(u=>Option.Some(u)):Option.Some(val)}mapOr(def,fn){if(this.isNone())return Option.Some(def);let val=fn(this.val);return isPromise(val)?val.then(u=>Option.Some(u)):Option.Some(val)}flatMap(fn){return this.val!==NONE_VAL?fn(this.val):Option.None}bind(fn){return this.val!==NONE_VAL?fn(this.val):Option.None}and(opt){return this.val!==NONE_VAL&&opt.val!==NONE_VAL?Option.Some([this.val,opt.val]):Option.None}tap(fn){return this.val!==NONE_VAL&&fn(this.val),this}async tapAsync(fn){return this.val!==NONE_VAL&&await fn(this.val),this}zip(fn){if(this.val===NONE_VAL)return Option.None;let r=fn(this.val);return isPromise(r)?r.then(u=>Option.Some([this.val,u])):Option.Some([this.val,r])}flatZip(fn){if(this.val===NONE_VAL)return Option.None;let r=fn(this.val);return isPromise(r)?r.then(opt=>opt.map(u=>[this.val,u])):r.map(u=>[this.val,u])}static any(seq){for(let el of seq)if(el.val!==NONE_VAL)return!0;return!1}static all(seq){for(let el of seq)if(el.val===NONE_VAL)return!1;return!0}static sequence(...options){let vals=[];for(let opt of options){if(opt.val===NONE_VAL)return Option.None;vals.push(opt.val)}return Option.Some(vals)}static async lift(opt){return opt.isNone()?Promise.resolve(Option.None):opt.val.then(val=>Option.Some(val))}innerMap(mapper){if(this.val===NONE_VAL)return this;if(Array.isArray(this.val))return Option.Some(this.val.map(mapper));throw Error("Can only be called for Option<Array<T>>")}pipe(...fns){let x=this;for(let fn of fns)x=x.map(fn);return x}constructor(val){_define_property(this,"val",void 0),this.val=val}}_define_property(Option,"None",new Option(NONE_VAL)),_define_property(Option,"UNIT_OPT",new Option(UNIT));let matchRes=(r,branches)=>r.isOk()?branches.Ok(r.unwrap()):branches.Err(r.unwrapErr()),matchOpt=(o,branches)=>o.isSome()?branches.Some(o.unwrap()):branches.None();export{Option,Result,UNIT,UnwrappedErrWithOk,UnwrappedNone,UnwrappedOkWithErr,matchOpt,matchRes};
|
package/lib/option.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ type CombinedOptions<T extends Option<unknown>[]> = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare class Option<T> {
|
|
13
13
|
readonly val: T;
|
|
14
|
-
private readonly ok;
|
|
15
14
|
private constructor();
|
|
16
15
|
static readonly None: Option<never>;
|
|
17
16
|
static readonly UNIT_OPT: UnitOption;
|
|
@@ -19,6 +18,7 @@ export declare class Option<T> {
|
|
|
19
18
|
static fromNullable<T>(val: T): Option<NonNullable<T>>;
|
|
20
19
|
isSome(): this is Option<T>;
|
|
21
20
|
isNone(): this is Option<never>;
|
|
21
|
+
isUnit(): this is Option<UNIT>;
|
|
22
22
|
unwrap(): T;
|
|
23
23
|
safeUnwrap(): T | null;
|
|
24
24
|
toString(): string;
|
|
@@ -26,18 +26,32 @@ export declare class Option<T> {
|
|
|
26
26
|
map<U>(fn: (val: T) => Promise<U>): Promise<Option<U>>;
|
|
27
27
|
mapOr<U>(def: U, fn: (val: T) => U): Option<U>;
|
|
28
28
|
mapOr<U>(def: U, fn: (val: T) => Promise<U>): Promise<Option<U>>;
|
|
29
|
+
flatMap<U>(fn: (val: T) => Option<U>): Option<U>;
|
|
30
|
+
flatMap<U>(fn: (val: T) => Promise<Option<U>>): Promise<Option<U>>;
|
|
29
31
|
bind<U>(fn: (val: T) => Option<U>): Option<U>;
|
|
30
32
|
bind<U>(fn: (val: T) => Promise<Option<U>>): Promise<Option<U>>;
|
|
31
33
|
and<U>(opt: Option<U>): Option<[T, U]>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
zip<U>(
|
|
35
|
-
|
|
34
|
+
tap(fn: (val: T) => void): Option<T>;
|
|
35
|
+
tapAsync(fn: (val: T) => Promise<unknown>): Promise<Option<T>>;
|
|
36
|
+
zip<U>(fn: (val: T) => Promise<U>): Promise<Option<[T, U]>>;
|
|
37
|
+
zip<U>(fn: (val: T) => U): Option<[T, U]>;
|
|
38
|
+
flatZip<U>(fn: (val: T) => Promise<Option<U>>): Promise<Option<[T, U]>>;
|
|
39
|
+
flatZip<U>(fn: (val: T) => Option<U>): Option<[T, U]>;
|
|
36
40
|
static any<T>(seq: Option<T>[]): boolean;
|
|
37
41
|
static all<T>(seq: Option<T>[]): boolean;
|
|
38
42
|
static sequence<T extends Option<unknown>[]>(...options: T): Option<CombinedOptions<T>>;
|
|
39
43
|
static lift<T>(opt: Option<Promise<T>>): Promise<Option<T>>;
|
|
40
44
|
innerMap<U>(mapper: InnerMapMapper<T, U>): InnerMapReturn<T, U>;
|
|
45
|
+
pipe<U>(fn: (val: T) => U): Option<U>;
|
|
46
|
+
pipe<U, V>(fn: (val: T) => U, fn2: (val: U) => V): Option<V>;
|
|
47
|
+
pipe<U, V, W>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W): Option<W>;
|
|
48
|
+
pipe<U, V, W, X>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X): Option<X>;
|
|
49
|
+
pipe<U, V, W, X, Y>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y): Option<Y>;
|
|
50
|
+
pipe<U, V, W, X, Y, Z>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z): Option<Z>;
|
|
51
|
+
pipe<U, V, W, X, Y, Z, A>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A): Option<A>;
|
|
52
|
+
pipe<U, V, W, X, Y, Z, A, B>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A, fn8: (val: A) => B): Option<B>;
|
|
53
|
+
pipe<U, V, W, X, Y, Z, A, B, C>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A, fn8: (val: A) => B, fn9: (val: B) => C): Option<C>;
|
|
54
|
+
pipe<U, V, W, X, Y, Z, A, B, C, D>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A, fn8: (val: A) => B, fn9: (val: B) => C, fn10: (val: C) => D): Option<D>;
|
|
41
55
|
}
|
|
42
56
|
export {};
|
|
43
57
|
//# sourceMappingURL=option.d.ts.map
|
package/lib/option.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option.d.ts","sourceRoot":"","sources":["../src/option.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"option.d.ts","sourceRoot":"","sources":["../src/option.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAO9B,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,KAAK,CAAC,GACrD,CAAC,GAAG,EAAE,KAAK,KAAK,CAAC,GACjB,KAAK,CAAC;AAET,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAQhF,qBAAa,aAAc,SAAQ,KAAK;;CAIvC;AAKD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AACtC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACpE,KAAK,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI;KAClD,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,qBAAa,MAAM,CAAC,CAAC;IACA,QAAQ,CAAC,GAAG,EAAE,CAAC;IAAnC,OAAO;IAEP,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAyC;IAC5E,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAoB;IAExD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,GA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AG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAChB,MAAM,CAAC,CAAC,CAAC;IACZ,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAChC,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EACjB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAClB,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GACjB,MAAM,CAAC,CAAC,CAAC;CASZ"}
|
package/lib/result.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare class Result<T, E> {
|
|
|
34
34
|
static Err<E, T = never>(err: E): Result<T, E>;
|
|
35
35
|
isOk(): this is Result<T, never>;
|
|
36
36
|
isErr(): this is Result<never, E>;
|
|
37
|
+
isUnit(): this is Result<UNIT, never>;
|
|
37
38
|
toString(): string;
|
|
38
39
|
unwrap(): T;
|
|
39
40
|
unwrapOr(def: T): T;
|
|
@@ -44,7 +45,7 @@ export declare class Result<T, E> {
|
|
|
44
45
|
safeUnwrapErr(): E | null;
|
|
45
46
|
/**
|
|
46
47
|
*
|
|
47
|
-
* @param {Mapper<T, U>}
|
|
48
|
+
* @param {Mapper<T, U>} fn The mapping/endofunctor to apply to the internal Ok value (T -> U)
|
|
48
49
|
* @returns Result<U, E> containing the mapped value
|
|
49
50
|
* @example
|
|
50
51
|
* const r = Result.Ok({data: 42})
|
|
@@ -59,10 +60,26 @@ export declare class Result<T, E> {
|
|
|
59
60
|
mapErr<U>(fn: Mapper<E, U>): Result<T, U>;
|
|
60
61
|
mapOr<U>(default_: U, fn: Mapper<T, U>): U;
|
|
61
62
|
mapOrAsync<U>(default_: U, fn: AsyncMapper<T, U>): Promise<U>;
|
|
62
|
-
/** For combining two results. For the lazy eval version, see {@link
|
|
63
|
+
/** For combining two results. For the lazy eval version, see {@link flatZip} and {@link zipAsync} */
|
|
63
64
|
and<U, E2>(r: Result<U, E2>): Result<[T, U], E | E2>;
|
|
64
65
|
/**
|
|
65
|
-
* Also known as `andThen` or `fmap`
|
|
66
|
+
* Also known as `andThen`, `bind` or `fmap`
|
|
67
|
+
* Like Result.map but used in cases where the mapper func returns a Result instead of a containable value
|
|
68
|
+
* @example
|
|
69
|
+
* const r: Result<string, SomeError> = Result.Ok("42")
|
|
70
|
+
* const mapper = (d: string) => {
|
|
71
|
+
* const n = Number.parseInt(d)
|
|
72
|
+
* if(Number.isNumber(n) && !Number.isNaN(n)) return Result.Ok(n)
|
|
73
|
+
*
|
|
74
|
+
* return Result.Err(new InvalidNumStringError(d))
|
|
75
|
+
* }
|
|
76
|
+
* const result1 = r.map(mapper) // Type is Result<Result<number, InvalidNumStringError>, SomeError>
|
|
77
|
+
* const result2 = r.flatMap(mapper) // Type is Result<number, SomeError | InvalidNumStringError>
|
|
78
|
+
*/
|
|
79
|
+
flatMap<U, E2>(fn: (val: T) => Promise<Result<U, E | E2>>): Promise<Result<U, E | E2>>;
|
|
80
|
+
flatMap<U, E2>(fn: (val: T) => Result<U, E2>): Result<U, E | E2>;
|
|
81
|
+
/**
|
|
82
|
+
* Also known as `andThen`, `fmap` or `flatMap`
|
|
66
83
|
* Like Result.map but used in cases where the mapper func returns a Result instead of a containable value
|
|
67
84
|
* @example
|
|
68
85
|
* const r: Result<string, SomeError> = Result.Ok("42")
|
|
@@ -84,23 +101,23 @@ export declare class Result<T, E> {
|
|
|
84
101
|
* const binderOk = (d: string) => Result.Ok<number, SomeOtherError>(0909)
|
|
85
102
|
* const binderErr = (d: string) => Result.Err<number, SomeOtherError>(new SomeOtherError())
|
|
86
103
|
*
|
|
87
|
-
* const res1 = r.
|
|
88
|
-
* const res2 = r.
|
|
104
|
+
* const res1 = r.zipErr(binderOk) // Result<string, SomeError | SomeOtherError> - Value: Result.Ok('42') - No change in Ok type
|
|
105
|
+
* const res2 = r.zipErr(binderErr) // Result<string, SomeError | SomeOtherError> - Value: Result.Err(new SomeOtherError())
|
|
89
106
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
zipErr<E2>(fn: (val: T) => Promise<Result<unknown, E2>>): Promise<Result<T, E | E2>>;
|
|
108
|
+
zipErr<E2>(fn: (val: T) => Result<unknown, E2>): Result<T, E | E2>;
|
|
92
109
|
/** For running infallible side-effects on the contained value. Up to the programmer to ensure the underlying function doesn't fail */
|
|
93
|
-
|
|
110
|
+
tap(fn: (val: T) => void): Result<T, E>;
|
|
94
111
|
/**
|
|
95
|
-
* Async version of {@link
|
|
96
|
-
* @see {@link
|
|
112
|
+
* Async version of {@link tap}
|
|
113
|
+
* @see {@link tap}
|
|
97
114
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
115
|
+
tapAsync(fn: (val: T) => Promise<void>): Promise<Result<T, E>>;
|
|
116
|
+
zip<U>(fn: (val: T) => Promise<U>): Promise<Result<[T, U], E>>;
|
|
117
|
+
zip<U>(fn: (val: T) => U): Result<[T, U], E>;
|
|
101
118
|
/** For combining two results lazily. For the eager eval version, see {@link and} */
|
|
102
|
-
|
|
103
|
-
|
|
119
|
+
flatZip<U, E2>(fn: (val: T) => Promise<Result<U, E2>>): Promise<Result<[T, U], E | E2>>;
|
|
120
|
+
flatZip<U, E2>(fn: (val: T) => Result<U, E2>): Result<[T, U], E | E2>;
|
|
104
121
|
/** Type guard specifying all array results as Ok/Err */
|
|
105
122
|
static all<T, E extends Error>(c: "ok", seq: Result<T, E>[]): seq is Result<T, never>[];
|
|
106
123
|
static all<T, E extends Error>(c: "err", seq: Result<T, E>[]): seq is Result<never, E>[];
|
|
@@ -117,6 +134,16 @@ export declare class Result<T, E> {
|
|
|
117
134
|
/** Convert a Result of a Promise to the Promise of a Result */
|
|
118
135
|
static lift<T, E extends Error>(r: Result<Promise<T>, E>): Promise<Result<T, E>>;
|
|
119
136
|
innerMap<U>(mapper: InnerMapMapper<T, U>): InnerMapReturn<T, E, U>;
|
|
137
|
+
pipe<U>(fn: (val: T) => U): Result<U, E>;
|
|
138
|
+
pipe<U, V>(fn: (val: T) => U, fn2: (val: U) => V): Result<V, E>;
|
|
139
|
+
pipe<U, V, W>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W): Result<W, E>;
|
|
140
|
+
pipe<U, V, W, X>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X): Result<X, E>;
|
|
141
|
+
pipe<U, V, W, X, Y>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y): Result<Y, E>;
|
|
142
|
+
pipe<U, V, W, X, Y, Z>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z): Result<Z, E>;
|
|
143
|
+
pipe<U, V, W, X, Y, Z, A>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A): Result<A, E>;
|
|
144
|
+
pipe<U, V, W, X, Y, Z, A, B>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A, fn8: (val: A) => B): Result<B, E>;
|
|
145
|
+
pipe<U, V, W, X, Y, Z, A, B, C>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A, fn8: (val: A) => B, fn9: (val: B) => C): Result<C, E>;
|
|
146
|
+
pipe<U, V, W, X, Y, Z, A, B, C, D>(fn: (val: T) => U, fn2: (val: U) => V, fn3: (val: V) => W, fn4: (val: W) => X, fn5: (val: X) => Y, fn6: (val: Y) => Z, fn7: (val: Z) => A, fn8: (val: A) => B, fn9: (val: B) => C, fn10: (val: C) => D): Result<D, E>;
|
|
120
147
|
}
|
|
121
148
|
export {};
|
|
122
149
|
//# sourceMappingURL=result.d.ts.map
|
package/lib/result.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,qBAAa,kBAAmB,SAAQ,KAAK;gBAChC,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;CAGvC;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAChC,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;CAGvC;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,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|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const TUPLE_KEY: unique symbol;
|
|
2
|
+
export interface Tuple<Inner> extends Array<Inner> {
|
|
3
|
+
[TUPLE_KEY]: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const setAsTuple: <Inner, T extends Array<Inner>>(arr: T) => Tuple<Inner>;
|
|
6
|
+
export declare const isTuple: <Inner>(t: unknown) => t is Tuple<Inner>;
|
|
7
|
+
export type AppendToTuple<T, U> = T extends [...infer Rest, infer L] ? [...Rest, L, U] : [T, U];
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=tuple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../src/tuple.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,SAAS,eAAsB,CAAC;AAEtC,MAAM,WAAW,KAAK,CAAC,KAAK,CAAE,SAAQ,KAAK,CAAC,KAAK,CAAC;IACjD,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,GAAI,KAAK,EAAE,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,OAClD,CAAC,KACJ,KAAK,CAAC,KAAK,CAOb,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,KAAK,KAAK,OAAO,KAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAEhC,CAAC;AAE7B,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,MAAM,CAAC,CAAC,GACjE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,GACf,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|