Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swan-io/boxed

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swan-io/boxed - npm Package Compare versions

Comparing version 0.12.0 to 0.12.1

1

dist/Array.d.ts

@@ -10,2 +10,3 @@ import { Option } from "./OptionResult";

export declare const isArray: (arg: any) => arg is any[];
export declare const keepMapOne: <A, B>(array: A[], func: (item: A) => Option<B>) => Option<B>;
export declare const keepMap: <A, B>(array: A[], func: (item: A) => Option<B>) => B[];

@@ -12,0 +13,0 @@ export declare const getBy: <A>(array: A[], func: (item: A) => boolean) => Option<A>;

2

dist/Boxed.js

@@ -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)},u=function(t){return Object.values(t)},o={__proto__:null,entries:function(t){return Object.entries(t)},keys:e,values:u},a=function(t,n){for(var r=Math.min(t.length,n.length),e=Array(r),u=-1;++u<r;)e[u]=[t[u],n[u]];return e},i={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 O.Ok(t)},None:function(){return O.Error(t)}})},isSome:function(){return"Some"===this.tag},isNone:function(){return"None"===this.tag},__boxed_type__:"Option"},c=t({},i,{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(i)).tag="None",n),l=function(){return s},h={Some:f,None:l,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=h.Some([]),e=0,u=function(){if(e>=n)return{v:r};var u=t[e];null!=u&&(r=r.flatMap(function(t){return u.map(function(n){return t.push(n),t})})),e++};;){var o=u();if("object"==typeof o)return o.v}},allFromDict:function(t){var n=e(t);return this.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return"Some"===t.tag&&"Some"===n.tag?r(t.value,n.value):t.tag===n.tag},pattern:{Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}}},v={map:function(t){return"Ok"===this.tag?m(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({},v,{get:function(){return this.value}}),p=t({},v,{getError:function(){return this.value}}),m=function(t){var n=Object.create(g);return n.tag="Ok",n.value=t,n},_=function(t){var n=Object.create(p);return n.tag="Error",n.value=t,n},O={Ok:m,Error:_,fromExecution:function(t){try{return O.Ok(t())}catch(t){return O.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,r){try{var e=Promise.resolve(t).then(function(t){return O.Ok(t)})}catch(t){return r(t)}return e&&e.then?e.then(void 0,r):e}(0,function(t){return O.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=O.Ok([]),e=0,u=function(){if(e>=n)return{v:r};var u=t[e];null!=u&&(r=r.flatMap(function(t){return u.map(function(n){return t.push(n),t})})),e++};;){var o=u();if("object"==typeof o)return o.v}},allFromDict:function(t){var n=e(t);return O.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||r(t.value,n.value))},pattern:{Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}}},k=function(t,n){return t===n?0:t>n?1:-1},d={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,keepMap:function(t,n){var r=[];return t.forEach(function(t){var e=n(t);e.isSome()&&r.push(e.get())}),r},getBy:function(t,n){for(var r=-1;++r<t.length;){var e=t[r];if(n(e))return h.Some(e)}return h.None()},getIndexBy:function(t,n){for(var r=-1;++r<t.length;)if(n(t[r]))return h.Some(r);return h.None()},binarySearchBy:function(t,n,r){if(void 0===r&&(r=k),0===t.length)return-1;for(var e=0,u=t.length-1;;){var o=e+(u-e)/2|0;if(o===e||o===u)return u;var a=r(n,t[o]);if(0===a)return o;a>0?e=o:a<0&&(u=o)}},unzip:function(t){for(var n=t.length,r=Array(n),e=Array(n),u=-1;++u<n;){var o=t[u];void 0!==o&&(r[u]=o[0],e[u]=o[1])}return[r,e]},zip:a},b={map:function(t){return"Done"===this.tag?E(t(this.value)):this},flatMap:function(t){return"Done"===this.tag?t(this.value):this},mapResult:function(t){return this.map(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return n}})})},mapOk:function(t){return this.map(function(n){return n.match({Ok:function(n){return O.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 O.Error(t(n))}})})},flatMapOk:function(t){return this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return E(n)}})})},flatMapError:function(t){return this.flatMap(function(n){return n.match({Ok:function(){return E(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?h.Some(this.value):h.None()},isDone:function(){return"Done"===this.tag},isLoading:function(){return"Loading"===this.tag},isNotAsked:function(){return"NotAsked"===this.tag},__boxed_type__:"AsyncData"},y=t({},b,{get:function(){return this.value}}),E=function(t){var n=Object.create(y);return n.tag="Done",n.value=t,n},D=((r=Object.create(b)).tag="Loading",r),S=function(){var t=Object.create(b);return t.tag="NotAsked",t}(),N={Done:E,Loading:function(){return D},NotAsked:function(){return S},all:function(t){for(var n=t.length,r=N.Done([]),e=0,u=function(){if(e>=n)return{v:r};var u=t[e];null!=u&&(r=r.flatMap(function(t){return u.map(function(n){return t.push(n),t})})),e++};;){var o=u();if("object"==typeof o)return o.v}},allFromDict:function(t){var n=e(t);return N.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return"Done"===t.tag&&"Done"===n.tag?r(t.value,n.value):t.tag===n.tag},pattern:{Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}}};function j(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(O.Ok(n))},function(n){return t(O.Error(n))})})};var n=t.prototype;return n.onResolve=function(t){var n;"Pending"===this._state.tag?(this._state.resolveCallbacks=null!=(n=this._state.resolveCallbacks)?n:[],this._state.resolveCallbacks.push(t)):"Resolved"===this._state.tag&&t(this._state.value)},n.onCancel=function(t){var n;"Pending"===this._state.tag?(this._state.cancelCallbacks=null!=(n=this._state.cancelCallbacks)?n:[],this._state.cancelCallbacks.push(t)):"Cancelled"===this._state.tag&&t()},n.cancel=function(){if("Pending"===this._state.tag){var t=this._state,n=t.cancel,r=t.cancelCallbacks;this._state={tag:"Cancelled"},null==n||n(),null==r||r.forEach(function(t){return t()})}},n.map=function(n,r){var e=this;void 0===r&&(r=!1);var u=t.make(function(t){if(e.onResolve(function(r){t(n(r))}),r)return function(){e.cancel()}});return this.onCancel(function(){u.cancel()}),u},n.then=function(t){return this.onResolve(t),this},n.flatMap=function(n,r){var e=this;void 0===r&&(r=!1);var u=t.make(function(t){if(e.onResolve(function(r){var e=n(r);e.onResolve(t),e.onCancel(function(){return u.cancel()})}),r)return function(){e.cancel()}});return this.onCancel(function(){u.cancel()}),u},n.tap=function(t){return this.onResolve(t),this},n.tapOk=function(t){return this.onResolve(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.onResolve(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.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 O.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 O.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(A);return j.call(n,t),n},x.value=function(t){var n=Object.create(A);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([]),u=0,o=function(){if(u>=r)return{v:e};var o=t[u];null!=o&&(e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t},n)},n)),u++};;){var a=o();if("object"==typeof a)return a.v}},x.allFromDict=function(t){var n=e(t);return x.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})};var A=Object.create(null,Object.getOwnPropertyDescriptors(x.prototype)),R={make:function(){var t=void 0;return[x.make(function(n){t=n}),t]}},M=Symbol("NOT_COMPUTED"),P={__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?h.Some(n.value):h.None():"Result"===n.__boxed_type__?"Ok"===n.tag?O.Ok(n.value):O.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?N.NotAsked():"Loading"===n.tag?N.Loading():N.Done(n.value):n})}};exports.Array=d,exports.AsyncData=N,exports.Deferred=R,exports.Dict=o,exports.Future=x,exports.Lazy=function(t){var n={contents:M};return{get:function(){return n.contents===M&&(n.contents=t()),n.contents}}},exports.Option=h,exports.Result=O,exports.Serializer=P;
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)},u=function(t){return Object.values(t)},o={__proto__:null,entries:function(t){return Object.entries(t)},keys:e,values:u},a=function(t,n){for(var r=Math.min(t.length,n.length),e=Array(r),u=-1;++u<r;)e[u]=[t[u],n[u]];return e},i={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 O.Ok(t)},None:function(){return O.Error(t)}})},isSome:function(){return"Some"===this.tag},isNone:function(){return"None"===this.tag},__boxed_type__:"Option"},c=t({},i,{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(i)).tag="None",n),l=function(){return s},h={Some:f,None:l,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=h.Some([]),e=0,u=function(){if(e>=n)return{v:r};var u=t[e];null!=u&&(r=r.flatMap(function(t){return u.map(function(n){return t.push(n),t})})),e++};;){var o=u();if("object"==typeof o)return o.v}},allFromDict:function(t){var n=e(t);return this.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return"Some"===t.tag&&"Some"===n.tag?r(t.value,n.value):t.tag===n.tag},pattern:{Some:function(t){return{tag:"Some",value:t}},None:{tag:"None"}}},v={map:function(t){return"Ok"===this.tag?m(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({},v,{get:function(){return this.value}}),p=t({},v,{getError:function(){return this.value}}),m=function(t){var n=Object.create(g);return n.tag="Ok",n.value=t,n},_=function(t){var n=Object.create(p);return n.tag="Error",n.value=t,n},O={Ok:m,Error:_,fromExecution:function(t){try{return O.Ok(t())}catch(t){return O.Error(t)}},fromPromise:function(t){try{return Promise.resolve(function(n,r){try{var e=Promise.resolve(t).then(function(t){return O.Ok(t)})}catch(t){return r(t)}return e&&e.then?e.then(void 0,r):e}(0,function(t){return O.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=O.Ok([]),e=0,u=function(){if(e>=n)return{v:r};var u=t[e];null!=u&&(r=r.flatMap(function(t){return u.map(function(n){return t.push(n),t})})),e++};;){var o=u();if("object"==typeof o)return o.v}},allFromDict:function(t){var n=e(t);return O.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return t.tag===n.tag&&("Error"===t.tag&&"Error"===n.tag||r(t.value,n.value))},pattern:{Ok:function(t){return{tag:"Ok",value:t}},Error:function(t){return{tag:"Error",value:t}}}},k=function(t,n){return t===n?0:t>n?1:-1},d={__proto__:null,from:Array.from,of:Array.of,isArray:Array.isArray,keepMapOne:function(t,n){for(var r=-1;++r<t.length;){var e=n(t[r]);if(e.isSome())return e}return h.None()},keepMap:function(t,n){var r=[];return t.forEach(function(t){var e=n(t);e.isSome()&&r.push(e.get())}),r},getBy:function(t,n){for(var r=-1;++r<t.length;){var e=t[r];if(n(e))return h.Some(e)}return h.None()},getIndexBy:function(t,n){for(var r=-1;++r<t.length;)if(n(t[r]))return h.Some(r);return h.None()},binarySearchBy:function(t,n,r){if(void 0===r&&(r=k),0===t.length)return-1;for(var e=0,u=t.length-1;;){var o=e+(u-e)/2|0;if(o===e||o===u)return u;var a=r(n,t[o]);if(0===a)return o;a>0?e=o:a<0&&(u=o)}},unzip:function(t){for(var n=t.length,r=Array(n),e=Array(n),u=-1;++u<n;){var o=t[u];void 0!==o&&(r[u]=o[0],e[u]=o[1])}return[r,e]},zip:a},b={map:function(t){return"Done"===this.tag?E(t(this.value)):this},flatMap:function(t){return"Done"===this.tag?t(this.value):this},mapResult:function(t){return this.map(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return n}})})},mapOk:function(t){return this.map(function(n){return n.match({Ok:function(n){return O.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 O.Error(t(n))}})})},flatMapOk:function(t){return this.flatMap(function(n){return n.match({Ok:function(n){return t(n)},Error:function(){return E(n)}})})},flatMapError:function(t){return this.flatMap(function(n){return n.match({Ok:function(){return E(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?h.Some(this.value):h.None()},isDone:function(){return"Done"===this.tag},isLoading:function(){return"Loading"===this.tag},isNotAsked:function(){return"NotAsked"===this.tag},__boxed_type__:"AsyncData"},y=t({},b,{get:function(){return this.value}}),E=function(t){var n=Object.create(y);return n.tag="Done",n.value=t,n},D=((r=Object.create(b)).tag="Loading",r),S=function(){var t=Object.create(b);return t.tag="NotAsked",t}(),N={Done:E,Loading:function(){return D},NotAsked:function(){return S},all:function(t){for(var n=t.length,r=N.Done([]),e=0,u=function(){if(e>=n)return{v:r};var u=t[e];null!=u&&(r=r.flatMap(function(t){return u.map(function(n){return t.push(n),t})})),e++};;){var o=u();if("object"==typeof o)return o.v}},allFromDict:function(t){var n=e(t);return N.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})},equals:function(t,n,r){return"Done"===t.tag&&"Done"===n.tag?r(t.value,n.value):t.tag===n.tag},pattern:{Done:function(t){return{tag:"Done",value:t}},NotAsked:{tag:"NotAsked"},Loading:{tag:"Loading"}}};function j(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(O.Ok(n))},function(n){return t(O.Error(n))})})};var n=t.prototype;return n.onResolve=function(t){var n;"Pending"===this._state.tag?(this._state.resolveCallbacks=null!=(n=this._state.resolveCallbacks)?n:[],this._state.resolveCallbacks.push(t)):"Resolved"===this._state.tag&&t(this._state.value)},n.onCancel=function(t){var n;"Pending"===this._state.tag?(this._state.cancelCallbacks=null!=(n=this._state.cancelCallbacks)?n:[],this._state.cancelCallbacks.push(t)):"Cancelled"===this._state.tag&&t()},n.cancel=function(){if("Pending"===this._state.tag){var t=this._state,n=t.cancel,r=t.cancelCallbacks;this._state={tag:"Cancelled"},null==n||n(),null==r||r.forEach(function(t){return t()})}},n.map=function(n,r){var e=this;void 0===r&&(r=!1);var u=t.make(function(t){if(e.onResolve(function(r){t(n(r))}),r)return function(){e.cancel()}});return this.onCancel(function(){u.cancel()}),u},n.then=function(t){return this.onResolve(t),this},n.flatMap=function(n,r){var e=this;void 0===r&&(r=!1);var u=t.make(function(t){if(e.onResolve(function(r){var e=n(r);e.onResolve(t),e.onCancel(function(){return u.cancel()})}),r)return function(){e.cancel()}});return this.onCancel(function(){u.cancel()}),u},n.tap=function(t){return this.onResolve(t),this},n.tapOk=function(t){return this.onResolve(function(n){n.match({Ok:function(n){return t(n)},Error:function(){}})}),this},n.tapError=function(t){return this.onResolve(function(n){n.match({Ok:function(){},Error:function(n){return t(n)}})}),this},n.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 O.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 O.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(A);return j.call(n,t),n},x.value=function(t){var n=Object.create(A);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([]),u=0,o=function(){if(u>=r)return{v:e};var o=t[u];null!=o&&(e=e.flatMap(function(t){return o.map(function(n){return t.push(n),t},n)},n)),u++};;){var a=o();if("object"==typeof a)return a.v}},x.allFromDict=function(t){var n=e(t);return x.all(u(t)).map(function(t){return Object.fromEntries(a(n,t))})};var A=Object.create(null,Object.getOwnPropertyDescriptors(x.prototype)),R={make:function(){var t=void 0;return[x.make(function(n){t=n}),t]}},M=Symbol("NOT_COMPUTED"),P={__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?h.Some(n.value):h.None():"Result"===n.__boxed_type__?"Ok"===n.tag?O.Ok(n.value):O.Error(n.value):"AsyncData"===n.__boxed_type__?"NotAsked"===n.tag?N.NotAsked():"Loading"===n.tag?N.Loading():N.Done(n.value):n})}};exports.Array=d,exports.AsyncData=N,exports.Deferred=R,exports.Dict=o,exports.Future=x,exports.Lazy=function(t){var n={contents:M};return{get:function(){return n.contents===M&&(n.contents=t()),n.contents}}},exports.Option=h,exports.Result=O,exports.Serializer=P;
//# sourceMappingURL=Boxed.js.map

@@ -0,4 +1,10 @@

# 0.12.1
Features:
- Add `Array.keepMapOne` (a8300de)
# 0.12.0
Fatures:
Features:

@@ -5,0 +11,0 @@ - Add helpers for `AsyncData<Result>` (6319ada)

{
"name": "@swan-io/boxed",
"version": "0.12.0",
"version": "0.12.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc