@swan-io/boxed
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -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=function(t){return Object.keys(t)},o=function(t){return Object.values(t)},u={__proto__:null,entries:function(t){return Object.entries(t)},keys:e,values:o},i=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},a={map:function(t){return"Some"===this.tag?f(t(this.value)):this},flatMap:function(t){return"Some"===this.tag?t(this.value):this},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 d.Ok(t)},None:function(){return d.Error(t)}})},isSome:function(){return"Some"===this.tag},isNone:function(){return"None"===this.tag},__boxed_type__:"Option"},c=t({},a,{get:function(){return this.value}}),f=function(t){var n=Object.create(c);return n.tag="Some",n.value=t,n},s=((n=Object.create(a)).tag="None",n),l=function(){return s},h={Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}},v={Some:f,None:l,isOption:function(t){return null!=t&&(Object.prototype.isPrototypeOf.call(a,t)||Object.prototype.isPrototypeOf.call(c,t))},fromNullable:function(t){return null==t?l():f(t)},fromNull:function(t){return null===t?l():f(t)},fromUndefined:function(t){return void 0===t?l():f(t)},all:function(t){for(var n=t.length,r=v.Some([]),e=0,o=function(){if(e>=n)return{v:r};var o=t[e];null!=o&&(r=r.flatMap(function(t){return o.map(function(n){return t.push(n),t})})),e++};;){var u=o();if("object"==typeof u)return u.v}},allFromDict:function(t){var n=e(t);return this.all(o(t)).map(function(t){return Object.fromEntries(i(n,t))})},equals:function(t,n,r){return"Some"===t.tag&&"Some"===n.tag?r(t.value,n.value):t.tag===n.tag},P:h,pattern:h},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?f(this.value):l()},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:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}},d={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 d.Ok(t())}catch(t){return d.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,r){try{var e=Promise.resolve(t).then(function(t){return d.Ok(t)})}catch(t){return r(t)}return e&&e.then?e.then(void 0,r):e}(0,function(t){return d.Error(t)}))}catch(t){return Promise.reject(t)}},fromOption:function(t,n){return t.toResult(n)},all:function(t){for(var n=t.length,r=d.Ok([]),e=0,o=function(){if(e>=n)return{v:r};var o=t[e];null!=o&&(r=r.flatMap(function(t){return o.map(function(n){return t.push(n),t})})),e++};;){var u=o();if("object"==typeof u)return u.v}},allFromDict:function(t){var n=e(t);return d.all(o(t)).map(function(t){return Object.fromEntries(i(n,t))})},equals:function(t,n,r){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||r(t.value,n.value))},P:k,pattern:k},y=function(t,n){return t===n?0:t>n?1:-1},b={__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=y),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:i},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 d.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 d.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"},j=t({},E,{get:function(){return this.value}}),D=function(t){var n=Object.create(j);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}(),P={Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}},R={Done:D,Loading:function(){return S},NotAsked:function(){return N},all:function(t){for(var n=t.length,r=R.Done([]),e=0,o=function(){if(e>=n)return{v:r};var o=t[e];null!=o&&(r=r.flatMap(function(t){return o.map(function(n){return t.push(n),t})})),e++};;){var u=o();if("object"==typeof u)return u.v}},allFromDict:function(t){var n=e(t);return R.all(o(t)).map(function(t){return Object.fromEntries(i(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(j,t)||Object.prototype.isPrototypeOf.call(E,t))},P:P,pattern:P};function A(t){var n=this;this._state={tag:"Pending"},this._state.cancel=t(function(t){var r;"Pending"===n._state.tag&&(null==(r=n._state.resolveCallbacks)||r.forEach(function(n){return n(t)}),n._state={tag:"Resolved",value:t})})}var x=/*#__PURE__*/function(){function t(t){this._state=void 0,this._state={tag:"Pending"}}t.fromPromise=function(n){return t.make(function(t){n.then(function(n){return t(d.Ok(n))},function(n){return t(d.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 o=t.make(function(t){if(e.onResolve(function(r){t(n(r))}),r)return function(){e.cancel()}});return this.onCancel(function(){o.cancel()}),o},n.then=function(t){return this.onResolve(t),this},n.flatMap=function(n,r){var e=this;void 0===r&&(r=!1);var o=t.make(function(t){if(e.onResolve(function(r){var e=n(r);e.onResolve(t),e.onCancel(function(){return o.cancel()})}),r)return function(){e.cancel()}});return this.onCancel(function(){o.cancel()}),o},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 d.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 d.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}();x.make=function(t){var n=Object.create(M);return A.call(n,t),n},x.isFuture=function(t){return null!=t&&Object.prototype.isPrototypeOf.call(M,t)},x.value=function(t){var n=Object.create(M);return n._state={tag:"Resolved",value:t},n},x.all=function(t,n){void 0===n&&(n=!1);for(var r=t.length,e=x.value([]),o=0,u=function(){if(o>=r)return{v:e};var u=t[o];null!=u&&(e=e.flatMap(function(t){return u.map(function(n){return t.push(n),t},n)},n)),o++};;){var i=u();if("object"==typeof i)return i.v}},x.allFromDict=function(t){var n=e(t);return x.all(o(t)).map(function(t){return Object.fromEntries(i(n,t))})};var M=Object.create(null,Object.getOwnPropertyDescriptors(x.prototype)),C={make:function(){var t=void 0;return[x.make(function(n){t=n}),t]}},L=Symbol("NOT_COMPUTED"),T={__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?d.Ok(n.value):d.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?R.NotAsked():"Loading"===n.tag?R.Loading():R.Done(n.value):n})}};exports.Array=b,exports.AsyncData=R,exports.Deferred=C,exports.Dict=u,exports.Future=x,exports.Lazy=function(t){var n={contents:L};return{get:function(){return n.contents===L&&(n.contents=t()),n.contents}}},exports.Option=v,exports.Result=d,exports.Serializer=T; | ||
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=function(t){return Object.keys(t)},o=function(t){return Object.values(t)},u={__proto__:null,entries:function(t){return Object.entries(t)},keys:e,values:o},i=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},a={map:function(t){return"Some"===this.tag?f(t(this.value)):this},flatMap:function(t){return"Some"===this.tag?t(this.value):this},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 d.Ok(t)},None:function(){return d.Error(t)}})},isSome:function(){return"Some"===this.tag},isNone:function(){return"None"===this.tag},__boxed_type__:"Option"},c=t({},a,{get:function(){return this.value}}),f=function(t){var n=Object.create(c);return n.tag="Some",n.value=t,n},s=((n=Object.create(a)).tag="None",n),l=function(){return s},h={Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}},v={Some:f,None:l,isOption:function(t){return null!=t&&(Object.prototype.isPrototypeOf.call(a,t)||Object.prototype.isPrototypeOf.call(c,t))},fromNullable:function(t){return null==t?l():f(t)},fromNull:function(t){return null===t?l():f(t)},fromUndefined:function(t){return void 0===t?l():f(t)},all:function(t){for(var n=t.length,r=v.Some([]),e=0,o=function(){if(e>=n)return{v:r};var o=t[e];null!=o&&(r=r.flatMap(function(t){return o.map(function(n){return t.push(n),t})})),e++};;){var u=o();if("object"==typeof u)return u.v}},allFromDict:function(t){var n=e(t);return this.all(o(t)).map(function(t){return Object.fromEntries(i(n,t))})},equals:function(t,n,r){return"Some"===t.tag&&"Some"===n.tag?r(t.value,n.value):t.tag===n.tag},P:h,pattern:h},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?f(this.value):l()},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:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}},d={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 d.Ok(t())}catch(t){return d.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,r){try{var e=Promise.resolve(t).then(function(t){return d.Ok(t)})}catch(t){return r(t)}return e&&e.then?e.then(void 0,r):e}(0,function(t){return d.Error(t)}))}catch(t){return Promise.reject(t)}},fromOption:function(t,n){return t.toResult(n)},all:function(t){for(var n=t.length,r=d.Ok([]),e=0,o=function(){if(e>=n)return{v:r};var o=t[e];null!=o&&(r=r.flatMap(function(t){return o.map(function(n){return t.push(n),t})})),e++};;){var u=o();if("object"==typeof u)return u.v}},allFromDict:function(t){var n=e(t);return d.all(o(t)).map(function(t){return Object.fromEntries(i(n,t))})},equals:function(t,n,r){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||r(t.value,n.value))},P:k,pattern:k},y=function(t,n){return t===n?0:t>n?1:-1},b={__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=y),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:i},E={map:function(t){return"Done"===this.tag?j(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 d.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 d.Error(t(n))}})})},flatMapOk:function(t){return this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return j(n)}})})},flatMapError:function(t){return this.flatMap(function(n){return n.match({Ok:function(){return j(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"},D=t({},E,{get:function(){return this.value}}),j=function(t){var n=Object.create(D);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}(),P={Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}},R={Done:j,Loading:function(){return S},NotAsked:function(){return N},all:function(t){for(var n=t.length,r=R.Done([]),e=0,o=function(){if(e>=n)return{v:r};var o=t[e];null!=o&&(r=r.flatMap(function(t){return o.map(function(n){return t.push(n),t})})),e++};;){var u=o();if("object"==typeof u)return u.v}},allFromDict:function(t){var n=e(t);return R.all(o(t)).map(function(t){return Object.fromEntries(i(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(D,t)||Object.prototype.isPrototypeOf.call(E,t))},P:P,pattern:P},A=/*#__PURE__*/function(){function t(t){var n=this;this._state=void 0,this._state={tag:"Pending"},this._state.cancel=t(function(t){var r;"Pending"===n._state.tag&&(null==(r=n._state.resolveCallbacks)||r.forEach(function(n){return n(t)}),n._state={tag:"Resolved",value:t})})}t.fromPromise=function(n){return t.make(function(t){n.then(function(n){return t(d.Ok(n))},function(n){return t(d.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 o=t.make(function(t){if(e.onResolve(function(r){t(n(r))}),r)return function(){e.cancel()}});return this.onCancel(function(){o.cancel()}),o},n.then=function(t){return this.onResolve(t),this},n.flatMap=function(n,r){var e=this;void 0===r&&(r=!1);var o=t.make(function(t){if(e.onResolve(function(r){var e=n(r);e.onResolve(t),e.onCancel(function(){return o.cancel()})}),r)return function(){e.cancel()}});return this.onCancel(function(){o.cancel()}),o},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 d.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 d.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}();A.make=function(t){return new A(t)},A.isFuture=function(t){return null!=t&&Object.prototype.isPrototypeOf.call(x,t)},A.value=function(t){var n=Object.create(x);return n._state={tag:"Resolved",value:t},n},A.all=function(t,n){void 0===n&&(n=!1);for(var r=t.length,e=A.value([]),o=0,u=function(){if(o>=r)return{v:e};var u=t[o];null!=u&&(e=e.flatMap(function(t){return u.map(function(n){return t.push(n),t},n)},n)),o++};;){var i=u();if("object"==typeof i)return i.v}},A.allFromDict=function(t){var n=e(t);return A.all(o(t)).map(function(t){return Object.fromEntries(i(n,t))})};var x=Object.create(null,Object.getOwnPropertyDescriptors(A.prototype)),M={make:function(){var t=void 0;return[A.make(function(n){t=n}),t]}},C=Symbol("NOT_COMPUTED"),L={__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?d.Ok(n.value):d.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?R.NotAsked():"Loading"===n.tag?R.Loading():R.Done(n.value):n})}};exports.Array=b,exports.AsyncData=R,exports.Deferred=M,exports.Dict=u,exports.Future=A,exports.Lazy=function(t){var n={contents:C};return{get:function(){return n.contents===C&&(n.contents=t()),n.contents}}},exports.Option=v,exports.Result=d,exports.Serializer=L; | ||
//# sourceMappingURL=Boxed.js.map |
@@ -25,14 +25,4 @@ import { Result } from "./OptionResult"; | ||
static allFromDict: <Dict extends LooseRecord<Future<any>>>(dict: Dict) => Future<{ [K in keyof Dict]: Dict[K] extends Future<infer T> ? T : never; }>; | ||
protected _state: { | ||
tag: "Pending"; | ||
resolveCallbacks?: Array<(value: A) => void>; | ||
cancel?: void | (() => void); | ||
cancelCallbacks?: Array<() => void>; | ||
} | { | ||
tag: "Cancelled"; | ||
} | { | ||
tag: "Resolved"; | ||
value: A; | ||
}; | ||
protected constructor(_init: (resolver: (value: A) => void) => (() => void) | void); | ||
private _state; | ||
protected constructor(init: (resolver: (value: A) => void) => (() => void) | void); | ||
/** | ||
@@ -39,0 +29,0 @@ * Runs the callback with the future value when resolved |
@@ -0,1 +1,7 @@ | ||
# 1.2.0 | ||
Fixes: | ||
- Make `_state` private in `Future`'s exposed signature (25f7bc9) | ||
# 1.1.0 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "@swan-io/boxed", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -51,5 +51,5 @@ "description": "Utility types for functional TypeScript", | ||
"ts-pattern": "^4.3.0", | ||
"typescript": "^5.0.4", | ||
"typescript": "^5.1.6", | ||
"vitest": "^0.31.0" | ||
} | ||
} |
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
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
171365
660