@swan-io/boxed
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -6,3 +6,3 @@ import * as Array from "./Array"; | ||
import { Future } from "./Future"; | ||
import * as Lazy from "./Lazy"; | ||
import { Lazy } from "./Lazy"; | ||
import { Option } from "./Option"; | ||
@@ -9,0 +9,0 @@ import { Result } from "./Result"; |
@@ -1,2 +0,2 @@ | ||
var t=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="None",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Some"===this.tag?o.Some(t(this.value)):this},n.flatMap=function(t){return"Some"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Some"===this.tag?this.value:t},n.match=function(t){return"Some"===this.tag?t.Some(this.value):t.None()},n.tap=function(t){return t(this),this},n.toUndefined=function(){return"None"===this.tag?void 0:this.value},n.toNull=function(){return"None"===this.tag?null:this.value},n.isSome=function(){return"Some"===this.tag},n.isNone=function(){return"None"===this.tag},t}();t.prototype.__boxed_type__="Option";var n,e=Object.create(null,Object.getOwnPropertyDescriptors(t.prototype)),r=((n=Object.create(e)).tag="None",n.value=void 0,n),o={Some:function(t){var n=Object.create(e);return n.tag="Some",n.value=t,n},None:function(){return r},fromNullable:function(t){return null==t?o.None():o.Some(t)},fromNull:function(t){return null===t?o.None():o.Some(t)},fromUndefined:function(t){return void 0===t?o.None():o.Some(t)},all:function(t){for(var n=t.length,e=o.Some([]),r=0,u=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var i=u();if("object"==typeof i)return i.v}},equals:function(t,n,e){return"Some"===t.tag&&"Some"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}}},u=function(t,n){return t===n?0:t>n?1:-1},i={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,keepMap:function(t,n){var e=[];return t.forEach(function(t){var r=n(t);null!=r&&e.push(r)}),e},getBy:function(t,n){for(var e=-1;++e<t.length;){var r=t[e];if(n(r))return o.Some(r)}return o.None()},getIndexBy:function(t,n){for(var e=-1;++e<t.length;)if(n(t[e]))return o.Some(e);return o.None()},binarySearchBy:function(t,n,e){if(void 0===e&&(e=u),0===t.length)return-1;for(var r=0,o=t.length-1;;){var i=r+(o-r)/2|0;if(i===r||i===o)return o;var a=e(n,t[i]);if(0===a)return i;a>0?r=i:a<0&&(o=i)}}},a=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="NotAsked",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Done"===this.tag?v.Done(t(this.value)):this},n.flatMap=function(t){return"Done"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Done"===this.tag?this.value:t},n.match=function(t){return"Done"===this.tag?t.Done(this.value):"Loading"===this.tag?t.Loading():t.NotAsked()},n.tap=function(t){return t(this),this},n.isDone=function(){return"Done"===this.tag},n.isLoading=function(){return"Loading"===this.tag},n.isNotAsked=function(){return"NotAsked"===this.tag},n.toOption=function(){return"Done"===this.tag?o.Some(this.value):o.None()},t}();a.prototype.__boxed_type__="AsyncData";var c,f=Object.create(null,Object.getOwnPropertyDescriptors(a.prototype)),s=((c=Object.create(f)).tag="Loading",c.value=void 0,c),l=function(){var t=Object.create(f);return t.tag="NotAsked",t.value=void 0,t}(),v={Done:function(t){var n=Object.create(f);return n.tag="Done",n.value=t,n},Loading:function(){return s},NotAsked:function(){return l},all:function(t){for(var n=t.length,e=v.Done([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var u=o();if("object"==typeof u)return u.v}},equals:function(t,n,e){return"Done"===t.tag&&"Done"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}}},h=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag=void 0,this.value=void 0}var n=t.prototype;return n.map=function(t){return"Ok"===this.tag?p.Ok(t(this.value)):this},n.mapError=function(t){return"Ok"===this.tag?this:p.Error(t(this.value))},n.flatMap=function(t){return"Ok"===this.tag?t(this.value):this},n.flatMapError=function(t){return"Ok"===this.tag?this:t(this.value)},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.value)},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.value),this},n.isOk=function(){return"Ok"===this.tag},n.isError=function(){return"Error"===this.tag},n.toOption=function(){return"Ok"===this.tag?o.Some(this.value):o.None()},t}();h.prototype.__boxed_type__="Result";var g=Object.create(null,Object.getOwnPropertyDescriptors(h.prototype)),p={Ok:function(t){var n=Object.create(g);return n.tag="Ok",n.value=t,n},Error:function(t){var n=Object.create(g);return n.tag="Error",n.value=t,n},fromExecution:function(t){try{return p.Ok(t())}catch(t){return p.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,e){try{var r=Promise.resolve(t).then(function(t){return p.Ok(t)})}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(t){return p.Error(t)}))}catch(t){return Promise.reject(t)}},all:function(t){for(var n=t.length,e=p.Ok([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var u=o();if("object"==typeof u)return u.v}},equals:function(t,n,e){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||e(t.value,n.value))},pattern:{Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}}};function d(t){var n=this,e={};this.tag="Pending",this.pending=e,e.cancel=t(function(t){if("Pending"===n.tag){var e=n.pending.resolveCallbacks;null==e||e.forEach(function(n){return n(t)}),n.tag="Resolved",n.value=t,n.pending=void 0}})}var _=Object.create(null,Object.getOwnPropertyDescriptors(/*#__PURE__*/function(){function t(t){this.tag=void 0,this.value=void 0,this.pending=void 0,this.tag="Pending",this.pending={}}var n=t.prototype;return n.isPending=function(){return"Pending"===this.tag},n.isCancelled=function(){return"Cancelled"===this.tag},n.isResolved=function(){return"Resolved"===this.tag},n.get=function(t){if(this.isPending()){var n,e=this.pending;e.resolveCallbacks=null!=(n=e.resolveCallbacks)?n:[],e.resolveCallbacks.push(t)}this.isResolved()&&t(this.value)},n.onCancel=function(t){if(this.isPending()){var n,e=this.pending;e.cancelCallbacks=null!=(n=e.cancelCallbacks)?n:[],e.cancelCallbacks.push(t)}this.isCancelled()&&t()},n.cancel=function(){if("Pending"===this.tag){this.tag="Cancelled",this.value=void 0;var t=this.pending,n=t.cancelCallbacks;null==t.cancel||t.cancel(),null==n||n.forEach(function(t){return t()}),this.pending=void 0}},n.map=function(t,n){var e=this;void 0===n&&(n=!1);var r=m.make(function(r){if(e.get(function(n){r(t(n))}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.then=function(t){return this.get(t),this},n.flatMap=function(t,n){var e=this;void 0===n&&(n=!1);var r=m.make(function(o){if(e.get(function(n){var e=t(n);e.get(o),e.onCancel(function(){return r.cancel()})}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.tap=function(t){return this.get(t),this},n.tapOk=function(t){return this.get(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.get(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.mapResult=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.mapOk=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return p.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 p.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 m.value(n)}})},n)},n.flatMapError=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(){return m.value(n)},Error:function(n){return t(n)}})},n)},n.toPromise=function(){var t=this;return new Promise(function(n){t.get(n)})},n.resultToPromise=function(){var t=this;return new Promise(function(n,e){t.get(function(t){t.match({Ok:n,Error:e})})})},t}().prototype)),m={make:function(t){var n=Object.create(_);return d.call(n,t),n},value:function(t){var n=Object.create(_);return d.call(n,function(n){return n(t)}),n},fromPromise:function(t){return m.make(function(n){t.then(function(t){return n(p.Ok(t))},function(t){return n(p.Error(t))})})},all:function(t,n){void 0===n&&(n=!1);for(var e=t.length,r=m.value([]),o=0,u=function(){if(o>=e)return{v:r};var u=t[o];r=r.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}}},O={make:function(){var t=void 0;return[m.make(function(n){t=n}),t]}},k={__proto__:null,entries:function(t){return Object.entries(t)},keys:function(t){return Object.keys(t)},values:function(t){return Object.values(t)}},y=Symbol.for("NOT_COMPUTED"),b={__proto__:null,Lazy:function(t){var n={contents:y};return{get value(){return n.contents===y&&(n.contents=t()),n.contents}}}},E={__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?o.Some(n.value):o.None():"Result"===n.__boxed_type__?"Ok"===n.tag?p.Ok(n.value):p.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?v.NotAsked():"Loading"===n.tag?v.Loading():v.Done(n.value):n})}};export{i as Array,v as AsyncData,O as Deferred,k as Dict,m as Future,b as Lazy,o as Option,p as Result,E as Serializer}; | ||
var t=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="None",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Some"===this.tag?o.Some(t(this.value)):this},n.flatMap=function(t){return"Some"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Some"===this.tag?this.value:t},n.match=function(t){return"Some"===this.tag?t.Some(this.value):t.None()},n.tap=function(t){return t(this),this},n.toUndefined=function(){return"None"===this.tag?void 0:this.value},n.toNull=function(){return"None"===this.tag?null:this.value},n.isSome=function(){return"Some"===this.tag},n.isNone=function(){return"None"===this.tag},t}();t.prototype.__boxed_type__="Option";var n,e=Object.create(null,Object.getOwnPropertyDescriptors(t.prototype)),r=((n=Object.create(e)).tag="None",n.value=void 0,n),o={Some:function(t){var n=Object.create(e);return n.tag="Some",n.value=t,n},None:function(){return r},fromNullable:function(t){return null==t?o.None():o.Some(t)},fromNull:function(t){return null===t?o.None():o.Some(t)},fromUndefined:function(t){return void 0===t?o.None():o.Some(t)},all:function(t){for(var n=t.length,e=o.Some([]),r=0,u=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var i=u();if("object"==typeof i)return i.v}},equals:function(t,n,e){return"Some"===t.tag&&"Some"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}}},u=function(t,n){return t===n?0:t>n?1:-1},i={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,keepMap:function(t,n){var e=[];return t.forEach(function(t){var r=n(t);null!=r&&e.push(r)}),e},getBy:function(t,n){for(var e=-1;++e<t.length;){var r=t[e];if(n(r))return o.Some(r)}return o.None()},getIndexBy:function(t,n){for(var e=-1;++e<t.length;)if(n(t[e]))return o.Some(e);return o.None()},binarySearchBy:function(t,n,e){if(void 0===e&&(e=u),0===t.length)return-1;for(var r=0,o=t.length-1;;){var i=r+(o-r)/2|0;if(i===r||i===o)return o;var a=e(n,t[i]);if(0===a)return i;a>0?r=i:a<0&&(o=i)}}},a=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="NotAsked",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Done"===this.tag?v.Done(t(this.value)):this},n.flatMap=function(t){return"Done"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Done"===this.tag?this.value:t},n.match=function(t){return"Done"===this.tag?t.Done(this.value):"Loading"===this.tag?t.Loading():t.NotAsked()},n.tap=function(t){return t(this),this},n.isDone=function(){return"Done"===this.tag},n.isLoading=function(){return"Loading"===this.tag},n.isNotAsked=function(){return"NotAsked"===this.tag},n.toOption=function(){return"Done"===this.tag?o.Some(this.value):o.None()},t}();a.prototype.__boxed_type__="AsyncData";var c,f=Object.create(null,Object.getOwnPropertyDescriptors(a.prototype)),s=((c=Object.create(f)).tag="Loading",c.value=void 0,c),l=function(){var t=Object.create(f);return t.tag="NotAsked",t.value=void 0,t}(),v={Done:function(t){var n=Object.create(f);return n.tag="Done",n.value=t,n},Loading:function(){return s},NotAsked:function(){return l},all:function(t){for(var n=t.length,e=v.Done([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var u=o();if("object"==typeof u)return u.v}},equals:function(t,n,e){return"Done"===t.tag&&"Done"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}}},h=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag=void 0,this.value=void 0}var n=t.prototype;return n.map=function(t){return"Ok"===this.tag?p.Ok(t(this.value)):this},n.mapError=function(t){return"Ok"===this.tag?this:p.Error(t(this.value))},n.flatMap=function(t){return"Ok"===this.tag?t(this.value):this},n.flatMapError=function(t){return"Ok"===this.tag?this:t(this.value)},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.value)},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.value),this},n.isOk=function(){return"Ok"===this.tag},n.isError=function(){return"Error"===this.tag},n.toOption=function(){return"Ok"===this.tag?o.Some(this.value):o.None()},t}();h.prototype.__boxed_type__="Result";var g=Object.create(null,Object.getOwnPropertyDescriptors(h.prototype)),p={Ok:function(t){var n=Object.create(g);return n.tag="Ok",n.value=t,n},Error:function(t){var n=Object.create(g);return n.tag="Error",n.value=t,n},fromExecution:function(t){try{return p.Ok(t())}catch(t){return p.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,e){try{var r=Promise.resolve(t).then(function(t){return p.Ok(t)})}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(t){return p.Error(t)}))}catch(t){return Promise.reject(t)}},all:function(t){for(var n=t.length,e=p.Ok([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var u=o();if("object"==typeof u)return u.v}},equals:function(t,n,e){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||e(t.value,n.value))},pattern:{Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}}};function d(t){var n=this,e={};this.tag="Pending",this.pending=e,e.cancel=t(function(t){if("Pending"===n.tag){var e=n.pending.resolveCallbacks;null==e||e.forEach(function(n){return n(t)}),n.tag="Resolved",n.value=t,n.pending=void 0}})}var m=Object.create(null,Object.getOwnPropertyDescriptors(/*#__PURE__*/function(){function t(t){this.tag=void 0,this.value=void 0,this.pending=void 0,this.tag="Pending",this.pending={}}var n=t.prototype;return n.isPending=function(){return"Pending"===this.tag},n.isCancelled=function(){return"Cancelled"===this.tag},n.isResolved=function(){return"Resolved"===this.tag},n.get=function(t){if(this.isPending()){var n,e=this.pending;e.resolveCallbacks=null!=(n=e.resolveCallbacks)?n:[],e.resolveCallbacks.push(t)}this.isResolved()&&t(this.value)},n.onCancel=function(t){if(this.isPending()){var n,e=this.pending;e.cancelCallbacks=null!=(n=e.cancelCallbacks)?n:[],e.cancelCallbacks.push(t)}this.isCancelled()&&t()},n.cancel=function(){if("Pending"===this.tag){this.tag="Cancelled",this.value=void 0;var t=this.pending,n=t.cancelCallbacks;null==t.cancel||t.cancel(),null==n||n.forEach(function(t){return t()}),this.pending=void 0}},n.map=function(t,n){var e=this;void 0===n&&(n=!1);var r=_.make(function(r){if(e.get(function(n){r(t(n))}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.then=function(t){return this.get(t),this},n.flatMap=function(t,n){var e=this;void 0===n&&(n=!1);var r=_.make(function(o){if(e.get(function(n){var e=t(n);e.get(o),e.onCancel(function(){return r.cancel()})}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.tap=function(t){return this.get(t),this},n.tapOk=function(t){return this.get(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.get(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.mapResult=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.mapOk=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return p.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 p.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 _.value(n)}})},n)},n.flatMapError=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(){return _.value(n)},Error:function(n){return t(n)}})},n)},n.toPromise=function(){var t=this;return new Promise(function(n){t.get(n)})},n.resultToPromise=function(){var t=this;return new Promise(function(n,e){t.get(function(t){t.match({Ok:n,Error:e})})})},t}().prototype)),_={make:function(t){var n=Object.create(m);return d.call(n,t),n},value:function(t){var n=Object.create(m);return d.call(n,function(n){return n(t)}),n},fromPromise:function(t){return _.make(function(n){t.then(function(t){return n(p.Ok(t))},function(t){return n(p.Error(t))})})},all:function(t,n){void 0===n&&(n=!1);for(var e=t.length,r=_.value([]),o=0,u=function(){if(o>=e)return{v:r};var u=t[o];r=r.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}}},O={make:function(){var t=void 0;return[_.make(function(n){t=n}),t]}},k={__proto__:null,entries:function(t){return Object.entries(t)},keys:function(t){return Object.keys(t)},values:function(t){return Object.values(t)}},y=Symbol.for("NOT_COMPUTED"),b=function(t){var n={contents:y};return{get value(){return n.contents===y&&(n.contents=t()),n.contents}}},E={__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?o.Some(n.value):o.None():"Result"===n.__boxed_type__?"Ok"===n.tag?p.Ok(n.value):p.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?v.NotAsked():"Loading"===n.tag?v.Loading():v.Done(n.value):n})}};export{i as Array,v as AsyncData,O as Deferred,k as Dict,_ as Future,b as Lazy,o as Option,p as Result,E as Serializer}; | ||
//# sourceMappingURL=Boxed.esm.js.map |
@@ -1,2 +0,2 @@ | ||
var t=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="None",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Some"===this.tag?o.Some(t(this.value)):this},n.flatMap=function(t){return"Some"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Some"===this.tag?this.value:t},n.match=function(t){return"Some"===this.tag?t.Some(this.value):t.None()},n.tap=function(t){return t(this),this},n.toUndefined=function(){return"None"===this.tag?void 0:this.value},n.toNull=function(){return"None"===this.tag?null:this.value},n.isSome=function(){return"Some"===this.tag},n.isNone=function(){return"None"===this.tag},t}();t.prototype.__boxed_type__="Option";var n,e=Object.create(null,Object.getOwnPropertyDescriptors(t.prototype)),r=((n=Object.create(e)).tag="None",n.value=void 0,n),o={Some:function(t){var n=Object.create(e);return n.tag="Some",n.value=t,n},None:function(){return r},fromNullable:function(t){return null==t?o.None():o.Some(t)},fromNull:function(t){return null===t?o.None():o.Some(t)},fromUndefined:function(t){return void 0===t?o.None():o.Some(t)},all:function(t){for(var n=t.length,e=o.Some([]),r=0,u=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var i=u();if("object"==typeof i)return i.v}},equals:function(t,n,e){return"Some"===t.tag&&"Some"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}}},u=function(t,n){return t===n?0:t>n?1:-1},i={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,keepMap:function(t,n){var e=[];return t.forEach(function(t){var r=n(t);null!=r&&e.push(r)}),e},getBy:function(t,n){for(var e=-1;++e<t.length;){var r=t[e];if(n(r))return o.Some(r)}return o.None()},getIndexBy:function(t,n){for(var e=-1;++e<t.length;)if(n(t[e]))return o.Some(e);return o.None()},binarySearchBy:function(t,n,e){if(void 0===e&&(e=u),0===t.length)return-1;for(var r=0,o=t.length-1;;){var i=r+(o-r)/2|0;if(i===r||i===o)return o;var a=e(n,t[i]);if(0===a)return i;a>0?r=i:a<0&&(o=i)}}},a=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="NotAsked",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Done"===this.tag?v.Done(t(this.value)):this},n.flatMap=function(t){return"Done"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Done"===this.tag?this.value:t},n.match=function(t){return"Done"===this.tag?t.Done(this.value):"Loading"===this.tag?t.Loading():t.NotAsked()},n.tap=function(t){return t(this),this},n.isDone=function(){return"Done"===this.tag},n.isLoading=function(){return"Loading"===this.tag},n.isNotAsked=function(){return"NotAsked"===this.tag},n.toOption=function(){return"Done"===this.tag?o.Some(this.value):o.None()},t}();a.prototype.__boxed_type__="AsyncData";var c,s=Object.create(null,Object.getOwnPropertyDescriptors(a.prototype)),f=((c=Object.create(s)).tag="Loading",c.value=void 0,c),l=function(){var t=Object.create(s);return t.tag="NotAsked",t.value=void 0,t}(),v={Done:function(t){var n=Object.create(s);return n.tag="Done",n.value=t,n},Loading:function(){return f},NotAsked:function(){return l},all:function(t){for(var n=t.length,e=v.Done([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var u=o();if("object"==typeof u)return u.v}},equals:function(t,n,e){return"Done"===t.tag&&"Done"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}}},h=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag=void 0,this.value=void 0}var n=t.prototype;return n.map=function(t){return"Ok"===this.tag?p.Ok(t(this.value)):this},n.mapError=function(t){return"Ok"===this.tag?this:p.Error(t(this.value))},n.flatMap=function(t){return"Ok"===this.tag?t(this.value):this},n.flatMapError=function(t){return"Ok"===this.tag?this:t(this.value)},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.value)},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.value),this},n.isOk=function(){return"Ok"===this.tag},n.isError=function(){return"Error"===this.tag},n.toOption=function(){return"Ok"===this.tag?o.Some(this.value):o.None()},t}();h.prototype.__boxed_type__="Result";var g=Object.create(null,Object.getOwnPropertyDescriptors(h.prototype)),p={Ok:function(t){var n=Object.create(g);return n.tag="Ok",n.value=t,n},Error:function(t){var n=Object.create(g);return n.tag="Error",n.value=t,n},fromExecution:function(t){try{return p.Ok(t())}catch(t){return p.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,e){try{var r=Promise.resolve(t).then(function(t){return p.Ok(t)})}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(t){return p.Error(t)}))}catch(t){return Promise.reject(t)}},all:function(t){for(var n=t.length,e=p.Ok([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var u=o();if("object"==typeof u)return u.v}},equals:function(t,n,e){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||e(t.value,n.value))},pattern:{Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}}};function d(t){var n=this,e={};this.tag="Pending",this.pending=e,e.cancel=t(function(t){if("Pending"===n.tag){var e=n.pending.resolveCallbacks;null==e||e.forEach(function(n){return n(t)}),n.tag="Resolved",n.value=t,n.pending=void 0}})}var _=Object.create(null,Object.getOwnPropertyDescriptors(/*#__PURE__*/function(){function t(t){this.tag=void 0,this.value=void 0,this.pending=void 0,this.tag="Pending",this.pending={}}var n=t.prototype;return n.isPending=function(){return"Pending"===this.tag},n.isCancelled=function(){return"Cancelled"===this.tag},n.isResolved=function(){return"Resolved"===this.tag},n.get=function(t){if(this.isPending()){var n,e=this.pending;e.resolveCallbacks=null!=(n=e.resolveCallbacks)?n:[],e.resolveCallbacks.push(t)}this.isResolved()&&t(this.value)},n.onCancel=function(t){if(this.isPending()){var n,e=this.pending;e.cancelCallbacks=null!=(n=e.cancelCallbacks)?n:[],e.cancelCallbacks.push(t)}this.isCancelled()&&t()},n.cancel=function(){if("Pending"===this.tag){this.tag="Cancelled",this.value=void 0;var t=this.pending,n=t.cancelCallbacks;null==t.cancel||t.cancel(),null==n||n.forEach(function(t){return t()}),this.pending=void 0}},n.map=function(t,n){var e=this;void 0===n&&(n=!1);var r=m.make(function(r){if(e.get(function(n){r(t(n))}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.then=function(t){return this.get(t),this},n.flatMap=function(t,n){var e=this;void 0===n&&(n=!1);var r=m.make(function(o){if(e.get(function(n){var e=t(n);e.get(o),e.onCancel(function(){return r.cancel()})}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.tap=function(t){return this.get(t),this},n.tapOk=function(t){return this.get(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.get(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.mapResult=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.mapOk=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return p.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 p.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 m.value(n)}})},n)},n.flatMapError=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(){return m.value(n)},Error:function(n){return t(n)}})},n)},n.toPromise=function(){var t=this;return new Promise(function(n){t.get(n)})},n.resultToPromise=function(){var t=this;return new Promise(function(n,e){t.get(function(t){t.match({Ok:n,Error:e})})})},t}().prototype)),m={make:function(t){var n=Object.create(_);return d.call(n,t),n},value:function(t){var n=Object.create(_);return d.call(n,function(n){return n(t)}),n},fromPromise:function(t){return m.make(function(n){t.then(function(t){return n(p.Ok(t))},function(t){return n(p.Error(t))})})},all:function(t,n){void 0===n&&(n=!1);for(var e=t.length,r=m.value([]),o=0,u=function(){if(o>=e)return{v:r};var u=t[o];r=r.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}}},O={make:function(){var t=void 0;return[m.make(function(n){t=n}),t]}},k={__proto__:null,entries:function(t){return Object.entries(t)},keys:function(t){return Object.keys(t)},values:function(t){return Object.values(t)}},y=Symbol.for("NOT_COMPUTED"),b={__proto__:null,Lazy:function(t){var n={contents:y};return{get value(){return n.contents===y&&(n.contents=t()),n.contents}}}},E={__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?o.Some(n.value):o.None():"Result"===n.__boxed_type__?"Ok"===n.tag?p.Ok(n.value):p.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?v.NotAsked():"Loading"===n.tag?v.Loading():v.Done(n.value):n})}};exports.Array=i,exports.AsyncData=v,exports.Deferred=O,exports.Dict=k,exports.Future=m,exports.Lazy=b,exports.Option=o,exports.Result=p,exports.Serializer=E; | ||
var t=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="None",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Some"===this.tag?o.Some(t(this.value)):this},n.flatMap=function(t){return"Some"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Some"===this.tag?this.value:t},n.match=function(t){return"Some"===this.tag?t.Some(this.value):t.None()},n.tap=function(t){return t(this),this},n.toUndefined=function(){return"None"===this.tag?void 0:this.value},n.toNull=function(){return"None"===this.tag?null:this.value},n.isSome=function(){return"Some"===this.tag},n.isNone=function(){return"None"===this.tag},t}();t.prototype.__boxed_type__="Option";var n,e=Object.create(null,Object.getOwnPropertyDescriptors(t.prototype)),r=((n=Object.create(e)).tag="None",n.value=void 0,n),o={Some:function(t){var n=Object.create(e);return n.tag="Some",n.value=t,n},None:function(){return r},fromNullable:function(t){return null==t?o.None():o.Some(t)},fromNull:function(t){return null===t?o.None():o.Some(t)},fromUndefined:function(t){return void 0===t?o.None():o.Some(t)},all:function(t){for(var n=t.length,e=o.Some([]),r=0,i=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var u=i();if("object"==typeof u)return u.v}},equals:function(t,n,e){return"Some"===t.tag&&"Some"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}}},i=function(t,n){return t===n?0:t>n?1:-1},u={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,keepMap:function(t,n){var e=[];return t.forEach(function(t){var r=n(t);null!=r&&e.push(r)}),e},getBy:function(t,n){for(var e=-1;++e<t.length;){var r=t[e];if(n(r))return o.Some(r)}return o.None()},getIndexBy:function(t,n){for(var e=-1;++e<t.length;)if(n(t[e]))return o.Some(e);return o.None()},binarySearchBy:function(t,n,e){if(void 0===e&&(e=i),0===t.length)return-1;for(var r=0,o=t.length-1;;){var u=r+(o-r)/2|0;if(u===r||u===o)return o;var a=e(n,t[u]);if(0===a)return u;a>0?r=u:a<0&&(o=u)}}},a=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag="NotAsked",this.value=void 0}var n=t.prototype;return n.map=function(t){return"Done"===this.tag?v.Done(t(this.value)):this},n.flatMap=function(t){return"Done"===this.tag?t(this.value):this},n.getWithDefault=function(t){return"Done"===this.tag?this.value:t},n.match=function(t){return"Done"===this.tag?t.Done(this.value):"Loading"===this.tag?t.Loading():t.NotAsked()},n.tap=function(t){return t(this),this},n.isDone=function(){return"Done"===this.tag},n.isLoading=function(){return"Loading"===this.tag},n.isNotAsked=function(){return"NotAsked"===this.tag},n.toOption=function(){return"Done"===this.tag?o.Some(this.value):o.None()},t}();a.prototype.__boxed_type__="AsyncData";var c,s=Object.create(null,Object.getOwnPropertyDescriptors(a.prototype)),f=((c=Object.create(s)).tag="Loading",c.value=void 0,c),l=function(){var t=Object.create(s);return t.tag="NotAsked",t.value=void 0,t}(),v={Done:function(t){var n=Object.create(s);return n.tag="Done",n.value=t,n},Loading:function(){return f},NotAsked:function(){return l},all:function(t){for(var n=t.length,e=v.Done([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var i=o();if("object"==typeof i)return i.v}},equals:function(t,n,e){return"Done"===t.tag&&"Done"===n.tag?e(t.value,n.value):t.tag===n.tag},pattern:{Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}}},h=/*#__PURE__*/function(){function t(){this.tag=void 0,this.value=void 0,this.tag=void 0,this.value=void 0}var n=t.prototype;return n.map=function(t){return"Ok"===this.tag?p.Ok(t(this.value)):this},n.mapError=function(t){return"Ok"===this.tag?this:p.Error(t(this.value))},n.flatMap=function(t){return"Ok"===this.tag?t(this.value):this},n.flatMapError=function(t){return"Ok"===this.tag?this:t(this.value)},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.value)},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.value),this},n.isOk=function(){return"Ok"===this.tag},n.isError=function(){return"Error"===this.tag},n.toOption=function(){return"Ok"===this.tag?o.Some(this.value):o.None()},t}();h.prototype.__boxed_type__="Result";var g=Object.create(null,Object.getOwnPropertyDescriptors(h.prototype)),p={Ok:function(t){var n=Object.create(g);return n.tag="Ok",n.value=t,n},Error:function(t){var n=Object.create(g);return n.tag="Error",n.value=t,n},fromExecution:function(t){try{return p.Ok(t())}catch(t){return p.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,e){try{var r=Promise.resolve(t).then(function(t){return p.Ok(t)})}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(t){return p.Error(t)}))}catch(t){return Promise.reject(t)}},all:function(t){for(var n=t.length,e=p.Ok([]),r=0,o=function(){if(r>=n)return{v:e};var o=t[r];e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t})}),r++};;){var i=o();if("object"==typeof i)return i.v}},equals:function(t,n,e){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||e(t.value,n.value))},pattern:{Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}}};function d(t){var n=this,e={};this.tag="Pending",this.pending=e,e.cancel=t(function(t){if("Pending"===n.tag){var e=n.pending.resolveCallbacks;null==e||e.forEach(function(n){return n(t)}),n.tag="Resolved",n.value=t,n.pending=void 0}})}var m=Object.create(null,Object.getOwnPropertyDescriptors(/*#__PURE__*/function(){function t(t){this.tag=void 0,this.value=void 0,this.pending=void 0,this.tag="Pending",this.pending={}}var n=t.prototype;return n.isPending=function(){return"Pending"===this.tag},n.isCancelled=function(){return"Cancelled"===this.tag},n.isResolved=function(){return"Resolved"===this.tag},n.get=function(t){if(this.isPending()){var n,e=this.pending;e.resolveCallbacks=null!=(n=e.resolveCallbacks)?n:[],e.resolveCallbacks.push(t)}this.isResolved()&&t(this.value)},n.onCancel=function(t){if(this.isPending()){var n,e=this.pending;e.cancelCallbacks=null!=(n=e.cancelCallbacks)?n:[],e.cancelCallbacks.push(t)}this.isCancelled()&&t()},n.cancel=function(){if("Pending"===this.tag){this.tag="Cancelled",this.value=void 0;var t=this.pending,n=t.cancelCallbacks;null==t.cancel||t.cancel(),null==n||n.forEach(function(t){return t()}),this.pending=void 0}},n.map=function(t,n){var e=this;void 0===n&&(n=!1);var r=_.make(function(r){if(e.get(function(n){r(t(n))}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.then=function(t){return this.get(t),this},n.flatMap=function(t,n){var e=this;void 0===n&&(n=!1);var r=_.make(function(o){if(e.get(function(n){var e=t(n);e.get(o),e.onCancel(function(){return r.cancel()})}),n)return function(){e.cancel()}});return this.onCancel(function(){r.cancel()}),r},n.tap=function(t){return this.get(t),this},n.tapOk=function(t){return this.get(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.get(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.mapResult=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.mapOk=function(t,n){return void 0===n&&(n=!1),this.map(function(n){return n.match({Ok:function(n){return p.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 p.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 _.value(n)}})},n)},n.flatMapError=function(t,n){return void 0===n&&(n=!1),this.flatMap(function(n){return n.match({Ok:function(){return _.value(n)},Error:function(n){return t(n)}})},n)},n.toPromise=function(){var t=this;return new Promise(function(n){t.get(n)})},n.resultToPromise=function(){var t=this;return new Promise(function(n,e){t.get(function(t){t.match({Ok:n,Error:e})})})},t}().prototype)),_={make:function(t){var n=Object.create(m);return d.call(n,t),n},value:function(t){var n=Object.create(m);return d.call(n,function(n){return n(t)}),n},fromPromise:function(t){return _.make(function(n){t.then(function(t){return n(p.Ok(t))},function(t){return n(p.Error(t))})})},all:function(t,n){void 0===n&&(n=!1);for(var e=t.length,r=_.value([]),o=0,i=function(){if(o>=e)return{v:r};var i=t[o];r=r.flatMap(function(t){return i.map(function(n){return t.push(n),t},n)},n),o++};;){var u=i();if("object"==typeof u)return u.v}}},O={make:function(){var t=void 0;return[_.make(function(n){t=n}),t]}},k={__proto__:null,entries:function(t){return Object.entries(t)},keys:function(t){return Object.keys(t)},values:function(t){return Object.values(t)}},y=Symbol.for("NOT_COMPUTED"),b={__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?o.Some(n.value):o.None():"Result"===n.__boxed_type__?"Ok"===n.tag?p.Ok(n.value):p.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?v.NotAsked():"Loading"===n.tag?v.Loading():v.Done(n.value):n})}};exports.Array=u,exports.AsyncData=v,exports.Deferred=O,exports.Dict=k,exports.Future=_,exports.Lazy=function(t){var n={contents:y};return{get value(){return n.contents===y&&(n.contents=t()),n.contents}}},exports.Option=o,exports.Result=p,exports.Serializer=b; | ||
//# sourceMappingURL=Boxed.js.map |
@@ -0,1 +1,7 @@ | ||
# 0.3.7 | ||
Fixes: | ||
- Fix issue with `Lazy` export (10064dc) | ||
# 0.3.6 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "@swan-io/boxed", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"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
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
120823