@swan-io/boxed
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -1,2 +0,2 @@ | ||
var t=function(t){return Object.keys(t)},n=function(t){return Object.values(t)},r=Object.prototype.hasOwnProperty,e={__proto__:null,fromEntries:Object.fromEntries,entries:function(t){return Object.entries(t)},keys:t,values:n,fromOptional:function(t){var n={};for(var e in t)if(r.call(t,e)){var o=t[e];if(void 0===o)continue;o.isSome()&&(n[e]=o.get())}return n}},o=new WeakMap,u="function"==typeof WeakRef?WeakRef:/*#__PURE__*/function(){function t(t){o.set(this,t)}return t.prototype.deref=function(){return o.get(this)},t}(),i=function(){var t=new Map,n="function"==typeof FinalizationRegistry?new FinalizationRegistry(function(n){t.delete(n)}):void 0;return{set:function(r,e){t.set(r,new u(e)),void 0!==n&&n.register(e,r)},get:function(n){var r=t.get(n);if(void 0!==r)return r.deref()}}},a=Symbol.for("__boxed_type__"),c=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},f=i(),s=/*#__PURE__*/function(){function t(){}t.fromPredicate=function(t,n){return n(t)?p.Some(t):v};var n=t.prototype;return n.map=function(t){return this===v?this:p.Some(t(this.value))},n.flatMap=function(t){return this===v?this:t(this.value)},n.filter=function(t){return this===v||t(this.value)?this:v},n.get=function(){return this.value},n.getWithDefault=function(t){return this===v?t:this.value},n.getOr=function(t){return this===v?t:this.value},n.match=function(t){return this===v?t.None():t.Some(this.value)},n.tap=function(t){return t(this),this},n.tapSome=function(t){return this===v||t(this.value),this},n.toUndefined=function(){if(this!==v)return this.value},n.toNull=function(){return this===v?null:this.value},n.toResult=function(t){return this.match({Some:function(t){return k.Ok(t)},None:function(){return k.Error(t)}})},n.isSome=function(){return this!==v},n.isNone=function(){return this===v},n.toJSON=function(){return this.match({None:function(){var t;return(t={})[a]="Option",t.tag="None",t},Some:function(t){var n;return(n={})[a]="Option",n.tag="Some",n.value=t,n}})},t}();s.P={Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}},s.Some=function(t){var n=f.get(t);if(void 0===n){var r=Object.create(h);return r.tag="Some",r.value=t,Object.freeze(r),f.set(t,r),r}return n},s.None=function(){return v},s.isOption=function(t){return null!=t&&"Option"===t.__boxed_type__},s.fromNullable=function(t){return null==t?v:p.Some(t)},s.fromNull=function(t){return null===t?v:p.Some(t)},s.fromUndefined=function(t){return void 0===t?v:p.Some(t)},s.all=function(t){for(var n,r=t.length,e=p.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},s.allFromDict=function(r){var e=t(r);return p.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},s.equals=function(t,n,r){return t.isSome()&&n.isSome()?r(t.get(),n.get()):t.tag===n.tag},s.fromJSON=function(t){return"None"===t.tag?p.None():p.Some(t.value)},s.prototype.__boxed_type__="Option";var l,h=s.prototype,v=((l=Object.create(h)).tag="None",Object.freeze(l),l),p=s,m=i(),g=i(),O=/*#__PURE__*/function(){function t(){}var n=t.prototype;return n.map=function(t){return"Ok"===this.tag?k.Ok(t(this.value)):this},n.mapError=function(t){return"Ok"===this.tag?this:k.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.getOr=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?p.Some(this.value):v},n.isOk=function(){return"Ok"===this.tag},n.isError=function(){return"Error"===this.tag},n.toJSON=function(){return this.match({Ok:function(t){var n;return(n={})[a]="Result",n.tag="Ok",n.value=t,n},Error:function(t){var n;return(n={})[a]="Result",n.tag="Error",n.error=t,n}})},t}();O.P={Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",error:t}}},O.Ok=function(t){var n=m.get(t);if(void 0===n){var r=Object.create(_);return r.tag="Ok",r.value=t,Object.freeze(r),m.set(t,r),r}return n},O.Error=function(t){var n=g.get(t);if(void 0===n){var r=Object.create(_);return r.tag="Error",r.error=t,Object.freeze(r),g.set(t,r),r}return n},O.isResult=function(t){return null!=t&&"Result"===t.__boxed_type__},O.fromExecution=function(t){try{return k.Ok(t())}catch(t){return k.Error(t)}},O.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)}},O.fromOption=function(t,n){return t.toResult(n)},O.all=function(t){for(var n,r=t.length,e=k.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},O.allFromDict=function(r){var e=t(r);return k.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},O.equals=function(t,n,r){return t.tag===n.tag&&(!(!t.isError()||!n.isError())||!(!t.isOk()||!n.isOk())&&r(t.get(),n.get()))},O.fromJSON=function(t){return"Ok"===t.tag?k.Ok(t.value):k.Error(t.error)},O.prototype.__boxed_type__="Result";var _=O.prototype,k=O,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 p.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 p.Some(e)}return p.None()},findIndex:function(t,n){for(var r=-1;++r<t.length;)if(n(t[r]))return p.Some(r);return p.None()},binarySearchBy:function(t,n,r){if(void 0===r&&(r=d),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:c},E=i(),b=/*#__PURE__*/function(){function t(){}var n=t.prototype;return n.map=function(t){return this===j||this===D?this:R.Done(t(this.value))},n.flatMap=function(t){return this===j||this===D?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 k.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 k.Error(t(n))}})})},n.flatMapOk=function(t){return this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return R.Done(n)}})})},n.flatMapError=function(t){return this.flatMap(function(n){return n.match({Ok:function(){return R.Done(n)},Error:function(n){return t(n)}})})},n.get=function(){return this.value},n.getWithDefault=function(t){return this===j||this===D?t:this.value},n.getOr=function(t){return this===j||this===D?t:this.value},n.match=function(t){return this===j?t.NotAsked():this===D?t.Loading():t.Done(this.value)},n.tap=function(t){return t(this),this},n.toOption=function(){return this===j||this===D?p.None():p.Some(this.value)},n.isDone=function(){return this!==j&&this!==D},n.isLoading=function(){return this===D},n.isNotAsked=function(){return this===j},n.toJSON=function(){return this.match({NotAsked:function(){var t;return(t={})[a]="AsyncData",t.tag="NotAsked",t},Loading:function(){var t;return(t={})[a]="AsyncData",t.tag="Loading",t},Done:function(t){var n;return(n={})[a]="AsyncData",n.tag="Done",n.value=t,n}})},t}();b.P={Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}},b.Done=function(t){var n=E.get(t);if(void 0===n){var r=Object.create(N);return r.tag="Done",r.value=t,Object.freeze(r),E.set(t,r),r}return n},b.Loading=function(){return D},b.NotAsked=function(){return j},b.all=function(t){for(var n,r=t.length,e=R.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},b.allFromDict=function(r){var e=t(r);return R.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},b.equals=function(t,n,r){return"Done"===t.tag&&"Done"===n.tag?r(t.value,n.value):t.tag===n.tag},b.isAsyncData=function(t){return null!=t&&"AsyncData"===t.__boxed_type__},b.fromJSON=function(t){return"NotAsked"===t.tag?R.NotAsked():"Loading"===t.tag?R.Loading():R.Done(t.value)},b.prototype.__boxed_type__="AsyncData";var S,N=b.prototype,D=((S=Object.create(N)).tag="Loading",Object.freeze(S),S),j=function(){var t=Object.create(N);return t.tag="NotAsked",Object.freeze(t),t}(),R=b,A=/*#__PURE__*/function(){function t(){this._state=void 0,this._state={tag:"Pending"}}t.fromPromise=function(t){return P.make(function(n){t.then(function(t){return n(k.Ok(t))},function(t){return n(k.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=P.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=P.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 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(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return P.value(n)}})},n)},n.flatMapError=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(){return P.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}();A.make=function(t){var n=Object.create(M);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},A.isFuture=function(t){return null!=t&&Object.prototype.isPrototypeOf.call(M,t)},A.value=function(t){var n=Object.create(M);return n._state={tag:"Resolved",value:t},n},A.all=function(t,n){void 0===n&&(n=!1);for(var r,e=t.length,o=P.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},A.allFromDict=function(r){var e=t(r);return P.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},A.wait=function(t){return P.make(function(n){var r=setTimeout(function(){return n()},t);return function(){return clearTimeout(r)}})},A.retry=function(t,n){var r=n.max;return function n(e){return t(e).flatMapError(function(t){return e+1<r?n(e+1):P.value(k.Error(t))})}(0)},A.concurrent=function(t,n){var r=n.concurrency;return P.make(function(n){var e=Array(t.length),o=r-1,u=0;t.slice(0,r).forEach(function r(i,a){return i().tap(function(i){if(e[a]=i,++u<t.length){var c=t[++o];null!=c&&r(c,o)}else n(e)})})})};var M=Object.create(null,Object.getOwnPropertyDescriptors(A.prototype)),P=A,x={make:function(){var t;return[P.make(function(n){t=n}),t]}},C=Symbol("NOT_COMPUTED");function z(){return z=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},z.apply(this,arguments)}var J={__proto__:null,encode:function(t,n){return JSON.stringify(t,function(t,n){return null==n?n:"string"==typeof n[a]?z({},n,{__boxed_type__:n[a]}):n},n)},decode:function(t){return JSON.parse(t,function(t,n){return null==n?n:"Option"===n.__boxed_type__?p.fromJSON(n):"Result"===n.__boxed_type__?k.fromJSON(n):"AsyncData"===n.__boxed_type__?R.fromJSON(n):n})}};exports.Array=y,exports.AsyncData=R,exports.Deferred=x,exports.Dict=e,exports.Future=P,exports.Lazy=function(t){var n={contents:C};return{get:function(){return n.contents===C&&(n.contents=t()),n.contents}}},exports.Option=p,exports.Result=k,exports.Serializer=J; | ||
var t=function(t){return Object.keys(t)},n=function(t){return Object.values(t)},r=Object.prototype.hasOwnProperty,e={__proto__:null,fromEntries:Object.fromEntries,entries:function(t){return Object.entries(t)},keys:t,values:n,fromOptional:function(t){var n={};for(var e in t)if(r.call(t,e)){var o=t[e];if(void 0===o)continue;o.isSome()&&(n[e]=o.get())}return n}},o=new WeakMap,u="function"==typeof WeakRef?WeakRef:/*#__PURE__*/function(){function t(t){o.set(this,t)}return t.prototype.deref=function(){return o.get(this)},t}(),i=function(){var t=new Map,n="function"==typeof FinalizationRegistry?new FinalizationRegistry(function(n){t.delete(n)}):void 0;return{set:function(r,e){t.set(r,new u(e)),void 0!==n&&n.register(e,r)},get:function(n){var r=t.get(n);if(void 0!==r)return r.deref()}}},a=Symbol.for("__boxed_type__"),c=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},f=i(),s=/*#__PURE__*/function(){function t(){}t.fromPredicate=function(t,n){return n(t)?p.Some(t):v};var n=t.prototype;return n.map=function(t){return this===v?this:p.Some(t(this.value))},n.flatMap=function(t){return this===v?this:t(this.value)},n.filter=function(t){return this===v||t(this.value)?this:v},n.get=function(){return this.value},n.getWithDefault=function(t){return this===v?t:this.value},n.getOr=function(t){return this===v?t:this.value},n.match=function(t){return this===v?t.None():t.Some(this.value)},n.tap=function(t){return t(this),this},n.tapSome=function(t){return this===v||t(this.value),this},n.toUndefined=function(){if(this!==v)return this.value},n.toNull=function(){return this===v?null:this.value},n.toResult=function(t){return this.match({Some:function(t){return k.Ok(t)},None:function(){return k.Error(t)}})},n.isSome=function(){return this!==v},n.isNone=function(){return this===v},n.toJSON=function(){return this.match({None:function(){var t;return(t={})[a]="Option",t.tag="None",t},Some:function(t){var n;return(n={})[a]="Option",n.tag="Some",n.value=t,n}})},t}();s.P={Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}},s.Some=function(t){var n=f.get(t);if(null==n){var r=Object.create(h);return r.tag="Some",r.value=t,Object.freeze(r),f.set(t,r),r}return n},s.None=function(){return v},s.isOption=function(t){return null!=t&&"Option"===t.__boxed_type__},s.fromNullable=function(t){return null==t?v:p.Some(t)},s.fromNull=function(t){return null===t?v:p.Some(t)},s.fromUndefined=function(t){return void 0===t?v:p.Some(t)},s.all=function(t){for(var n,r=t.length,e=p.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},s.allFromDict=function(r){var e=t(r);return p.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},s.equals=function(t,n,r){return t.isSome()&&n.isSome()?r(t.get(),n.get()):t.tag===n.tag},s.fromJSON=function(t){return"None"===t.tag?p.None():p.Some(t.value)},s.prototype.__boxed_type__="Option";var l,h=s.prototype,v=((l=Object.create(h)).tag="None",Object.freeze(l),l),p=s,m=i(),g=i(),O=/*#__PURE__*/function(){function t(){}var n=t.prototype;return n.map=function(t){return"Ok"===this.tag?k.Ok(t(this.value)):this},n.mapError=function(t){return"Ok"===this.tag?this:k.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.getOr=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?p.Some(this.value):v},n.isOk=function(){return"Ok"===this.tag},n.isError=function(){return"Error"===this.tag},n.toJSON=function(){return this.match({Ok:function(t){var n;return(n={})[a]="Result",n.tag="Ok",n.value=t,n},Error:function(t){var n;return(n={})[a]="Result",n.tag="Error",n.error=t,n}})},t}();O.P={Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",error:t}}},O.Ok=function(t){var n=m.get(t);if(null==n){var r=Object.create(_);return r.tag="Ok",r.value=t,Object.freeze(r),m.set(t,r),r}return n},O.Error=function(t){var n=g.get(t);if(null==n){var r=Object.create(_);return r.tag="Error",r.error=t,Object.freeze(r),g.set(t,r),r}return n},O.isResult=function(t){return null!=t&&"Result"===t.__boxed_type__},O.fromExecution=function(t){try{return k.Ok(t())}catch(t){return k.Error(t)}},O.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)}},O.fromOption=function(t,n){return t.toResult(n)},O.all=function(t){for(var n,r=t.length,e=k.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},O.allFromDict=function(r){var e=t(r);return k.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},O.equals=function(t,n,r){return t.tag===n.tag&&(!(!t.isError()||!n.isError())||!(!t.isOk()||!n.isOk())&&r(t.get(),n.get()))},O.fromJSON=function(t){return"Ok"===t.tag?k.Ok(t.value):k.Error(t.error)},O.prototype.__boxed_type__="Result";var _=O.prototype,k=O,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 p.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 p.Some(e)}return p.None()},findIndex:function(t,n){for(var r=-1;++r<t.length;)if(n(t[r]))return p.Some(r);return p.None()},binarySearchBy:function(t,n,r){if(void 0===r&&(r=d),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:c},E=i(),b=/*#__PURE__*/function(){function t(){}var n=t.prototype;return n.map=function(t){return this===j||this===D?this:R.Done(t(this.value))},n.flatMap=function(t){return this===j||this===D?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 k.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 k.Error(t(n))}})})},n.flatMapOk=function(t){return this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return R.Done(n)}})})},n.flatMapError=function(t){return this.flatMap(function(n){return n.match({Ok:function(){return R.Done(n)},Error:function(n){return t(n)}})})},n.get=function(){return this.value},n.getWithDefault=function(t){return this===j||this===D?t:this.value},n.getOr=function(t){return this===j||this===D?t:this.value},n.match=function(t){return this===j?t.NotAsked():this===D?t.Loading():t.Done(this.value)},n.tap=function(t){return t(this),this},n.toOption=function(){return this===j||this===D?p.None():p.Some(this.value)},n.isDone=function(){return this!==j&&this!==D},n.isLoading=function(){return this===D},n.isNotAsked=function(){return this===j},n.toJSON=function(){return this.match({NotAsked:function(){var t;return(t={})[a]="AsyncData",t.tag="NotAsked",t},Loading:function(){var t;return(t={})[a]="AsyncData",t.tag="Loading",t},Done:function(t){var n;return(n={})[a]="AsyncData",n.tag="Done",n.value=t,n}})},t}();b.P={Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}},b.Done=function(t){var n=E.get(t);if(null==n){var r=Object.create(N);return r.tag="Done",r.value=t,Object.freeze(r),E.set(t,r),r}return n},b.Loading=function(){return D},b.NotAsked=function(){return j},b.all=function(t){for(var n,r=t.length,e=R.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},b.allFromDict=function(r){var e=t(r);return R.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},b.equals=function(t,n,r){return"Done"===t.tag&&"Done"===n.tag?r(t.value,n.value):t.tag===n.tag},b.isAsyncData=function(t){return null!=t&&"AsyncData"===t.__boxed_type__},b.fromJSON=function(t){return"NotAsked"===t.tag?R.NotAsked():"Loading"===t.tag?R.Loading():R.Done(t.value)},b.prototype.__boxed_type__="AsyncData";var S,N=b.prototype,D=((S=Object.create(N)).tag="Loading",Object.freeze(S),S),j=function(){var t=Object.create(N);return t.tag="NotAsked",Object.freeze(t),t}(),R=b,A=/*#__PURE__*/function(){function t(){this._state=void 0,this._state={tag:"Pending"}}t.fromPromise=function(t){return P.make(function(n){t.then(function(t){return n(k.Ok(t))},function(t){return n(k.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=P.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=P.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 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(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return P.value(n)}})},n)},n.flatMapError=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(){return P.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}();A.make=function(t){var n=Object.create(M);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},A.isFuture=function(t){return null!=t&&Object.prototype.isPrototypeOf.call(M,t)},A.value=function(t){var n=Object.create(M);return n._state={tag:"Resolved",value:t},n},A.all=function(t,n){void 0===n&&(n=!1);for(var r,e=t.length,o=P.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},A.allFromDict=function(r){var e=t(r);return P.all(n(r)).map(function(t){return Object.fromEntries(c(e,t))})},A.wait=function(t){return P.make(function(n){var r=setTimeout(function(){return n()},t);return function(){return clearTimeout(r)}})},A.retry=function(t,n){var r=n.max;return function n(e){return t(e).flatMapError(function(t){return e+1<r?n(e+1):P.value(k.Error(t))})}(0)},A.concurrent=function(t,n){var r=n.concurrency;return P.make(function(n){var e=Array(t.length),o=r-1,u=0;t.slice(0,r).forEach(function r(i,a){return i().tap(function(i){if(e[a]=i,++u<t.length){var c=t[++o];null!=c&&r(c,o)}else n(e)})})})};var M=Object.create(null,Object.getOwnPropertyDescriptors(A.prototype)),P=A,x={make:function(){var t;return[P.make(function(n){t=n}),t]}},C=Symbol("NOT_COMPUTED");function z(){return z=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},z.apply(this,arguments)}var J={__proto__:null,encode:function(t,n){return JSON.stringify(t,function(t,n){return null==n?n:"string"==typeof n[a]?z({},n,{__boxed_type__:n[a]}):n},n)},decode:function(t){return JSON.parse(t,function(t,n){return null==n?n:"Option"===n.__boxed_type__?p.fromJSON(n):"Result"===n.__boxed_type__?k.fromJSON(n):"AsyncData"===n.__boxed_type__?R.fromJSON(n):n})}};exports.Array=y,exports.AsyncData=R,exports.Deferred=x,exports.Dict=e,exports.Future=P,exports.Lazy=function(t){var n={contents:C};return{get:function(){return n.contents===C&&(n.contents=t()),n.contents}}},exports.Option=p,exports.Result=k,exports.Serializer=J; | ||
//# sourceMappingURL=Boxed.js.map |
@@ -0,1 +1,7 @@ | ||
# 3.1.1 | ||
Fixes: | ||
- Handle null checks in store getter (c79d04b) | ||
# 3.1.0 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "@swan-io/boxed", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"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
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
198087