Socket
Socket
Sign inDemoInstall

return-style

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

return-style - npm Package Compare versions

Comparing version 0.12.4 to 0.12.5

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

### [0.12.5](https://github.com/BlackGlory/return-style/compare/v0.12.4...v0.12.5) (2021-12-04)
### [0.12.4](https://github.com/BlackGlory/return-style/compare/v0.12.3...v0.12.4) (2021-10-14)

@@ -7,0 +9,0 @@

9

dist/es2015/index.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@blackglory/go')) :
typeof define === 'function' && define.amd ? define(['exports', '@blackglory/go'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReturnStyle = {}, global.go));
})(this, (function (exports, go) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@blackglory/pass'), require('@blackglory/go')) :
typeof define === 'function' && define.amd ? define(['exports', '@blackglory/pass', '@blackglory/go'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReturnStyle = {}, global.pass, global.go));
})(this, (function (exports, pass, go) { 'use strict';

@@ -342,2 +342,3 @@ function getErrorResult(fn) {

const _ = iterable_1_1.value;
pass.pass();
}

@@ -344,0 +345,0 @@ }

@@ -1,2 +0,2 @@

!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@blackglory/go")):"function"==typeof define&&define.amd?define(["exports","@blackglory/go"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnStyle={},t.go)}(this,(function(t,r){"use strict";
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@blackglory/pass"),require("@blackglory/go")):"function"==typeof define&&define.amd?define(["exports","@blackglory/pass","@blackglory/go"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnStyle={},t.pass,t.go)}(this,(function(t,r,n){"use strict";
/*! *****************************************************************************

@@ -16,3 +16,3 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
function n(t,r,n,e){return new(n||(n=Promise))((function(o,i){function u(t){try{c(e.next(t))}catch(t){i(t)}}function s(t){try{c(e.throw(t))}catch(t){i(t)}}function c(t){var r;t.done?o(t.value):(r=t.value,r instanceof n?r:new n((function(t){t(r)}))).then(u,s)}c((e=e.apply(t,r||[])).next())}))}function e(t){var r="function"==typeof Symbol&&Symbol.iterator,n=r&&t[r],e=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,n=t[Symbol.asyncIterator];return n?n.call(t):(t=e(t),r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r);function o(n){r[n]=t[n]&&function(r){return new Promise((function(e,o){(function(t,r,n,e){Promise.resolve(e).then((function(r){t({value:r,done:n})}),r)})(e,o,(r=t[n](r)).done,r.value)}))}}}function i(t,r,n,e){if("a"===n&&!e)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?t!==r||!e:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?e:"a"===n?e.call(t):e?e.value:r.get(t)}function u(t,r,n,e,o){if("m"===e)throw new TypeError("Private method is not writable");if("a"===e&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?t!==r||!o:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===e?o.call(t,n):o?o.value=n:r.set(t,n),n}function s(t){return n(this,void 0,void 0,(function*(){try{return[!0,yield t]}catch(t){return[!1,void 0]}}))}function c(t){return n(this,void 0,void 0,(function*(){try{return yield t,[!1,void 0]}catch(t){return[!0,t]}}))}function f(t){return n(this,void 0,void 0,(function*(){try{return yield t,!0}catch(t){return!1}}))}function d(t){return n(this,void 0,void 0,(function*(){try{return yield t,!1}catch(t){return!0}}))}var a,h,l,v,y;class w{static Ok(t){return m.of(t)}static Err(t){return g.of(t)}}class m extends w{constructor(t){super(),a.set(this,void 0),u(this,a,t,"f")}static of(t){return new m(t)}isOk(){return!0}isErr(){return!1}onOk(t){return t(i(this,a,"f")),m.of(i(this,a,"f"))}onErr(){return m.of(i(this,a,"f"))}orElse(){return m.of(i(this,a,"f"))}map(t){return m.of(t(i(this,a,"f")))}get(){return i(this,a,"f")}}a=new WeakMap;class g extends w{constructor(t){super(),h.set(this,void 0),u(this,h,t,"f")}static of(t){return new g(t)}isOk(){return!1}isErr(){return!0}onOk(){return g.of(i(this,h,"f"))}onErr(t){return t(i(this,h,"f")),g.of(i(this,h,"f"))}orElse(t){return m.of(t)}map(){return g.of(i(this,h,"f"))}get(){throw i(this,h,"f")}}h=new WeakMap;class p{constructor(t){l.set(this,void 0),u(this,l,Promise.resolve(t),"f")}static Ok(t){return E.of(t)}static Err(t){return P.of(t)}get then(){const t=i(this,l,"f").then((t=>w.Ok(t)),(t=>w.Err(t)));return t.then.bind(t)}onOk(t){return r.go((()=>n(this,void 0,void 0,(function*(){const[r,n]=yield s(i(this,l,"f"));r&&t(n)})))),new p(i(this,l,"f"))}onErr(t){return r.go((()=>n(this,void 0,void 0,(function*(){const[r,n]=yield c(i(this,l,"f"));r&&t(n)})))),new p(i(this,l,"f"))}isOk(){return n(this,void 0,void 0,(function*(){return yield f(i(this,l,"f"))}))}isErr(){return n(this,void 0,void 0,(function*(){return yield d(i(this,l,"f"))}))}orElse(t){const e=r.go((()=>n(this,void 0,void 0,(function*(){try{return yield i(this,l,"f")}catch(r){return t}}))));return new p(e)}map(t){const e=r.go((()=>n(this,void 0,void 0,(function*(){const r=yield i(this,l,"f");return t(r)}))));return new p(e)}get(){return n(this,void 0,void 0,(function*(){return yield i(this,l,"f")}))}}l=new WeakMap;class E extends p{static of(t){return new E(t)}constructor(t){super(Promise.resolve(t))}}class P extends p{static of(t){return new P(t)}constructor(t){super(Promise.reject(t))}}class b{static Some(t){return S.of(t)}static None(){return O.of()}}class S extends b{constructor(t){super(),v.set(this,void 0),u(this,v,t,"f")}static of(t){return new S(t)}isSome(){return!0}isNone(){return!1}onSome(t){return t(i(this,v,"f")),S.of(i(this,v,"f"))}onNone(){return S.of(i(this,v,"f"))}orElse(){return S.of(i(this,v,"f"))}map(t){return S.of(t(i(this,v,"f")))}filter(t){return t(i(this,v,"f"))?S.of(i(this,v,"f")):O.of()}get(){return i(this,v,"f")}}v=new WeakMap;class O extends b{static of(){return new O}constructor(){super()}isSome(){return!1}isNone(){return!0}onSome(){return O.of()}onNone(t){return t(),O.of()}orElse(t){return S.of(t)}map(){return O.of()}filter(){return O.of()}get(){throw new Error("Cannot get value from None")}}function k(t,r){const n=t();return r(n)?b.None():b.Some(n)}const x=Symbol();class R{constructor(t){y.set(this,void 0),u(this,y,Promise.resolve(t),"f")}static Some(t){return N.of(t)}static None(){return A.of()}get then(){const t=i(this,y,"f").then((t=>t===x?b.None():b.Some(t)));return t.then.bind(t)}onSome(t){return r.go((()=>n(this,void 0,void 0,(function*(){const r=yield i(this,y,"f");r!==x&&t(r)})))),new R(i(this,y,"f"))}onNone(t){return r.go((()=>n(this,void 0,void 0,(function*(){(yield i(this,y,"f"))===x&&t()})))),new R(i(this,y,"f"))}isSome(){return n(this,void 0,void 0,(function*(){return(yield i(this,y,"f"))!==x}))}isNone(){return n(this,void 0,void 0,(function*(){return(yield i(this,y,"f"))===x}))}orElse(t){const e=r.go((()=>n(this,void 0,void 0,(function*(){const r=yield i(this,y,"f");return r===x?t:r}))));return new R(e)}map(t){const e=r.go((()=>n(this,void 0,void 0,(function*(){const r=yield i(this,y,"f");return r===x?x:t(r)}))));return new R(e)}filter(t){const e=r.go((()=>n(this,void 0,void 0,(function*(){const r=yield i(this,y,"f");return r===x?x:t(r)?r:x}))));return new R(e)}get(){return n(this,void 0,void 0,(function*(){const t=yield i(this,y,"f");if(t===x)throw new Error("Cannot get value from None");return t}))}}y=new WeakMap;class A extends R{static of(){return new A}constructor(){super(Promise.resolve(x))}}class N extends R{static of(t){return new N(t)}constructor(t){super(Promise.resolve(t))}}function T(t,e){const o=r.go((()=>n(this,void 0,void 0,(function*(){const r=yield t();return e(r)?x:r}))));return new R(o)}function j(t,e){return new R(r.go((()=>n(this,void 0,void 0,(function*(){const r=yield t;return e(r)?x:r})))))}t.getError=function(t){try{t()}catch(t){return t}},t.getErrorAsync=function(t){return n(this,void 0,void 0,(function*(){try{yield t()}catch(t){return t}}))},t.getErrorAsyncIterable=function(t){var r,e,i,u;return n(this,void 0,void 0,(function*(){try{try{for(r=o(t);!(e=yield r.next()).done;){e.value}}catch(t){i={error:t}}finally{try{e&&!e.done&&(u=r.return)&&(yield u.call(r))}finally{if(i)throw i.error}}}catch(t){return t}}))},t.getErrorPromise=function(t){return n(this,void 0,void 0,(function*(){try{yield t}catch(t){return t}}))},t.getErrorResult=function(t){try{return[void 0,t()]}catch(t){return[t,void 0]}},t.getErrorResultAsync=function(t){return n(this,void 0,void 0,(function*(){try{return[void 0,yield t()]}catch(t){return[t,void 0]}}))},t.getErrorResultPromise=function(t){return n(this,void 0,void 0,(function*(){try{return[void 0,yield t]}catch(t){return[t,void 0]}}))},t.getFailure=function(t){try{return t(),[!1,void 0]}catch(t){return[!0,t]}},t.getFailureAsync=function(t){return n(this,void 0,void 0,(function*(){try{return yield t(),[!1,void 0]}catch(t){return[!0,t]}}))},t.getFailurePromise=c,t.getResult=function(t){try{return t()}catch(t){return}},t.getResultAsync=function(t){return n(this,void 0,void 0,(function*(){try{return yield t()}catch(t){return}}))},t.getResultError=function(t){try{return[t(),void 0]}catch(t){return[void 0,t]}},t.getResultErrorAsync=function(t){return n(this,void 0,void 0,(function*(){try{return[yield t(),void 0]}catch(t){return[void 0,t]}}))},t.getResultErrorPromise=function(t){return n(this,void 0,void 0,(function*(){try{return[yield t,void 0]}catch(t){return[void 0,t]}}))},t.getResultPromise=function(t){return n(this,void 0,void 0,(function*(){try{return yield t}catch(t){return}}))},t.getSuccess=function(t){try{return[!0,t()]}catch(t){return[!1,void 0]}},t.getSuccessAsync=function(t){return n(this,void 0,void 0,(function*(){try{return[!0,yield t()]}catch(t){return[!1,void 0]}}))},t.getSuccessPromise=s,t.isFailure=function(t){try{return t(),!1}catch(t){return!0}},t.isFailureAsync=function(t){return n(this,void 0,void 0,(function*(){try{return yield t(),!1}catch(t){return!0}}))},t.isFailurePromise=d,t.isSuccess=function(t){try{return t(),!0}catch(t){return!1}},t.isSuccessAsync=function(t){return n(this,void 0,void 0,(function*(){try{return yield t(),!0}catch(t){return!1}}))},t.isSuccessPromise=f,t.toOptional=k,t.toOptionalAsync=T,t.toOptionalAsyncPartial=function(t){return r=>T(r,t)},t.toOptionalPartial=function(t){return r=>k(r,t)},t.toOptionalPromise=j,t.toOptionalPromisePartial=function(t){return r=>j(r,t)},t.toResult=function(t){try{const r=t();return w.Ok(r)}catch(t){return w.Err(t)}},t.toResultAsync=function(t){try{const r=t();return new p(r)}catch(t){return p.Err(t)}},t.toResultPromise=function(t){return new p(t)},Object.defineProperty(t,"__esModule",{value:!0})}));
function e(t,r,n,e){return new(n||(n=Promise))((function(o,i){function u(t){try{c(e.next(t))}catch(t){i(t)}}function s(t){try{c(e.throw(t))}catch(t){i(t)}}function c(t){var r;t.done?o(t.value):(r=t.value,r instanceof n?r:new n((function(t){t(r)}))).then(u,s)}c((e=e.apply(t,r||[])).next())}))}function o(t){var r="function"==typeof Symbol&&Symbol.iterator,n=r&&t[r],e=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,n=t[Symbol.asyncIterator];return n?n.call(t):(t=o(t),r={},e("next"),e("throw"),e("return"),r[Symbol.asyncIterator]=function(){return this},r);function e(n){r[n]=t[n]&&function(r){return new Promise((function(e,o){(function(t,r,n,e){Promise.resolve(e).then((function(r){t({value:r,done:n})}),r)})(e,o,(r=t[n](r)).done,r.value)}))}}}function u(t,r,n,e){if("a"===n&&!e)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?t!==r||!e:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?e:"a"===n?e.call(t):e?e.value:r.get(t)}function s(t,r,n,e,o){if("m"===e)throw new TypeError("Private method is not writable");if("a"===e&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?t!==r||!o:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===e?o.call(t,n):o?o.value=n:r.set(t,n),n}function c(t){return e(this,void 0,void 0,(function*(){try{return[!0,yield t]}catch(t){return[!1,void 0]}}))}function f(t){return e(this,void 0,void 0,(function*(){try{return yield t,[!1,void 0]}catch(t){return[!0,t]}}))}function a(t){return e(this,void 0,void 0,(function*(){try{return yield t,!0}catch(t){return!1}}))}function d(t){return e(this,void 0,void 0,(function*(){try{return yield t,!1}catch(t){return!0}}))}var h,l,v,y,w;class m{static Ok(t){return g.of(t)}static Err(t){return p.of(t)}}class g extends m{constructor(t){super(),h.set(this,void 0),s(this,h,t,"f")}static of(t){return new g(t)}isOk(){return!0}isErr(){return!1}onOk(t){return t(u(this,h,"f")),g.of(u(this,h,"f"))}onErr(){return g.of(u(this,h,"f"))}orElse(){return g.of(u(this,h,"f"))}map(t){return g.of(t(u(this,h,"f")))}get(){return u(this,h,"f")}}h=new WeakMap;class p extends m{constructor(t){super(),l.set(this,void 0),s(this,l,t,"f")}static of(t){return new p(t)}isOk(){return!1}isErr(){return!0}onOk(){return p.of(u(this,l,"f"))}onErr(t){return t(u(this,l,"f")),p.of(u(this,l,"f"))}orElse(t){return g.of(t)}map(){return p.of(u(this,l,"f"))}get(){throw u(this,l,"f")}}l=new WeakMap;class E{constructor(t){v.set(this,void 0),s(this,v,Promise.resolve(t),"f")}static Ok(t){return b.of(t)}static Err(t){return P.of(t)}get then(){const t=u(this,v,"f").then((t=>m.Ok(t)),(t=>m.Err(t)));return t.then.bind(t)}onOk(t){return n.go((()=>e(this,void 0,void 0,(function*(){const[r,n]=yield c(u(this,v,"f"));r&&t(n)})))),new E(u(this,v,"f"))}onErr(t){return n.go((()=>e(this,void 0,void 0,(function*(){const[r,n]=yield f(u(this,v,"f"));r&&t(n)})))),new E(u(this,v,"f"))}isOk(){return e(this,void 0,void 0,(function*(){return yield a(u(this,v,"f"))}))}isErr(){return e(this,void 0,void 0,(function*(){return yield d(u(this,v,"f"))}))}orElse(t){const r=n.go((()=>e(this,void 0,void 0,(function*(){try{return yield u(this,v,"f")}catch(r){return t}}))));return new E(r)}map(t){const r=n.go((()=>e(this,void 0,void 0,(function*(){const r=yield u(this,v,"f");return t(r)}))));return new E(r)}get(){return e(this,void 0,void 0,(function*(){return yield u(this,v,"f")}))}}v=new WeakMap;class b extends E{static of(t){return new b(t)}constructor(t){super(Promise.resolve(t))}}class P extends E{static of(t){return new P(t)}constructor(t){super(Promise.reject(t))}}class S{static Some(t){return k.of(t)}static None(){return O.of()}}class k extends S{constructor(t){super(),y.set(this,void 0),s(this,y,t,"f")}static of(t){return new k(t)}isSome(){return!0}isNone(){return!1}onSome(t){return t(u(this,y,"f")),k.of(u(this,y,"f"))}onNone(){return k.of(u(this,y,"f"))}orElse(){return k.of(u(this,y,"f"))}map(t){return k.of(t(u(this,y,"f")))}filter(t){return t(u(this,y,"f"))?k.of(u(this,y,"f")):O.of()}get(){return u(this,y,"f")}}y=new WeakMap;class O extends S{static of(){return new O}constructor(){super()}isSome(){return!1}isNone(){return!0}onSome(){return O.of()}onNone(t){return t(),O.of()}orElse(t){return k.of(t)}map(){return O.of()}filter(){return O.of()}get(){throw new Error("Cannot get value from None")}}function x(t,r){const n=t();return r(n)?S.None():S.Some(n)}const R=Symbol();class A{constructor(t){w.set(this,void 0),s(this,w,Promise.resolve(t),"f")}static Some(t){return T.of(t)}static None(){return N.of()}get then(){const t=u(this,w,"f").then((t=>t===R?S.None():S.Some(t)));return t.then.bind(t)}onSome(t){return n.go((()=>e(this,void 0,void 0,(function*(){const r=yield u(this,w,"f");r!==R&&t(r)})))),new A(u(this,w,"f"))}onNone(t){return n.go((()=>e(this,void 0,void 0,(function*(){(yield u(this,w,"f"))===R&&t()})))),new A(u(this,w,"f"))}isSome(){return e(this,void 0,void 0,(function*(){return(yield u(this,w,"f"))!==R}))}isNone(){return e(this,void 0,void 0,(function*(){return(yield u(this,w,"f"))===R}))}orElse(t){const r=n.go((()=>e(this,void 0,void 0,(function*(){const r=yield u(this,w,"f");return r===R?t:r}))));return new A(r)}map(t){const r=n.go((()=>e(this,void 0,void 0,(function*(){const r=yield u(this,w,"f");return r===R?R:t(r)}))));return new A(r)}filter(t){const r=n.go((()=>e(this,void 0,void 0,(function*(){const r=yield u(this,w,"f");return r===R?R:t(r)?r:R}))));return new A(r)}get(){return e(this,void 0,void 0,(function*(){const t=yield u(this,w,"f");if(t===R)throw new Error("Cannot get value from None");return t}))}}w=new WeakMap;class N extends A{static of(){return new N}constructor(){super(Promise.resolve(R))}}class T extends A{static of(t){return new T(t)}constructor(t){super(Promise.resolve(t))}}function j(t,r){const o=n.go((()=>e(this,void 0,void 0,(function*(){const n=yield t();return r(n)?R:n}))));return new A(o)}function F(t,r){return new A(n.go((()=>e(this,void 0,void 0,(function*(){const n=yield t;return r(n)?R:n})))))}t.getError=function(t){try{t()}catch(t){return t}},t.getErrorAsync=function(t){return e(this,void 0,void 0,(function*(){try{yield t()}catch(t){return t}}))},t.getErrorAsyncIterable=function(t){var n,o,u,s;return e(this,void 0,void 0,(function*(){try{try{for(n=i(t);!(o=yield n.next()).done;){o.value;r.pass()}}catch(t){u={error:t}}finally{try{o&&!o.done&&(s=n.return)&&(yield s.call(n))}finally{if(u)throw u.error}}}catch(t){return t}}))},t.getErrorPromise=function(t){return e(this,void 0,void 0,(function*(){try{yield t}catch(t){return t}}))},t.getErrorResult=function(t){try{return[void 0,t()]}catch(t){return[t,void 0]}},t.getErrorResultAsync=function(t){return e(this,void 0,void 0,(function*(){try{return[void 0,yield t()]}catch(t){return[t,void 0]}}))},t.getErrorResultPromise=function(t){return e(this,void 0,void 0,(function*(){try{return[void 0,yield t]}catch(t){return[t,void 0]}}))},t.getFailure=function(t){try{return t(),[!1,void 0]}catch(t){return[!0,t]}},t.getFailureAsync=function(t){return e(this,void 0,void 0,(function*(){try{return yield t(),[!1,void 0]}catch(t){return[!0,t]}}))},t.getFailurePromise=f,t.getResult=function(t){try{return t()}catch(t){return}},t.getResultAsync=function(t){return e(this,void 0,void 0,(function*(){try{return yield t()}catch(t){return}}))},t.getResultError=function(t){try{return[t(),void 0]}catch(t){return[void 0,t]}},t.getResultErrorAsync=function(t){return e(this,void 0,void 0,(function*(){try{return[yield t(),void 0]}catch(t){return[void 0,t]}}))},t.getResultErrorPromise=function(t){return e(this,void 0,void 0,(function*(){try{return[yield t,void 0]}catch(t){return[void 0,t]}}))},t.getResultPromise=function(t){return e(this,void 0,void 0,(function*(){try{return yield t}catch(t){return}}))},t.getSuccess=function(t){try{return[!0,t()]}catch(t){return[!1,void 0]}},t.getSuccessAsync=function(t){return e(this,void 0,void 0,(function*(){try{return[!0,yield t()]}catch(t){return[!1,void 0]}}))},t.getSuccessPromise=c,t.isFailure=function(t){try{return t(),!1}catch(t){return!0}},t.isFailureAsync=function(t){return e(this,void 0,void 0,(function*(){try{return yield t(),!1}catch(t){return!0}}))},t.isFailurePromise=d,t.isSuccess=function(t){try{return t(),!0}catch(t){return!1}},t.isSuccessAsync=function(t){return e(this,void 0,void 0,(function*(){try{return yield t(),!0}catch(t){return!1}}))},t.isSuccessPromise=a,t.toOptional=x,t.toOptionalAsync=j,t.toOptionalAsyncPartial=function(t){return r=>j(r,t)},t.toOptionalPartial=function(t){return r=>x(r,t)},t.toOptionalPromise=F,t.toOptionalPromisePartial=function(t){return r=>F(r,t)},t.toResult=function(t){try{const r=t();return m.Ok(r)}catch(t){return m.Err(t)}},t.toResultAsync=function(t){try{const r=t();return new E(r)}catch(t){return E.Err(t)}},t.toResultPromise=function(t){return new E(t)},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@blackglory/go')) :
typeof define === 'function' && define.amd ? define(['exports', '@blackglory/go'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReturnStyle = {}, global.go));
})(this, (function (exports, go) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@blackglory/pass'), require('@blackglory/go')) :
typeof define === 'function' && define.amd ? define(['exports', '@blackglory/pass', '@blackglory/go'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReturnStyle = {}, global.pass, global.go));
})(this, (function (exports, pass, go) { 'use strict';

@@ -246,3 +246,5 @@ function getErrorResult(fn) {

try {
for await (const _ of iterable) { }
for await (const _ of iterable) {
pass.pass();
}
}

@@ -249,0 +251,0 @@ catch (promiseError) {

@@ -1,2 +0,2 @@

!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@blackglory/go")):"function"==typeof define&&define.amd?define(["exports","@blackglory/go"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnStyle={},t.go)}(this,(function(t,r){"use strict";async function e(t){try{return[!0,await t]}catch(t){return[!1,void 0]}}async function n(t){try{return await t,[!1,void 0]}catch(t){return[!0,t]}}async function o(t){try{return await t,!0}catch(t){return!1}}async function s(t){try{return await t,!1}catch(t){return!0}}
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@blackglory/pass"),require("@blackglory/go")):"function"==typeof define&&define.amd?define(["exports","@blackglory/pass","@blackglory/go"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnStyle={},t.pass,t.go)}(this,(function(t,r,e){"use strict";async function n(t){try{return[!0,await t]}catch(t){return[!1,void 0]}}async function o(t){try{return await t,[!1,void 0]}catch(t){return[!0,t]}}async function s(t){try{return await t,!0}catch(t){return!1}}async function i(t){try{return await t,!1}catch(t){return!0}}
/*! *****************************************************************************

@@ -16,3 +16,3 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
function i(t,r,e,n){if("a"===e&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?t!==r||!n:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?n:"a"===e?n.call(t):n?n.value:r.get(t)}function c(t,r,e,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?t!==r||!o:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,e):o?o.value=e:r.set(t,e),e}var a,u,f,h,y;class w{static Ok(t){return l.of(t)}static Err(t){return d.of(t)}}class l extends w{constructor(t){super(),a.set(this,void 0),c(this,a,t,"f")}static of(t){return new l(t)}isOk(){return!0}isErr(){return!1}onOk(t){return t(i(this,a,"f")),l.of(i(this,a,"f"))}onErr(){return l.of(i(this,a,"f"))}orElse(){return l.of(i(this,a,"f"))}map(t){return l.of(t(i(this,a,"f")))}get(){return i(this,a,"f")}}a=new WeakMap;class d extends w{constructor(t){super(),u.set(this,void 0),c(this,u,t,"f")}static of(t){return new d(t)}isOk(){return!1}isErr(){return!0}onOk(){return d.of(i(this,u,"f"))}onErr(t){return t(i(this,u,"f")),d.of(i(this,u,"f"))}orElse(t){return l.of(t)}map(){return d.of(i(this,u,"f"))}get(){throw i(this,u,"f")}}u=new WeakMap;class g{constructor(t){f.set(this,void 0),c(this,f,Promise.resolve(t),"f")}static Ok(t){return m.of(t)}static Err(t){return p.of(t)}get then(){const t=i(this,f,"f").then((t=>w.Ok(t)),(t=>w.Err(t)));return t.then.bind(t)}onOk(t){return r.go((async()=>{const[r,n]=await e(i(this,f,"f"));r&&t(n)})),new g(i(this,f,"f"))}onErr(t){return r.go((async()=>{const[r,e]=await n(i(this,f,"f"));r&&t(e)})),new g(i(this,f,"f"))}async isOk(){return await o(i(this,f,"f"))}async isErr(){return await s(i(this,f,"f"))}orElse(t){const e=r.go((async()=>{try{return await i(this,f,"f")}catch(r){return t}}));return new g(e)}map(t){const e=r.go((async()=>{const r=await i(this,f,"f");return t(r)}));return new g(e)}async get(){return await i(this,f,"f")}}f=new WeakMap;class m extends g{static of(t){return new m(t)}constructor(t){super(Promise.resolve(t))}}class p extends g{static of(t){return new p(t)}constructor(t){super(Promise.reject(t))}}class v{static Some(t){return E.of(t)}static None(){return P.of()}}class E extends v{constructor(t){super(),h.set(this,void 0),c(this,h,t,"f")}static of(t){return new E(t)}isSome(){return!0}isNone(){return!1}onSome(t){return t(i(this,h,"f")),E.of(i(this,h,"f"))}onNone(){return E.of(i(this,h,"f"))}orElse(){return E.of(i(this,h,"f"))}map(t){return E.of(t(i(this,h,"f")))}filter(t){return t(i(this,h,"f"))?E.of(i(this,h,"f")):P.of()}get(){return i(this,h,"f")}}h=new WeakMap;class P extends v{static of(){return new P}constructor(){super()}isSome(){return!1}isNone(){return!0}onSome(){return P.of()}onNone(t){return t(),P.of()}orElse(t){return E.of(t)}map(){return P.of()}filter(){return P.of()}get(){throw new Error("Cannot get value from None")}}function S(t,r){const e=t();return r(e)?v.None():v.Some(e)}const k=Symbol();class O{constructor(t){y.set(this,void 0),c(this,y,Promise.resolve(t),"f")}static Some(t){return R.of(t)}static None(){return b.of()}get then(){const t=i(this,y,"f").then((t=>t===k?v.None():v.Some(t)));return t.then.bind(t)}onSome(t){return r.go((async()=>{const r=await i(this,y,"f");r!==k&&t(r)})),new O(i(this,y,"f"))}onNone(t){return r.go((async()=>{await i(this,y,"f")===k&&t()})),new O(i(this,y,"f"))}async isSome(){return await i(this,y,"f")!==k}async isNone(){return await i(this,y,"f")===k}orElse(t){const e=r.go((async()=>{const r=await i(this,y,"f");return r===k?t:r}));return new O(e)}map(t){const e=r.go((async()=>{const r=await i(this,y,"f");return r===k?k:t(r)}));return new O(e)}filter(t){const e=r.go((async()=>{const r=await i(this,y,"f");return r===k?k:t(r)?r:k}));return new O(e)}async get(){const t=await i(this,y,"f");if(t===k)throw new Error("Cannot get value from None");return t}}y=new WeakMap;class b extends O{static of(){return new b}constructor(){super(Promise.resolve(k))}}class R extends O{static of(t){return new R(t)}constructor(t){super(Promise.resolve(t))}}function A(t,e){const n=r.go((async()=>{const r=await t();return e(r)?k:r}));return new O(n)}function N(t,e){return new O(r.go((async()=>{const r=await t;return e(r)?k:r})))}t.getError=function(t){try{t()}catch(t){return t}},t.getErrorAsync=async function(t){try{await t()}catch(t){return t}},t.getErrorAsyncIterable=async function(t){try{for await(const r of t);}catch(t){return t}},t.getErrorPromise=async function(t){try{await t}catch(t){return t}},t.getErrorResult=function(t){try{return[void 0,t()]}catch(t){return[t,void 0]}},t.getErrorResultAsync=async function(t){try{return[void 0,await t()]}catch(t){return[t,void 0]}},t.getErrorResultPromise=async function(t){try{return[void 0,await t]}catch(t){return[t,void 0]}},t.getFailure=function(t){try{return t(),[!1,void 0]}catch(t){return[!0,t]}},t.getFailureAsync=async function(t){try{return await t(),[!1,void 0]}catch(t){return[!0,t]}},t.getFailurePromise=n,t.getResult=function(t){try{return t()}catch(t){return}},t.getResultAsync=async function(t){try{return await t()}catch(t){return}},t.getResultError=function(t){try{return[t(),void 0]}catch(t){return[void 0,t]}},t.getResultErrorAsync=async function(t){try{return[await t(),void 0]}catch(t){return[void 0,t]}},t.getResultErrorPromise=async function(t){try{return[await t,void 0]}catch(t){return[void 0,t]}},t.getResultPromise=async function(t){try{return await t}catch(t){return}},t.getSuccess=function(t){try{return[!0,t()]}catch(t){return[!1,void 0]}},t.getSuccessAsync=async function(t){try{return[!0,await t()]}catch(t){return[!1,void 0]}},t.getSuccessPromise=e,t.isFailure=function(t){try{return t(),!1}catch(t){return!0}},t.isFailureAsync=async function(t){try{return await t(),!1}catch(t){return!0}},t.isFailurePromise=s,t.isSuccess=function(t){try{return t(),!0}catch(t){return!1}},t.isSuccessAsync=async function(t){try{return await t(),!0}catch(t){return!1}},t.isSuccessPromise=o,t.toOptional=S,t.toOptionalAsync=A,t.toOptionalAsyncPartial=function(t){return r=>A(r,t)},t.toOptionalPartial=function(t){return r=>S(r,t)},t.toOptionalPromise=N,t.toOptionalPromisePartial=function(t){return r=>N(r,t)},t.toResult=function(t){try{const r=t();return w.Ok(r)}catch(t){return w.Err(t)}},t.toResultAsync=function(t){try{const r=t();return new g(r)}catch(t){return g.Err(t)}},t.toResultPromise=function(t){return new g(t)},Object.defineProperty(t,"__esModule",{value:!0})}));
function c(t,r,e,n){if("a"===e&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?t!==r||!n:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?n:"a"===e?n.call(t):n?n.value:r.get(t)}function a(t,r,e,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?t!==r||!o:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,e):o?o.value=e:r.set(t,e),e}var u,f,h,y,l;class w{static Ok(t){return d.of(t)}static Err(t){return g.of(t)}}class d extends w{constructor(t){super(),u.set(this,void 0),a(this,u,t,"f")}static of(t){return new d(t)}isOk(){return!0}isErr(){return!1}onOk(t){return t(c(this,u,"f")),d.of(c(this,u,"f"))}onErr(){return d.of(c(this,u,"f"))}orElse(){return d.of(c(this,u,"f"))}map(t){return d.of(t(c(this,u,"f")))}get(){return c(this,u,"f")}}u=new WeakMap;class g extends w{constructor(t){super(),f.set(this,void 0),a(this,f,t,"f")}static of(t){return new g(t)}isOk(){return!1}isErr(){return!0}onOk(){return g.of(c(this,f,"f"))}onErr(t){return t(c(this,f,"f")),g.of(c(this,f,"f"))}orElse(t){return d.of(t)}map(){return g.of(c(this,f,"f"))}get(){throw c(this,f,"f")}}f=new WeakMap;class m{constructor(t){h.set(this,void 0),a(this,h,Promise.resolve(t),"f")}static Ok(t){return p.of(t)}static Err(t){return v.of(t)}get then(){const t=c(this,h,"f").then((t=>w.Ok(t)),(t=>w.Err(t)));return t.then.bind(t)}onOk(t){return e.go((async()=>{const[r,e]=await n(c(this,h,"f"));r&&t(e)})),new m(c(this,h,"f"))}onErr(t){return e.go((async()=>{const[r,e]=await o(c(this,h,"f"));r&&t(e)})),new m(c(this,h,"f"))}async isOk(){return await s(c(this,h,"f"))}async isErr(){return await i(c(this,h,"f"))}orElse(t){const r=e.go((async()=>{try{return await c(this,h,"f")}catch(r){return t}}));return new m(r)}map(t){const r=e.go((async()=>{const r=await c(this,h,"f");return t(r)}));return new m(r)}async get(){return await c(this,h,"f")}}h=new WeakMap;class p extends m{static of(t){return new p(t)}constructor(t){super(Promise.resolve(t))}}class v extends m{static of(t){return new v(t)}constructor(t){super(Promise.reject(t))}}class E{static Some(t){return P.of(t)}static None(){return k.of()}}class P extends E{constructor(t){super(),y.set(this,void 0),a(this,y,t,"f")}static of(t){return new P(t)}isSome(){return!0}isNone(){return!1}onSome(t){return t(c(this,y,"f")),P.of(c(this,y,"f"))}onNone(){return P.of(c(this,y,"f"))}orElse(){return P.of(c(this,y,"f"))}map(t){return P.of(t(c(this,y,"f")))}filter(t){return t(c(this,y,"f"))?P.of(c(this,y,"f")):k.of()}get(){return c(this,y,"f")}}y=new WeakMap;class k extends E{static of(){return new k}constructor(){super()}isSome(){return!1}isNone(){return!0}onSome(){return k.of()}onNone(t){return t(),k.of()}orElse(t){return P.of(t)}map(){return k.of()}filter(){return k.of()}get(){throw new Error("Cannot get value from None")}}function S(t,r){const e=t();return r(e)?E.None():E.Some(e)}const b=Symbol();class O{constructor(t){l.set(this,void 0),a(this,l,Promise.resolve(t),"f")}static Some(t){return A.of(t)}static None(){return R.of()}get then(){const t=c(this,l,"f").then((t=>t===b?E.None():E.Some(t)));return t.then.bind(t)}onSome(t){return e.go((async()=>{const r=await c(this,l,"f");r!==b&&t(r)})),new O(c(this,l,"f"))}onNone(t){return e.go((async()=>{await c(this,l,"f")===b&&t()})),new O(c(this,l,"f"))}async isSome(){return await c(this,l,"f")!==b}async isNone(){return await c(this,l,"f")===b}orElse(t){const r=e.go((async()=>{const r=await c(this,l,"f");return r===b?t:r}));return new O(r)}map(t){const r=e.go((async()=>{const r=await c(this,l,"f");return r===b?b:t(r)}));return new O(r)}filter(t){const r=e.go((async()=>{const r=await c(this,l,"f");return r===b?b:t(r)?r:b}));return new O(r)}async get(){const t=await c(this,l,"f");if(t===b)throw new Error("Cannot get value from None");return t}}l=new WeakMap;class R extends O{static of(){return new R}constructor(){super(Promise.resolve(b))}}class A extends O{static of(t){return new A(t)}constructor(t){super(Promise.resolve(t))}}function N(t,r){const n=e.go((async()=>{const e=await t();return r(e)?b:e}));return new O(n)}function x(t,r){return new O(e.go((async()=>{const e=await t;return r(e)?b:e})))}t.getError=function(t){try{t()}catch(t){return t}},t.getErrorAsync=async function(t){try{await t()}catch(t){return t}},t.getErrorAsyncIterable=async function(t){try{for await(const e of t)r.pass()}catch(t){return t}},t.getErrorPromise=async function(t){try{await t}catch(t){return t}},t.getErrorResult=function(t){try{return[void 0,t()]}catch(t){return[t,void 0]}},t.getErrorResultAsync=async function(t){try{return[void 0,await t()]}catch(t){return[t,void 0]}},t.getErrorResultPromise=async function(t){try{return[void 0,await t]}catch(t){return[t,void 0]}},t.getFailure=function(t){try{return t(),[!1,void 0]}catch(t){return[!0,t]}},t.getFailureAsync=async function(t){try{return await t(),[!1,void 0]}catch(t){return[!0,t]}},t.getFailurePromise=o,t.getResult=function(t){try{return t()}catch(t){return}},t.getResultAsync=async function(t){try{return await t()}catch(t){return}},t.getResultError=function(t){try{return[t(),void 0]}catch(t){return[void 0,t]}},t.getResultErrorAsync=async function(t){try{return[await t(),void 0]}catch(t){return[void 0,t]}},t.getResultErrorPromise=async function(t){try{return[await t,void 0]}catch(t){return[void 0,t]}},t.getResultPromise=async function(t){try{return await t}catch(t){return}},t.getSuccess=function(t){try{return[!0,t()]}catch(t){return[!1,void 0]}},t.getSuccessAsync=async function(t){try{return[!0,await t()]}catch(t){return[!1,void 0]}},t.getSuccessPromise=n,t.isFailure=function(t){try{return t(),!1}catch(t){return!0}},t.isFailureAsync=async function(t){try{return await t(),!1}catch(t){return!0}},t.isFailurePromise=i,t.isSuccess=function(t){try{return t(),!0}catch(t){return!1}},t.isSuccessAsync=async function(t){try{return await t(),!0}catch(t){return!1}},t.isSuccessPromise=s,t.toOptional=S,t.toOptionalAsync=N,t.toOptionalAsyncPartial=function(t){return r=>N(r,t)},t.toOptionalPartial=function(t){return r=>S(r,t)},t.toOptionalPromise=x,t.toOptionalPromisePartial=function(t){return r=>x(r,t)},t.toResult=function(t){try{const r=t();return w.Ok(r)}catch(t){return w.Err(t)}},t.toResultAsync=function(t){try{const r=t();return new m(r)}catch(t){return m.Err(t)}},t.toResultPromise=function(t){return new m(t)},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map

@@ -20,2 +20,3 @@ "use strict";

exports.getErrorAsyncIterable = void 0;
const pass_1 = require("@blackglory/pass");
function getErrorAsyncIterable(iterable) {

@@ -29,2 +30,3 @@ var iterable_1, iterable_1_1;

const _ = iterable_1_1.value;
(0, pass_1.pass)();
}

@@ -31,0 +33,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getErrorAsyncIterable = void 0;
const pass_1 = require("@blackglory/pass");
async function getErrorAsyncIterable(iterable) {
try {
for await (const _ of iterable) { }
for await (const _ of iterable) {
(0, pass_1.pass)();
}
}

@@ -8,0 +11,0 @@ catch (promiseError) {

{
"name": "return-style",
"version": "0.12.4",
"version": "0.12.5",
"description": "Non-intrusively convert the result of any function or promise to the user's desired style.",

@@ -35,4 +35,4 @@ "keywords": [

"lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
"test": "jest --config jest.config.js",
"test:coverage": "jest --coverage --config jest.config.js",
"test": "jest --runInBand --config jest.config.js",
"test:coverage": "jest --coverage --runInBand --config jest.config.js",
"prepublishOnly": "run-s clean build bundle",

@@ -60,29 +60,30 @@ "clean": "run-p clean:*",

"@blackglory/jest-matchers": "^0.1.21",
"@blackglory/types": "^0.5.1",
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
"@rollup/plugin-typescript": "^8.2.5",
"@types/jest": "^27.0.2",
"@blackglory/types": "^0.5.2",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@rollup/plugin-typescript": "^8.3.0",
"@types/jest": "^27.0.3",
"@types/node": "^14.14.35",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"eslint": "^8.4.0",
"husky": "4",
"iterable-operator": "^0.14.4",
"jest": "^27.2.5",
"jest-extended": "^1.0.0",
"jest": "^27.4.3",
"jest-extended": "^1.2.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"rollup": "^2.58.0",
"rollup": "^2.60.2",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"standard-version": "^9.3.1",
"ts-jest": "^27.0.5",
"standard-version": "^9.3.2",
"ts-jest": "^27.0.7",
"tscpaths": "^0.0.9",
"tslib": "^2.3.1",
"typescript": "^4.4.4"
"typescript": "^4.5.2"
},
"dependencies": {
"@blackglory/go": "^0.1.0"
"@blackglory/go": "^0.1.1",
"@blackglory/pass": "^0.1.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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

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

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

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