@swan-io/boxed
Advanced tools
Comparing version 2.0.1 to 2.1.0-beta
import { Option, Result } from "./OptionResult"; | ||
import { LooseRecord, Remap } from "./types"; | ||
interface IAsyncData<A> { | ||
import { LooseRecord } from "./types"; | ||
declare class __AsyncData<A> { | ||
static P: { | ||
Done: <const A_1>(value: A_1) => { | ||
readonly tag: "Done"; | ||
readonly value: A_1; | ||
}; | ||
NotAsked: { | ||
readonly tag: "NotAsked"; | ||
}; | ||
Loading: { | ||
readonly tag: "Loading"; | ||
}; | ||
}; | ||
/** | ||
* Returns the AsyncData containing the value from the callback | ||
* | ||
* (AsyncData\<A>, A => B) => AsyncData\<B> | ||
* Create an AsyncData.Done value | ||
*/ | ||
map<B>(this: AsyncData<A>, func: (value: A) => B): AsyncData<B>; | ||
static Done: <A_1 = never>(value: A_1) => AsyncData<A_1>; | ||
/** | ||
* Returns the AsyncData containing the value from the callback | ||
* | ||
* (AsyncData\<A>, A => AsyncData\<B>) => AsyncData\<B> | ||
* Create an AsyncData.Loading value | ||
*/ | ||
static Loading: <A_1 = never>() => AsyncData<A_1>; | ||
/** | ||
* Create an AsyncData.NotAsked value | ||
*/ | ||
static NotAsked: <A_1 = never>() => AsyncData<A_1>; | ||
/** | ||
* Turns an array of asyncData into an asyncData of array | ||
*/ | ||
static all: <AsyncDatas extends [] | AsyncData<any>[]>(asyncDatas: AsyncDatas) => AsyncData<{ [K in keyof AsyncDatas]: AsyncDatas[K] extends AsyncData<infer T> ? T : never; }>; | ||
/** | ||
* Turns an dict of asyncData into a asyncData of dict | ||
*/ | ||
static allFromDict: <Dict extends LooseRecord<AsyncData<any>>>(dict: Dict) => AsyncData<{ [K in keyof Dict]: Dict[K] extends AsyncData<infer T> ? T : never; }>; | ||
static equals: <A_1>(a: AsyncData<A_1>, b: AsyncData<A_1>, equals: (a: A_1, b: A_1) => boolean) => boolean; | ||
static isAsyncData: (value: unknown) => value is AsyncData<unknown>; | ||
map<B>(this: AsyncData<A>, func: (value: A) => B): AsyncData<B>; | ||
flatMap<B>(this: AsyncData<A>, func: (value: A) => AsyncData<B>): AsyncData<B>; | ||
/** | ||
* For AsyncData<Result<*>>: | ||
* | ||
* Takes a callback taking the Ok value and returning a new result and returns an AsyncData with this new result | ||
* | ||
* (AsyncData\<Result<A, E>>, A => \<Result<B, F>) => AsyncData\<Result<B, F | E>> | ||
*/ | ||
mapOkToResult<A, E, B, F>(this: AsyncData<Result<A, E>>, func: (value: A) => Result<B, F>): AsyncData<Result<B, F | E>>; | ||
/** | ||
* Takes a callback taking the Ok value and returning a new result and returns an AsyncData with this new result | ||
* For AsyncData<Result<*>>: | ||
* | ||
* (AsyncData\<Result<A, E>>, E => \<Result<B, F>) => AsyncData\<Result<A | B, F>> | ||
* Takes a callback taking the Error value and returning a new result and returns an AsyncData with this new result | ||
*/ | ||
mapErrorToResult<A, E, B, F>(this: AsyncData<Result<A, E>>, func: (value: E) => Result<B, F>): AsyncData<Result<A | B, F>>; | ||
/** | ||
* For AsyncData<Result<*>>: | ||
* | ||
* Takes a callback taking the Ok value and returning a new ok value and returns an AsyncData resolving to this new result | ||
* | ||
* (AsyncData\<Result<A, E>>, A => B) => AsyncData\<Result<B, E>> | ||
*/ | ||
mapOk<A, E, B>(this: AsyncData<Result<A, E>>, func: (value: A) => B): AsyncData<Result<B, E>>; | ||
/** | ||
* For AsyncData<Result<*>>: | ||
* | ||
* Takes a callback taking the Error value and returning a new error value and returns an AsyncData to this new result | ||
* | ||
* (AsyncData\<Result<A, E>>, E => B) => AsyncData\<Result<A, B>> | ||
*/ | ||
mapError<A, E, B>(this: AsyncData<Result<A, E>>, func: (value: E) => B): AsyncData<Result<A, B>>; | ||
/** | ||
* For AsyncData<Result<*>>: | ||
* | ||
* Takes a callback taking the Ok value and returning an AsyncData | ||
* | ||
* (AsyncData\<Result<A, E>>, A => AsyncData\<Result\<B, F>>) => AsyncData\<Result<B, F | E>> | ||
*/ | ||
flatMapOk<A, E, B, F>(this: AsyncData<Result<A, E>>, func: (value: A) => AsyncData<Result<B, F>>): AsyncData<Result<B, F | E>>; | ||
/** | ||
* For AsyncData<Result<*>>: | ||
* | ||
* Takes a callback taking the Error value and returning an AsyncData | ||
* | ||
* (AsyncData\<Result<A, E>>, E => AsyncData\<Result\<B, F>>) => AsyncData\<Result<A | B, F | E>> | ||
*/ | ||
flatMapError<A, E, B, F>(this: AsyncData<Result<A, E>>, func: (value: E) => AsyncData<Result<B, F>>): AsyncData<Result<A | B, F>>; | ||
/** | ||
* Return the value if present, and the fallback otherwise | ||
* | ||
* (AsyncData\<A>, A) => A | ||
* Returns the value. Use within `if (asyncData.isDone()) { ... }` | ||
*/ | ||
get(this: Done<A>): A; | ||
getWithDefault(this: AsyncData<A>, defaultValue: A): A; | ||
/** | ||
* Explodes the AsyncData given its case | ||
*/ | ||
match<B>(this: AsyncData<A>, config: { | ||
@@ -66,79 +87,20 @@ Done: (value: A) => B; | ||
}): B; | ||
/** | ||
* Runs the callback and returns `this` | ||
*/ | ||
tap(this: AsyncData<A>, func: (asyncData: AsyncData<A>) => unknown): AsyncData<A>; | ||
/** | ||
* Return an option of the value | ||
* | ||
* (AsyncData\<A>) => Option\<A> | ||
*/ | ||
toOption(this: AsyncData<A>): Option<A>; | ||
/** | ||
* Typeguard | ||
*/ | ||
isDone(this: AsyncData<A>): this is Done<A>; | ||
/** | ||
* Typeguard | ||
*/ | ||
isLoading(this: AsyncData<A>): this is Loading<A>; | ||
/** | ||
* Typeguard | ||
*/ | ||
isNotAsked(this: AsyncData<A>): this is NotAsked<A>; | ||
} | ||
type Done<A> = Remap<IAsyncData<A>> & { | ||
interface Done<A> extends __AsyncData<A> { | ||
tag: "Done"; | ||
value: A; | ||
/** | ||
* Returns the value. Use within `if (asyncData.isDone()) { ... }` | ||
*/ | ||
get(this: Done<A>): A; | ||
}; | ||
type Loading<A> = Remap<IAsyncData<A>> & { | ||
} | ||
interface Loading<A> extends __AsyncData<A> { | ||
tag: "Loading"; | ||
}; | ||
type NotAsked<A> = Remap<IAsyncData<A>> & { | ||
} | ||
interface NotAsked<A> extends __AsyncData<A> { | ||
tag: "NotAsked"; | ||
}; | ||
} | ||
export declare const AsyncData: typeof __AsyncData; | ||
export type AsyncData<A> = Done<A> | Loading<A> | NotAsked<A>; | ||
declare const Done: <A = never>(value: A) => AsyncData<A>; | ||
declare const Loading: <A = never>() => AsyncData<A>; | ||
declare const NotAsked: <A = never>() => AsyncData<A>; | ||
export declare const AsyncData: { | ||
/** | ||
* Create an AsyncData.Done value | ||
*/ | ||
Done: <A = never>(value: A) => AsyncData<A>; | ||
/** | ||
* Create an AsyncData.Loading value | ||
*/ | ||
Loading: <A_1 = never>() => AsyncData<A_1>; | ||
/** | ||
* Create an AsyncData.NotAsked value | ||
*/ | ||
NotAsked: <A_2 = never>() => AsyncData<A_2>; | ||
/** | ||
* Turns an array of asyncData into an asyncData of array | ||
*/ | ||
all<AsyncDatas extends [] | AsyncData<any>[]>(asyncDatas: AsyncDatas): AsyncData<{ [K in keyof AsyncDatas]: AsyncDatas[K] extends AsyncData<infer T> ? T : never; }>; | ||
/** | ||
* Turns an dict of asyncData into a asyncData of dict | ||
*/ | ||
allFromDict<Dict extends LooseRecord<AsyncData<any>>>(dict: Dict): AsyncData<{ [K_1 in keyof Dict]: Dict[K_1] extends AsyncData<infer T_1> ? T_1 : never; }>; | ||
equals<A_3>(a: AsyncData<A_3>, b: AsyncData<A_3>, equals: (a: A_3, b: A_3) => boolean): boolean; | ||
isAsyncData: (value: unknown) => value is AsyncData<unknown>; | ||
P: { | ||
Done: <const A_4>(value: A_4) => { | ||
readonly tag: "Done"; | ||
readonly value: A_4; | ||
}; | ||
NotAsked: { | ||
readonly tag: "NotAsked"; | ||
}; | ||
Loading: { | ||
readonly tag: "Loading"; | ||
}; | ||
}; | ||
}; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
function t(){return t=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t},t.apply(this,arguments)}var n,r,e,u=function(t){return Object.keys(t)},o=function(t){return Object.values(t)},i={__proto__:null,entries:function(t){return Object.entries(t)},keys:u,values:o},a=function(t,n){for(var r=Math.min(t.length,n.length),e=Array(r),u=-1;++u<r;)e[u]=[t[u],n[u]];return e},c={map:function(t){return"Some"===this.tag?s(t(this.value)):this},flatMap:function(t){return"Some"===this.tag?t(this.value):this},filter:function(t){return"Some"===this.tag&&t(this.value)?this:v.None()},getWithDefault:function(t){return"Some"===this.tag?this.value:t},match:function(t){return"Some"===this.tag?t.Some(this.value):t.None()},tap:function(t){return t(this),this},toUndefined:function(){return"Some"===this.tag?this.value:void 0},toNull:function(){return"Some"===this.tag?this.value:null},toResult:function(t){return this.match({Some:function(t){return k.Ok(t)},None:function(){return k.Error(t)}})},isSome:function(){return"Some"===this.tag},isNone:function(){return"None"===this.tag},__boxed_type__:"Option"},f=t({},c,{get:function(){return this.value}}),s=function(t){var n=Object.create(f);return n.tag="Some",n.value=t,n},l=((n=Object.create(c)).tag="None",n),h=function(){return l},v={Some:s,None:h,isOption:function(t){return null!=t&&(Object.prototype.isPrototypeOf.call(c,t)||Object.prototype.isPrototypeOf.call(f,t))},fromNullable:function(t){return null==t?h():s(t)},fromNull:function(t){return null===t?h():s(t)},fromUndefined:function(t){return void 0===t?h():s(t)},all:function(t){for(var n,r=t.length,e=v.Some([]),u=0,o=function(){if(u>=r)return{v:e};var n=t[u];null!=n&&(e=e.flatMap(function(t){return n.map(function(n){return t.push(n),t})})),u++};;)if(n=o())return n.v},allFromDict:function(t){var n=u(t);return this.all(o(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return"Some"===t.tag&&"Some"===n.tag?r(t.value,n.value):t.tag===n.tag},P:{Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}}},p={map:function(t){return"Ok"===this.tag?O(t(this.value)):this},mapError:function(t){return"Ok"===this.tag?this:_(t(this.value))},flatMap:function(t){return"Ok"===this.tag?t(this.value):this},flatMapError:function(t){return"Ok"===this.tag?this:t(this.value)},getWithDefault:function(t){return"Ok"===this.tag?this.value:t},match:function(t){return"Ok"===this.tag?t.Ok(this.value):t.Error(this.value)},tap:function(t){return t(this),this},tapOk:function(t){return"Ok"===this.tag&&t(this.value),this},tapError:function(t){return"Error"===this.tag&&t(this.value),this},toOption:function(){return"Ok"===this.tag?s(this.value):h()},isOk:function(){return"Ok"===this.tag},isError:function(){return"Error"===this.tag},__boxed_type__:"Result"},g=t({},p,{get:function(){return this.value}}),m=t({},p,{getError:function(){return this.value}}),O=function(t){var n=Object.create(g);return n.tag="Ok",n.value=t,n},_=function(t){var n=Object.create(m);return n.tag="Error",n.value=t,n},k={Ok:O,Error:_,isResult:function(t){return null!=t&&(Object.prototype.isPrototypeOf.call(g,t)||Object.prototype.isPrototypeOf.call(m,t))},fromExecution:function(t){try{return k.Ok(t())}catch(t){return k.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,r){try{var e=Promise.resolve(t).then(function(t){return k.Ok(t)})}catch(t){return r(t)}return e&&e.then?e.then(void 0,r):e}(0,function(t){return k.Error(t)}))}catch(t){return Promise.reject(t)}},fromOption:function(t,n){return t.toResult(n)},all:function(t){for(var n,r=t.length,e=k.Ok([]),u=0,o=function(){if(u>=r)return{v:e};var n=t[u];null!=n&&(e=e.flatMap(function(t){return n.map(function(n){return t.push(n),t})})),u++};;)if(n=o())return n.v},allFromDict:function(t){var n=u(t);return k.all(o(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||r(t.value,n.value))},P:{Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}}},d=function(t,n){return t===n?0:t>n?1:-1},y={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,findMap:function(t,n){for(var r=-1;++r<t.length;){var e=n(t[r]);if(e.isSome())return e}return v.None()},filterMap:function(t,n){var r=[];return t.forEach(function(t){var e=n(t);e.isSome()&&r.push(e.get())}),r},find:function(t,n){for(var r=-1;++r<t.length;){var e=t[r];if(n(e))return v.Some(e)}return v.None()},findIndex:function(t,n){for(var r=-1;++r<t.length;)if(n(t[r]))return v.Some(r);return v.None()},binarySearchBy:function(t,n,r){if(void 0===r&&(r=d),0===t.length)return-1;for(var e=0,u=t.length-1;;){var o=e+(u-e)/2|0;if(o===e||o===u)return u;var i=r(n,t[o]);if(0===i)return o;i>0?e=o:i<0&&(u=o)}},unzip:function(t){for(var n=t.length,r=Array(n),e=Array(n),u=-1;++u<n;){var o=t[u];void 0!==o&&(r[u]=o[0],e[u]=o[1])}return[r,e]},zip:a},E={map:function(t){return"Done"===this.tag?D(t(this.value)):this},flatMap:function(t){return"Done"===this.tag?t(this.value):this},mapOkToResult:function(t){return this.map(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return n}})})},mapErrorToResult:function(t){return this.map(function(n){return n.match({Error:function(n){return t(n)},Ok:function(){return n}})})},mapOk:function(t){return this.map(function(n){return n.match({Ok:function(n){return k.Ok(t(n))},Error:function(){return n}})})},mapError:function(t){return this.map(function(n){return n.match({Ok:function(){return n},Error:function(n){return k.Error(t(n))}})})},flatMapOk:function(t){return this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return D(n)}})})},flatMapError:function(t){return this.flatMap(function(n){return n.match({Ok:function(){return D(n)},Error:function(n){return t(n)}})})},getWithDefault:function(t){return"Done"===this.tag?this.value:t},match:function(t){return"Done"===this.tag?t.Done(this.value):"Loading"===this.tag?t.Loading():t.NotAsked()},tap:function(t){return t(this),this},toOption:function(){return"Done"===this.tag?v.Some(this.value):v.None()},isDone:function(){return"Done"===this.tag},isLoading:function(){return"Loading"===this.tag},isNotAsked:function(){return"NotAsked"===this.tag},__boxed_type__:"AsyncData"},b=t({},E,{get:function(){return this.value}}),D=function(t){var n=Object.create(b);return n.tag="Done",n.value=t,n},S=((r=Object.create(E)).tag="Loading",r),N=function(){var t=Object.create(E);return t.tag="NotAsked",t}(),j={Done:D,Loading:function(){return S},NotAsked:function(){return N},all:function(t){for(var n,r=t.length,e=j.Done([]),u=0,o=function(){if(u>=r)return{v:e};var n=t[u];null!=n&&(e=e.flatMap(function(t){return n.map(function(n){return t.push(n),t})})),u++};;)if(n=o())return n.v},allFromDict:function(t){var n=u(t);return j.all(o(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return"Done"===t.tag&&"Done"===n.tag?r(t.value,n.value):t.tag===n.tag},isAsyncData:function(t){return null!=t&&(Object.prototype.isPrototypeOf.call(b,t)||Object.prototype.isPrototypeOf.call(E,t))},P:{Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}}},P=/*#__PURE__*/function(){function t(t){var n=this;this._state=void 0,this._state={tag:"Pending"},this._state.cancel=t(function(t){if("Pending"===n._state.tag){var r=n._state.resolveCallbacks;n._state={tag:"Resolved",value:t},null==r||r.forEach(function(n){return n(t)})}})}t.fromPromise=function(n){return t.make(function(t){n.then(function(n){return t(k.Ok(n))},function(n){return t(k.Error(n))})})};var n=t.prototype;return n.onResolve=function(t){var n;"Pending"===this._state.tag?(this._state.resolveCallbacks=null!=(n=this._state.resolveCallbacks)?n:[],this._state.resolveCallbacks.push(t)):"Resolved"===this._state.tag&&t(this._state.value)},n.onCancel=function(t){var n;"Pending"===this._state.tag?(this._state.cancelCallbacks=null!=(n=this._state.cancelCallbacks)?n:[],this._state.cancelCallbacks.push(t)):"Cancelled"===this._state.tag&&t()},n.cancel=function(){if("Pending"===this._state.tag){var t=this._state,n=t.cancel,r=t.cancelCallbacks;this._state={tag:"Cancelled"},null==n||n(),null==r||r.forEach(function(t){return t()})}},n.map=function(n,r){var e=this;void 0===r&&(r=!1);var u=t.make(function(t){if(e.onResolve(function(r){t(n(r))}),r)return function(){e.cancel()}});return this.onCancel(function(){u.cancel()}),u},n.then=function(t){return this.onResolve(t),this},n.flatMap=function(n,r){var e=this;void 0===r&&(r=!1);var u=t.make(function(t){if(e.onResolve(function(r){var e=n(r);e.onResolve(t),e.onCancel(function(){return u.cancel()})}),r)return function(){e.cancel()}});return this.onCancel(function(){u.cancel()}),u},n.tap=function(t){return this.onResolve(t),this},n.tapOk=function(t){return this.onResolve(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.onResolve(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.mapOkToResult=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return n}})},n)},n.mapErrorToResult=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Error:function(n){return t(n)},Ok:function(){return n}})},n)},n.mapOk=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return k.Ok(t(n))},Error:function(){return n}})},n)},n.mapError=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(){return n},Error:function(n){return k.Error(t(n))}})},n)},n.flatMapOk=function(n,r){return void 0===r&&(r=!1),this.flatMap(function(r){return r.match({Ok:function(t){return n(t)},Error:function(){return t.value(r)}})},r)},n.flatMapError=function(n,r){return void 0===r&&(r=!1),this.flatMap(function(r){return r.match({Ok:function(){return t.value(r)},Error:function(t){return n(t)}})},r)},n.toPromise=function(){var t=this;return new Promise(function(n){t.onResolve(n)})},n.resultToPromise=function(){var t=this;return new Promise(function(n,r){t.onResolve(function(t){t.match({Ok:n,Error:r})})})},t}();e=P,P.make=function(t){return new e(t)},P.isFuture=function(t){return null!=t&&Object.prototype.isPrototypeOf.call(R,t)},P.value=function(t){var n=Object.create(R);return n._state={tag:"Resolved",value:t},n},P.all=function(t,n){void 0===n&&(n=!1);for(var r,u=t.length,o=e.value([]),i=0,a=function(){if(i>=u)return{v:o};var r=t[i];null!=r&&(o=o.flatMap(function(t){return r.map(function(n){return t.push(n),t},n)},n)),i++};;)if(r=a())return r.v},P.allFromDict=function(t){var n=u(t);return e.all(o(t)).map(function(t){return Object.fromEntries(a(n,t))})};var R=Object.create(null,Object.getOwnPropertyDescriptors(P.prototype)),A={make:function(){var t=void 0;return[P.make(function(n){t=n}),t]}},x=Symbol("NOT_COMPUTED"),M={__proto__:null,encode:function(t,n){return JSON.stringify(t,function(t,n){if(null!=n)return"Option"===n.__boxed_type__?{__boxed_type__:"Option",tag:n.tag,value:n.value}:"Result"===n.__boxed_type__?{__boxed_type__:"Result",tag:n.tag,value:n.value}:"AsyncData"===n.__boxed_type__?{__boxed_type__:"AsyncData",tag:n.tag,value:n.value}:n},n)},decode:function(t){return JSON.parse(t,function(t,n){return null==n?n:"Option"===n.__boxed_type__?"Some"===n.tag?v.Some(n.value):v.None():"Result"===n.__boxed_type__?"Ok"===n.tag?k.Ok(n.value):k.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?j.NotAsked():"Loading"===n.tag?j.Loading():j.Done(n.value):n})}};exports.Array=y,exports.AsyncData=j,exports.Deferred=A,exports.Dict=i,exports.Future=P,exports.Lazy=function(t){var n={contents:x};return{get:function(){return n.contents===x&&(n.contents=t()),n.contents}}},exports.Option=v,exports.Result=k,exports.Serializer=M; | ||
var t=function(t){return Object.keys(t)},n=function(t){return Object.values(t)},r={__proto__:null,entries:function(t){return Object.entries(t)},keys:t,values:n},e=function(t,n){for(var r=Math.min(t.length,n.length),e=Array(r),o=-1;++o<r;)e[o]=[t[o],n[o]];return e},o=/*#__PURE__*/function(){function t(){}var n=t.prototype;return n.map=function(t){return this===a?this:c.Some(t(this.value))},n.flatMap=function(t){return this===a?this:t(this.value)},n.filter=function(t){return this===a||t(this.value)?this:a},n.get=function(){return this.value},n.getWithDefault=function(t){return this===a?t:this.value},n.match=function(t){return this===a?t.None():t.Some(this.value)},n.tap=function(t){return t(this),this},n.toUndefined=function(){if(this!==a)return this.value},n.toNull=function(){return this===a?null:this.value},n.toResult=function(t){return this.match({Some:function(t){return l.Ok(t)},None:function(){return l.Error(t)}})},n.isSome=function(){return this!==a},n.isNone=function(){return this===a},t}();o.P={Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}},o.Some=function(t){var n=Object.create(i);return n.tag="Some",n.value=t,n},o.None=function(){return a},o.isOption=function(t){return null!=t&&"Option"===t.__boxed_type__},o.fromNullable=function(t){return null==t?a:c.Some(t)},o.fromNull=function(t){return null===t?a:c.Some(t)},o.fromUndefined=function(t){return void 0===t?a:c.Some(t)},o.all=function(t){for(var n,r=t.length,e=c.Some([]),o=0,u=function(){if(o>=r)return{v:e};var n=t[o];null!=n&&(e=e.flatMap(function(t){return n.map(function(n){return t.push(n),t})})),o++};;)if(n=u())return n.v},o.allFromDict=function(r){var o=t(r);return c.all(n(r)).map(function(t){return Object.fromEntries(e(o,t))})},o.equals=function(t,n,r){return t.isSome()&&n.isSome()?r(t.get(),n.get()):t.tag===n.tag},o.prototype.__boxed_type__="Option";var u,i=Object.create(null,Object.getOwnPropertyDescriptors(o.prototype)),a=((u=Object.create(i)).tag="None",u),c=o,f=/*#__PURE__*/function(){function t(){}var n=t.prototype;return n.map=function(t){return"Ok"===this.tag?l.Ok(t(this.value)):this},n.mapError=function(t){return"Ok"===this.tag?this:l.Error(t(this.error))},n.flatMap=function(t){return"Ok"===this.tag?t(this.value):this},n.flatMapError=function(t){return"Ok"===this.tag?this:t(this.error)},n.get=function(){return this.value},n.getError=function(){return this.error},n.getWithDefault=function(t){return"Ok"===this.tag?this.value:t},n.match=function(t){return"Ok"===this.tag?t.Ok(this.value):t.Error(this.error)},n.tap=function(t){return t(this),this},n.tapOk=function(t){return"Ok"===this.tag&&t(this.value),this},n.tapError=function(t){return"Error"===this.tag&&t(this.error),this},n.toOption=function(){return"Ok"===this.tag?c.Some(this.value):a},n.isOk=function(){return"Ok"===this.tag},n.isError=function(){return"Error"===this.tag},t}();f.P={Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",error:t}}},f.Ok=function(t){var n=Object.create(s);return n.tag="Ok",n.value=t,n},f.Error=function(t){var n=Object.create(s);return n.tag="Error",n.error=t,n},f.isResult=function(t){return null!=t&&"Result"===t.__boxed_type__},f.fromExecution=function(t){try{return l.Ok(t())}catch(t){return l.Error(t)}},f.fromPromise=function(t){try{return Promise.resolve(function(n,r){try{var e=Promise.resolve(t).then(function(t){return l.Ok(t)})}catch(t){return r(t)}return e&&e.then?e.then(void 0,r):e}(0,function(t){return l.Error(t)}))}catch(t){return Promise.reject(t)}},f.fromOption=function(t,n){return t.toResult(n)},f.all=function(t){for(var n,r=t.length,e=l.Ok([]),o=0,u=function(){if(o>=r)return{v:e};var n=t[o];null!=n&&(e=e.flatMap(function(t){return n.map(function(n){return t.push(n),t})})),o++};;)if(n=u())return n.v},f.allFromDict=function(r){var o=t(r);return l.all(n(r)).map(function(t){return Object.fromEntries(e(o,t))})},f.equals=function(t,n,r){return t.tag===n.tag&&(!(!t.isError()||!n.isError())||!(!t.isOk()||!n.isOk())&&r(t.get(),n.get()))},f.prototype.__boxed_type__="Result";var s=Object.create(null,Object.getOwnPropertyDescriptors(f.prototype)),l=f,h=function(t,n){return t===n?0:t>n?1:-1},v={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,findMap:function(t,n){for(var r=-1;++r<t.length;){var e=n(t[r]);if(e.isSome())return e}return c.None()},filterMap:function(t,n){var r=[];return t.forEach(function(t){var e=n(t);e.isSome()&&r.push(e.get())}),r},find:function(t,n){for(var r=-1;++r<t.length;){var e=t[r];if(n(e))return c.Some(e)}return c.None()},findIndex:function(t,n){for(var r=-1;++r<t.length;)if(n(t[r]))return c.Some(r);return c.None()},binarySearchBy:function(t,n,r){if(void 0===r&&(r=h),0===t.length)return-1;for(var e=0,o=t.length-1;;){var u=e+(o-e)/2|0;if(u===e||u===o)return o;var i=r(n,t[u]);if(0===i)return u;i>0?e=u:i<0&&(o=u)}},unzip:function(t){for(var n=t.length,r=Array(n),e=Array(n),o=-1;++o<n;){var u=t[o];void 0!==u&&(r[o]=u[0],e[o]=u[1])}return[r,e]},zip:e},p=/*#__PURE__*/function(){function t(){}var n=t.prototype;return n.map=function(t){return this===O||this===g?this:k.Done(t(this.value))},n.flatMap=function(t){return this===O||this===g?this:t(this.value)},n.mapOkToResult=function(t){return this.map(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return n}})})},n.mapErrorToResult=function(t){return this.map(function(n){return n.match({Error:function(n){return t(n)},Ok:function(){return n}})})},n.mapOk=function(t){return this.map(function(n){return n.match({Ok:function(n){return l.Ok(t(n))},Error:function(){return n}})})},n.mapError=function(t){return this.map(function(n){return n.match({Ok:function(){return n},Error:function(n){return l.Error(t(n))}})})},n.flatMapOk=function(t){return this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return k.Done(n)}})})},n.flatMapError=function(t){return this.flatMap(function(n){return n.match({Ok:function(){return k.Done(n)},Error:function(n){return t(n)}})})},n.get=function(){return this.value},n.getWithDefault=function(t){return this===O||this===g?t:this.value},n.match=function(t){return this===O?t.NotAsked():this===g?t.Loading():t.Done(this.value)},n.tap=function(t){return t(this),this},n.toOption=function(){return this===O||this===g?c.None():c.Some(this.value)},n.isDone=function(){return this!==O&&this!==g},n.isLoading=function(){return this===g},n.isNotAsked=function(){return this===O},t}();p.P={Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}},p.Done=function(t){var n=Object.create(m);return n.tag="Done",n.value=t,n},p.Loading=function(){return g},p.NotAsked=function(){return O},p.all=function(t){for(var n,r=t.length,e=k.Done([]),o=0,u=function(){if(o>=r)return{v:e};var n=t[o];null!=n&&(e=e.flatMap(function(t){return n.map(function(n){return t.push(n),t})})),o++};;)if(n=u())return n.v},p.allFromDict=function(r){var o=t(r);return k.all(n(r)).map(function(t){return Object.fromEntries(e(o,t))})},p.equals=function(t,n,r){return"Done"===t.tag&&"Done"===n.tag?r(t.value,n.value):t.tag===n.tag},p.isAsyncData=function(t){return null!=t&&"AsyncData"===t.__boxed_type__},p.prototype.__boxed_type__="AsyncData";var _,m=Object.create(null,Object.getOwnPropertyDescriptors(p.prototype)),g=((_=Object.create(m)).tag="Loading",_),O=function(){var t=Object.create(m);return t.tag="NotAsked",t}(),k=p,d=/*#__PURE__*/function(){function t(){this._state=void 0,this._state={tag:"Pending"}}t.fromPromise=function(t){return E.make(function(n){t.then(function(t){return n(l.Ok(t))},function(t){return n(l.Error(t))})})};var n=t.prototype;return n.onResolve=function(t){var n;"Pending"===this._state.tag?(this._state.resolveCallbacks=null!=(n=this._state.resolveCallbacks)?n:[],this._state.resolveCallbacks.push(t)):"Resolved"===this._state.tag&&t(this._state.value)},n.onCancel=function(t){var n;"Pending"===this._state.tag?(this._state.cancelCallbacks=null!=(n=this._state.cancelCallbacks)?n:[],this._state.cancelCallbacks.push(t)):"Cancelled"===this._state.tag&&t()},n.cancel=function(){if("Pending"===this._state.tag){var t=this._state,n=t.cancel,r=t.cancelCallbacks;this._state={tag:"Cancelled"},null!=n&&n(),null==r||r.forEach(function(t){return t()})}},n.map=function(t,n){var r=this;void 0===n&&(n=!1);var e=E.make(function(e){if(r.onResolve(function(n){e(t(n))}),n)return function(){r.cancel()}});return this.onCancel(function(){e.cancel()}),e},n.then=function(t){return this.onResolve(t),this},n.flatMap=function(t,n){var r=this;void 0===n&&(n=!1);var e=E.make(function(o){if(r.onResolve(function(n){var r=t(n);r.onResolve(o),r.onCancel(function(){return e.cancel()})}),n)return function(){r.cancel()}});return this.onCancel(function(){e.cancel()}),e},n.tap=function(t){return this.onResolve(t),this},n.tapOk=function(t){return this.onResolve(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.onResolve(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.mapOkToResult=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return n}})},n)},n.mapErrorToResult=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Error:function(n){return t(n)},Ok:function(){return n}})},n)},n.mapOk=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return l.Ok(t(n))},Error:function(){return n}})},n)},n.mapError=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(){return n},Error:function(n){return l.Error(t(n))}})},n)},n.flatMapOk=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return E.value(n)}})},n)},n.flatMapError=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(){return E.value(n)},Error:function(n){return t(n)}})},n)},n.toPromise=function(){var t=this;return new Promise(function(n){t.onResolve(n)})},n.resultToPromise=function(){var t=this;return new Promise(function(n,r){t.onResolve(function(t){t.match({Ok:n,Error:r})})})},t}();d.make=function(t){var n=Object.create(y);return n._state={tag:"Pending"},n._state.cancel=t(function(t){if("Pending"===n._state.tag){var r=n._state.resolveCallbacks;n._state={tag:"Resolved",value:t},null==r||r.forEach(function(n){return n(t)})}}),n},d.isFuture=function(t){return null!=t&&Object.prototype.isPrototypeOf.call(y,t)},d.value=function(t){var n=Object.create(y);return n._state={tag:"Resolved",value:t},n},d.all=function(t,n){void 0===n&&(n=!1);for(var r,e=t.length,o=E.value([]),u=0,i=function(){if(u>=e)return{v:o};var r=t[u];null!=r&&(o=o.flatMap(function(t){return r.map(function(n){return t.push(n),t},n)},n)),u++};;)if(r=i())return r.v},d.allFromDict=function(r){var o=t(r);return E.all(n(r)).map(function(t){return Object.fromEntries(e(o,t))})};var y=Object.create(null,Object.getOwnPropertyDescriptors(d.prototype)),E=d,b={make:function(){var t=void 0;return[E.make(function(n){t=n}),t]}},D=Symbol("NOT_COMPUTED"),S={__proto__:null,encode:function(t,n){return JSON.stringify(t,function(t,n){if(null!=n)return"Option"===n.__boxed_type__?{__boxed_type__:"Option",tag:n.tag,value:n.value}:"Result"===n.__boxed_type__?{__boxed_type__:"Result",tag:n.tag,value:n.value,error:n.error}:"AsyncData"===n.__boxed_type__?{__boxed_type__:"AsyncData",tag:n.tag,value:n.value}:n},n)},decode:function(t){return JSON.parse(t,function(t,n){return null==n?n:"Option"===n.__boxed_type__?"Some"===n.tag?c.Some(n.value):c.None():"Result"===n.__boxed_type__?"Ok"===n.tag?l.Ok(n.value):l.Error(n.error):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?k.NotAsked():"Loading"===n.tag?k.Loading():k.Done(n.value):n})}};exports.Array=v,exports.AsyncData=k,exports.Deferred=b,exports.Dict=r,exports.Future=E,exports.Lazy=function(t){var n={contents:D};return{get:function(){return n.contents===D&&(n.contents=t()),n.contents}}},exports.Option=c,exports.Result=l,exports.Serializer=S; | ||
//# sourceMappingURL=Boxed.js.map |
import { Result } from "./OptionResult"; | ||
import { LooseRecord } from "./types"; | ||
export declare class Future<A> { | ||
export declare class __Future<A> { | ||
/** | ||
@@ -16,3 +16,3 @@ * Creates a new future from its initializer function (like `new Promise(...)`) | ||
*/ | ||
static fromPromise<A>(promise: Promise<A>): Future<Result<A, unknown>>; | ||
static fromPromise<A, E = unknown>(promise: Promise<A>): Future<Result<A, E>>; | ||
/** | ||
@@ -27,3 +27,3 @@ * Turns an array of futures into a future of array | ||
private _state; | ||
protected constructor(init: (resolver: (value: A) => void) => (() => void) | void); | ||
protected constructor(); | ||
/** | ||
@@ -117,1 +117,3 @@ * Runs the callback with the future value when resolved | ||
} | ||
export declare const Future: typeof __Future; | ||
export type Future<A> = __Future<A>; |
@@ -1,4 +0,37 @@ | ||
import { LooseRecord, Remap } from "./types"; | ||
interface IOption<A> { | ||
import { LooseRecord } from "./types"; | ||
declare class __Option<A> { | ||
static P: { | ||
Some: <const A_1>(value: A_1) => { | ||
readonly tag: "Some"; | ||
readonly value: A_1; | ||
}; | ||
None: { | ||
readonly tag: "None"; | ||
}; | ||
}; | ||
static Some: <A_1 = never>(value: A_1) => Option<A_1>; | ||
static None: <A_1 = never>() => Option<A_1>; | ||
static isOption: (value: unknown) => value is Option<unknown>; | ||
/** | ||
* Create an Option from a nullable value | ||
*/ | ||
static fromNullable: <A_1>(nullable: A_1 | null | undefined) => Option<A_1>; | ||
/** | ||
* Create an Option from a value | null | ||
*/ | ||
static fromNull: <A_1>(nullable: A_1 | null) => Option<A_1>; | ||
/** | ||
* Create an Option from a undefined | value | ||
*/ | ||
static fromUndefined: <A_1>(nullable: A_1 | undefined) => Option<A_1>; | ||
/** | ||
* Turns an array of options into an option of array | ||
*/ | ||
static all: <Options extends [] | Option<any>[]>(options: Options) => Option<{ [K in keyof Options]: Options[K] extends Option<infer T> ? T : never; }>; | ||
/** | ||
* Turns an dict of options into a options of dict | ||
*/ | ||
static allFromDict: <Dict extends LooseRecord<Option<any>>>(dict: Dict) => Option<{ [K in keyof Dict]: Dict[K] extends Option<infer T> ? T : never; }>; | ||
static equals: <A_1>(a: Option<A_1>, b: Option<A_1>, equals: (a: A_1, b: A_1) => boolean) => boolean; | ||
/** | ||
* Returns the Option containing the value from the callback | ||
@@ -23,2 +56,6 @@ * | ||
/** | ||
* Returns the value. Use within `if (Option.isSome()) { ... }` | ||
*/ | ||
get(this: Some<A>): A; | ||
/** | ||
* Return the value if present, and the fallback otherwise | ||
@@ -61,59 +98,47 @@ * | ||
} | ||
type Some<A> = Remap<IOption<A>> & { | ||
interface Some<A> extends __Option<A> { | ||
tag: "Some"; | ||
value: A; | ||
/** | ||
* Returns the value. Use within `if (option.isSome()) { ... }` | ||
*/ | ||
get(this: Some<A>): A; | ||
}; | ||
type None<A> = Remap<IOption<A>> & { | ||
} | ||
interface None<A> extends __Option<A> { | ||
tag: "None"; | ||
}; | ||
} | ||
export declare const Option: typeof __Option; | ||
export type Option<A> = Some<A> | None<A>; | ||
declare const Some: <A = never>(value: A) => Option<A>; | ||
declare const None: <A = never>() => Option<A>; | ||
export declare const Option: { | ||
declare class __Result<A, E> { | ||
static P: { | ||
Ok: <const A_1>(value: A_1) => { | ||
readonly tag: "Ok"; | ||
readonly value: A_1; | ||
}; | ||
Error: <const E_1>(error: E_1) => { | ||
readonly tag: "Error"; | ||
readonly error: E_1; | ||
}; | ||
}; | ||
static Ok: <A_1 = never, E_1 = never>(value: A_1) => Result<A_1, E_1>; | ||
static Error: <A_1 = never, E_1 = never>(error: E_1) => Result<A_1, E_1>; | ||
static isResult: (value: unknown) => value is Result<unknown, unknown>; | ||
/** | ||
* Create an Option.Some value | ||
* Runs the function and resolves a result of its return value, or to an error if thrown | ||
*/ | ||
Some: <A = never>(value: A) => Option<A>; | ||
static fromExecution: <A_1, E_1 = unknown>(func: () => A_1) => Result<A_1, E_1>; | ||
/** | ||
* Create an Option.None value | ||
* Takes the promise and resolves a result of its value, or to an error if rejected | ||
*/ | ||
None: <A_1 = never>() => Option<A_1>; | ||
isOption: (value: unknown) => value is Option<unknown>; | ||
static fromPromise: <A_1, E_1 = unknown>(promise: Promise<A_1>) => Promise<Result<A_1, E_1>>; | ||
/** | ||
* Create an Option from a nullable value | ||
* Takes the option and turns it into Ok(value) is Some, or Error(valueWhenNone) | ||
*/ | ||
fromNullable<A_2>(nullable: A_2 | null | undefined): Option<A_2>; | ||
static fromOption: <A_1, E_1>(option: Option<A_1>, valueWhenNone: E_1) => Result<A_1, E_1>; | ||
/** | ||
* Create an Option from a value | null | ||
* Turns an array of results into an result of array | ||
*/ | ||
fromNull<A_3>(nullable: A_3 | null): Option<A_3>; | ||
static all: <Results extends [] | Result<any, any>[]>(results: Results) => Result<{ [K in keyof Results]: Results[K] extends Result<infer T, any> ? T : never; }, { [K_1 in keyof Results]: Results[K_1] extends Result<any, infer T_1> ? T_1 : never; }[number]>; | ||
/** | ||
* Create an Option from a undefined | value | ||
* Turns an dict of results into a results of dict | ||
*/ | ||
fromUndefined<A_4>(nullable: A_4 | undefined): Option<A_4>; | ||
static allFromDict: <Dict extends LooseRecord<Result<any, any>>>(dict: Dict) => Result<{ [K in keyof Dict]: Dict[K] extends Result<infer T, any> ? T : never; }, { [K_1 in keyof Dict]: Dict[K_1] extends Result<any, infer T_1> ? T_1 : never; }[keyof Dict]>; | ||
static equals: <A_1, E_1>(a: Result<A_1, E_1>, b: Result<A_1, E_1>, equals: (a: A_1, b: A_1) => boolean) => boolean; | ||
/** | ||
* Turns an array of options into an option of array | ||
*/ | ||
all<Options extends [] | Option<any>[]>(options: Options): Option<{ [K in keyof Options]: Options[K] extends Option<infer T> ? T : never; }>; | ||
/** | ||
* Turns an dict of options into a options of dict | ||
*/ | ||
allFromDict<Dict extends LooseRecord<Option<any>>>(dict: Dict): Option<{ [K_1 in keyof Dict]: Dict[K_1] extends Option<infer T_1> ? T_1 : never; }>; | ||
equals<A_5>(a: Option<A_5>, b: Option<A_5>, equals: (a: A_5, b: A_5) => boolean): boolean; | ||
P: { | ||
Some: <const A_6>(value: A_6) => { | ||
readonly tag: "Some"; | ||
readonly value: A_6; | ||
}; | ||
None: { | ||
readonly tag: "None"; | ||
}; | ||
}; | ||
}; | ||
interface IResult<A, E> { | ||
/** | ||
* Returns the Result containing the value from the callback | ||
@@ -143,2 +168,10 @@ * | ||
/** | ||
* Returns the value. Use within `if (result.isOk()) { ... }` | ||
*/ | ||
get(this: Ok<A, E>): A; | ||
/** | ||
* Returns the error. Use within `if (result.isError()) { ... }` | ||
*/ | ||
getError(this: Error<A, E>): E; | ||
/** | ||
* Return the value if present, and the fallback otherwise | ||
@@ -183,63 +216,12 @@ * | ||
} | ||
type Ok<A, E> = Remap<IResult<A, E>> & { | ||
interface Ok<A, E> extends __Result<A, E> { | ||
tag: "Ok"; | ||
value: A; | ||
/** | ||
* Returns the ok value. Use within `if (result.isOk()) { ... }` | ||
*/ | ||
get(this: Ok<A, E>): A; | ||
}; | ||
type Error<A, E> = Remap<IResult<A, E>> & { | ||
} | ||
interface Error<A, E> extends __Result<A, E> { | ||
tag: "Error"; | ||
value: E; | ||
/** | ||
* Returns the error value. Use within `if (result.isError()) { ... }` | ||
*/ | ||
getError(this: Error<A, E>): E; | ||
}; | ||
error: E; | ||
} | ||
export declare const Result: typeof __Result; | ||
export type Result<A, E> = Ok<A, E> | Error<A, E>; | ||
declare const Ok: <A = never, E = never>(value: A) => Result<A, E>; | ||
declare const Error: <A = never, E = never>(value: E) => Result<A, E>; | ||
export declare const Result: { | ||
/** | ||
* Create an Result.Ok value | ||
*/ | ||
Ok: <A = never, E = never>(value: A) => Result<A, E>; | ||
/** | ||
* Create an Result.Error value | ||
*/ | ||
Error: <A_1 = never, E_1 = never>(value: E_1) => Result<A_1, E_1>; | ||
isResult: (value: unknown) => value is Result<unknown, unknown>; | ||
/** | ||
* Runs the function and resolves a result of its return value, or to an error if thrown | ||
*/ | ||
fromExecution<A_2, E_2 = unknown>(func: () => A_2): Result<A_2, E_2>; | ||
/** | ||
* Takes the promise and resolves a result of its value, or to an error if rejected | ||
*/ | ||
fromPromise<A_3, E_3 = unknown>(promise: Promise<A_3>): Promise<Result<A_3, E_3>>; | ||
/** | ||
* Takes the option and turns it into Ok(value) is Some, or Error(valueWhenNone) | ||
*/ | ||
fromOption<A_4, E_4>(option: Option<A_4>, valueWhenNone: E_4): Result<A_4, E_4>; | ||
/** | ||
* Turns an array of results into an result of array | ||
*/ | ||
all<Results extends [] | Result<any, any>[]>(results: Results): Result<{ [K in keyof Results]: Results[K] extends Result<infer T, any> ? T : never; }, { [K_1 in keyof Results]: Results[K_1] extends Result<any, infer T_1> ? T_1 : never; }[number]>; | ||
/** | ||
* Turns an dict of results into a results of dict | ||
*/ | ||
allFromDict<Dict extends LooseRecord<Result<any, any>>>(dict: Dict): Result<{ [K_2 in keyof Dict]: Dict[K_2] extends Result<infer T_2, any> ? T_2 : never; }, { [K_3 in keyof Dict]: Dict[K_3] extends Result<any, infer T_3> ? T_3 : never; }[keyof Dict]>; | ||
equals<A_5, E_5>(a: Result<A_5, E_5>, b: Result<A_5, E_5>, equals: (a: A_5, b: A_5) => boolean): boolean; | ||
P: { | ||
Ok: <const A_6>(value: A_6) => { | ||
readonly tag: "Ok"; | ||
readonly value: A_6; | ||
}; | ||
Error: <const E_6>(value: E_6) => { | ||
readonly tag: "Error"; | ||
readonly value: E_6; | ||
}; | ||
}; | ||
}; | ||
export {}; |
export type LooseRecord<T> = Record<PropertyKey, T>; | ||
export type Remap<T> = { | ||
[K in keyof T]: T[K]; | ||
}; |
@@ -0,1 +1,9 @@ | ||
# 2.1.0-beta | ||
Changes: | ||
- Improved overall performance (245d7b4) | ||
- Improved type structure for better compiler errors (245d7b4) | ||
- Allow `Future.fromPromise` to type error (d3afa85) | ||
# 2.0.1 | ||
@@ -2,0 +10,0 @@ |
{ | ||
"name": "@swan-io/boxed", | ||
"version": "2.0.1", | ||
"version": "2.1.0-beta", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Utility types for functional TypeScript", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163844
580
1