return-style
Advanced tools
Comparing version 0.9.2 to 0.10.0
@@ -377,10 +377,9 @@ (function (global, factory) { | ||
// Don't try to refactor it, You will lose to TypeScript. | ||
var _value, _value_1; | ||
class Result { | ||
static of(value) { | ||
return new Ok(value); | ||
static Ok(value) { | ||
return Ok.of(value); | ||
} | ||
static ofErr(error) { | ||
return new Err(error); | ||
static Err(error) { | ||
return Err.of(error); | ||
} | ||
@@ -394,2 +393,5 @@ } | ||
} | ||
static of(value) { | ||
return new Ok(value); | ||
} | ||
*[(_value = new WeakMap(), Symbol.iterator)]() { | ||
@@ -406,12 +408,12 @@ yield __classPrivateFieldGet(this, _value); | ||
callback(__classPrivateFieldGet(this, _value)); | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
onErr() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
orElse() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
map(mapper) { | ||
return Result.of(mapper(__classPrivateFieldGet(this, _value))); | ||
map(fn) { | ||
return Ok.of(fn(__classPrivateFieldGet(this, _value))); | ||
} | ||
@@ -428,2 +430,5 @@ get() { | ||
} | ||
static of(error) { | ||
return new Err(error); | ||
} | ||
*[(_value_1 = new WeakMap(), Symbol.iterator)]() { } | ||
@@ -437,13 +442,13 @@ isOk() { | ||
onOk() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
onErr(callback) { | ||
callback(__classPrivateFieldGet(this, _value_1)); | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
orElse(defaultValue) { | ||
return Result.of(defaultValue); | ||
return Ok.of(defaultValue); | ||
} | ||
map() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
@@ -458,6 +463,6 @@ get() { | ||
const result = fn(); | ||
return Result.of(result); | ||
return Result.Ok(result); | ||
} | ||
catch (e) { | ||
return Result.ofErr(e); | ||
return Result.Err(e); | ||
} | ||
@@ -472,7 +477,7 @@ } | ||
} | ||
static of(value) { | ||
return new AsyncOk(value); | ||
static Ok(value) { | ||
return AsyncOk.of(value); | ||
} | ||
static ofErr(error) { | ||
return new AsyncErr(error); | ||
static Err(error) { | ||
return AsyncErr.of(error); | ||
} | ||
@@ -535,2 +540,5 @@ [(_promise = new WeakMap(), Symbol.asyncIterator)]() { | ||
class AsyncOk extends AsyncResult { | ||
static of(value) { | ||
return new AsyncOk(value); | ||
} | ||
constructor(value) { | ||
@@ -541,2 +549,5 @@ super(Promise.resolve(value)); | ||
class AsyncErr extends AsyncResult { | ||
static of(value) { | ||
return new AsyncErr(value); | ||
} | ||
constructor(err) { | ||
@@ -553,3 +564,3 @@ super(Promise.reject(err)); | ||
catch (e) { | ||
return AsyncResult.ofErr(e); | ||
return AsyncResult.Err(e); | ||
} | ||
@@ -562,10 +573,9 @@ } | ||
// Don't try to refactor it, You will lose to TypeScript. | ||
var _value$1; | ||
class Optional { | ||
static of(value) { | ||
return new Some(value); | ||
static Some(value) { | ||
return Some.of(value); | ||
} | ||
static ofNone() { | ||
return new None(); | ||
static None() { | ||
return None.of(); | ||
} | ||
@@ -579,2 +589,5 @@ } | ||
} | ||
static of(value) { | ||
return new Some(value); | ||
} | ||
*[(_value$1 = new WeakMap(), Symbol.iterator)]() { | ||
@@ -591,19 +604,19 @@ yield __classPrivateFieldGet(this, _value$1); | ||
callback(__classPrivateFieldGet(this, _value$1)); | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
onNone() { | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
orElse() { | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
map(mapper) { | ||
return Optional.of(mapper(__classPrivateFieldGet(this, _value$1))); | ||
return Some.of(mapper(__classPrivateFieldGet(this, _value$1))); | ||
} | ||
filter(predicate) { | ||
if (predicate(__classPrivateFieldGet(this, _value$1))) { | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
else { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -616,2 +629,8 @@ } | ||
class None extends Optional { | ||
static of() { | ||
return new None(); | ||
} | ||
constructor() { | ||
super(); | ||
} | ||
*[Symbol.iterator]() { } | ||
@@ -624,17 +643,17 @@ isSome() { | ||
} | ||
onSome(_) { | ||
return Optional.ofNone(); | ||
onSome() { | ||
return None.of(); | ||
} | ||
onNone(callback) { | ||
callback(); | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
orElse(defaultValue) { | ||
return Optional.of(defaultValue); | ||
return Some.of(defaultValue); | ||
} | ||
map() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
filter() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -652,6 +671,6 @@ get() { | ||
if (isNone(result)) { | ||
return Optional.ofNone(); | ||
return Optional.None(); | ||
} | ||
else { | ||
return Optional.of(result); | ||
return Optional.Some(result); | ||
} | ||
@@ -661,3 +680,3 @@ } | ||
var _promise$1; | ||
const None$1 = Symbol(); | ||
const Nil = Symbol(); | ||
class AsyncOptional { | ||
@@ -668,7 +687,7 @@ constructor(promise) { | ||
} | ||
static of(value) { | ||
return new AsyncSome(value); | ||
static Some(value) { | ||
return AsyncSome.of(value); | ||
} | ||
static ofNone() { | ||
return new AsyncNone(); | ||
static None() { | ||
return AsyncNone.of(); | ||
} | ||
@@ -678,3 +697,3 @@ [(_promise$1 = new WeakMap(), Symbol.asyncIterator)]() { | ||
const result = yield __await(__classPrivateFieldGet(this, _promise$1)); | ||
if (result !== None$1) | ||
if (result !== Nil) | ||
yield yield __await(result); | ||
@@ -686,3 +705,3 @@ }); | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
if (result !== None$1) | ||
if (result !== Nil) | ||
callback(result); | ||
@@ -695,3 +714,3 @@ }))(); | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
if (result === Nil) | ||
callback(); | ||
@@ -704,3 +723,3 @@ }))(); | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
return result !== None$1; | ||
return result !== Nil; | ||
}); | ||
@@ -711,3 +730,3 @@ } | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
return result === None$1; | ||
return result === Nil; | ||
}); | ||
@@ -718,3 +737,3 @@ } | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
if (result === Nil) | ||
return defaultValue; | ||
@@ -727,4 +746,4 @@ return result; | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
return None$1; | ||
if (result === Nil) | ||
return Nil; | ||
return mapper(result); | ||
@@ -736,7 +755,7 @@ }))()); | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
return None$1; | ||
if (result === Nil) | ||
return Nil; | ||
if (predicate(result)) | ||
return result; | ||
return None$1; | ||
return Nil; | ||
}))()); | ||
@@ -747,3 +766,3 @@ } | ||
const result = yield __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
if (result === Nil) | ||
throw new Error('Cannot get value from None'); | ||
@@ -755,7 +774,13 @@ return result; | ||
class AsyncNone extends AsyncOptional { | ||
static of() { | ||
return new AsyncNone(); | ||
} | ||
constructor() { | ||
super(Promise.resolve(None$1)); | ||
super(Promise.resolve(Nil)); | ||
} | ||
} | ||
class AsyncSome extends AsyncOptional { | ||
static of(value) { | ||
return new AsyncSome(value); | ||
} | ||
constructor(value) { | ||
@@ -773,3 +798,3 @@ super(Promise.resolve(value)); | ||
if (isNone(result)) | ||
return None$1; | ||
return Nil; | ||
return result; | ||
@@ -776,0 +801,0 @@ }))()); |
@@ -16,3 +16,3 @@ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnStyle={})}(this,(function(t){"use strict"; | ||
***************************************************************************** */ | ||
function r(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 n(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 e(t){return this instanceof e?(this.v=t,this):new e(t)}function o(t,r,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,i=n.apply(t,r||[]),u=[];return o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o;function s(t){i[t]&&(o[t]=function(r){return new Promise((function(n,e){u.push([t,r,n,e])>1||c(t,r)}))})}function c(t,r){try{(n=i[t](r)).value instanceof e?Promise.resolve(n.value.v).then(f,d):h(u[0][2],n)}catch(t){h(u[0][3],t)}var n}function f(t){c("next",t)}function d(t){c("throw",t)}function h(t,r){t(r),u.shift(),u.length&&c(u[0][0],u[0][1])}}function i(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,e=t[Symbol.asyncIterator];return e?e.call(t):(t=n(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 u(t,r){if(!r.has(t))throw new TypeError("attempted to get private field on non-instance");return r.get(t)}function s(t,r,n){if(!r.has(t))throw new TypeError("attempted to set private field on non-instance");return r.set(t,n),n}function c(t){return r(this,void 0,void 0,(function*(){try{return[!0,yield t]}catch(t){return[!1,void 0]}}))}function f(t){return r(this,void 0,void 0,(function*(){try{return yield t,[!1,void 0]}catch(t){return[!0,t]}}))}function d(t){return r(this,void 0,void 0,(function*(){try{return yield t,!0}catch(t){return!1}}))}function h(t){return r(this,void 0,void 0,(function*(){try{return yield t,!1}catch(t){return!0}}))}var a,l,y,v,m;class w{static of(t){return new p(t)}static ofErr(t){return new E(t)}}class p extends w{constructor(t){super(),a.set(this,void 0),s(this,a,t)}*[(a=new WeakMap,Symbol.iterator)](){yield u(this,a)}isOk(){return!0}isErr(){return!1}onOk(t){return t(u(this,a)),w.of(u(this,a))}onErr(){return w.of(u(this,a))}orElse(){return w.of(u(this,a))}map(t){return w.of(t(u(this,a)))}get(){return u(this,a)}}class E extends w{constructor(t){super(),l.set(this,void 0),s(this,l,t)}*[(l=new WeakMap,Symbol.iterator)](){}isOk(){return!1}isErr(){return!0}onOk(){return w.ofErr(u(this,l))}onErr(t){return t(u(this,l)),w.ofErr(u(this,l))}orElse(t){return w.of(t)}map(){return w.ofErr(u(this,l))}get(){throw u(this,l)}}class g{constructor(t){y.set(this,void 0),s(this,y,t)}static of(t){return new S(t)}static ofErr(t){return new b(t)}[(y=new WeakMap,Symbol.asyncIterator)](){return o(this,arguments,(function*(){const[t,r]=yield e(c(u(this,y)));t&&(yield yield e(r))}))}onOk(t){return(()=>{r(this,void 0,void 0,(function*(){const[r,n]=yield c(u(this,y));r&&t(n)}))})(),new g(u(this,y))}onErr(t){return(()=>{r(this,void 0,void 0,(function*(){const[r,n]=yield f(u(this,y));r&&t(n)}))})(),new g(u(this,y))}isOk(){return r(this,void 0,void 0,(function*(){return yield d(u(this,y))}))}isErr(){return r(this,void 0,void 0,(function*(){return yield h(u(this,y))}))}orElse(t){return new g((()=>r(this,void 0,void 0,(function*(){try{return yield u(this,y)}catch(r){return t}})))())}map(t){return new g((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,y);return t(r)})))())}get(){return r(this,void 0,void 0,(function*(){return yield u(this,y)}))}}class S extends g{constructor(t){super(Promise.resolve(t))}}class b extends g{constructor(t){super(Promise.reject(t))}}class P{static of(t){return new x(t)}static ofNone(){return new N}}class x extends P{constructor(t){super(),v.set(this,void 0),s(this,v,t)}*[(v=new WeakMap,Symbol.iterator)](){yield u(this,v)}isSome(){return!0}isNone(){return!1}onSome(t){return t(u(this,v)),P.of(u(this,v))}onNone(){return P.of(u(this,v))}orElse(){return P.of(u(this,v))}map(t){return P.of(t(u(this,v)))}filter(t){return t(u(this,v))?P.of(u(this,v)):P.ofNone()}get(){return u(this,v)}}class N extends P{*[Symbol.iterator](){}isSome(){return!1}isNone(){return!0}onSome(t){return P.ofNone()}onNone(t){return t(),P.ofNone()}orElse(t){return P.of(t)}map(){return P.ofNone()}filter(){return P.ofNone()}get(){throw new Error("Cannot get value from None")}}function R(t,r){const n=t();return r(n)?P.ofNone():P.of(n)}const O=Symbol();class k{constructor(t){m.set(this,void 0),s(this,m,t)}static of(t){return new I(t)}static ofNone(){return new A}[(m=new WeakMap,Symbol.asyncIterator)](){return o(this,arguments,(function*(){const t=yield e(u(this,m));t!==O&&(yield yield e(t))}))}onSome(t){return(()=>{r(this,void 0,void 0,(function*(){const r=yield u(this,m);r!==O&&t(r)}))})(),new k(u(this,m))}onNone(t){return(()=>{r(this,void 0,void 0,(function*(){(yield u(this,m))===O&&t()}))})(),new k(u(this,m))}isSome(){return r(this,void 0,void 0,(function*(){return(yield u(this,m))!==O}))}isNone(){return r(this,void 0,void 0,(function*(){return(yield u(this,m))===O}))}orElse(t){return new k((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,m);return r===O?t:r})))())}map(t){return new k((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,m);return r===O?O:t(r)})))())}filter(t){return new k((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,m);return r===O?O:t(r)?r:O})))())}get(){return r(this,void 0,void 0,(function*(){const t=yield u(this,m);if(t===O)throw new Error("Cannot get value from None");return t}))}}class A extends k{constructor(){super(Promise.resolve(O))}}class I extends k{constructor(t){super(Promise.resolve(t))}}function T(t,n){return new k((()=>r(this,void 0,void 0,(function*(){const r=yield t;return n(r)?O:r})))())}t.getError=function(t){try{t()}catch(t){return t}},t.getErrorAsync=function(t){return r(this,void 0,void 0,(function*(){try{yield t()}catch(t){return t}}))},t.getErrorAsyncIterable=function(t){var n,e,o,u;return r(this,void 0,void 0,(function*(){try{try{for(n=i(t);!(e=yield n.next()).done;){e.value}}catch(t){o={error:t}}finally{try{e&&!e.done&&(u=n.return)&&(yield u.call(n))}finally{if(o)throw o.error}}}catch(t){return t}}))},t.getErrorPromise=function(t){return r(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 r(this,void 0,void 0,(function*(){try{return[void 0,yield t()]}catch(t){return[t,void 0]}}))},t.getErrorResultPromise=function(t){return r(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 r(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 r(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 r(this,void 0,void 0,(function*(){try{return[yield t(),void 0]}catch(t){return[void 0,t]}}))},t.getResultErrorPromise=function(t){return r(this,void 0,void 0,(function*(){try{return[yield t,void 0]}catch(t){return[void 0,t]}}))},t.getResultPromise=function(t){return r(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 r(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 r(this,void 0,void 0,(function*(){try{return yield t(),!1}catch(t){return!0}}))},t.isFailurePromise=h,t.isSuccess=function(t){try{return t(),!0}catch(t){return!1}},t.isSuccessAsync=function(t){return r(this,void 0,void 0,(function*(){try{return yield t(),!0}catch(t){return!1}}))},t.isSuccessPromise=d,t.toOptional=R,t.toOptionalPartial=function(t){return r=>R(r,t)},t.toOptionalPromise=T,t.toOptionalPromisePartial=function(t){return r=>T(r,t)},t.toResult=function(t){try{const r=t();return w.of(r)}catch(t){return w.ofErr(t)}},t.toResultAsync=function(t){try{const r=t();return new g(r)}catch(t){return g.ofErr(t)}},t.toResultPromise=function(t){return new g(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
function r(t,r,n,e){return new(n||(n=Promise))((function(i,o){function u(t){try{c(e.next(t))}catch(t){o(t)}}function s(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var r;t.done?i(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 n(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 e(t){return this instanceof e?(this.v=t,this):new e(t)}function i(t,r,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,r||[]),u=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(t){o[t]&&(i[t]=function(r){return new Promise((function(n,e){u.push([t,r,n,e])>1||c(t,r)}))})}function c(t,r){try{(n=o[t](r)).value instanceof e?Promise.resolve(n.value.v).then(f,d):a(u[0][2],n)}catch(t){a(u[0][3],t)}var n}function f(t){c("next",t)}function d(t){c("throw",t)}function a(t,r){t(r),u.shift(),u.length&&c(u[0][0],u[0][1])}}function o(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,e=t[Symbol.asyncIterator];return e?e.call(t):(t=n(t),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(n){r[n]=t[n]&&function(r){return new Promise((function(e,i){(function(t,r,n,e){Promise.resolve(e).then((function(r){t({value:r,done:n})}),r)})(e,i,(r=t[n](r)).done,r.value)}))}}}function u(t,r){if(!r.has(t))throw new TypeError("attempted to get private field on non-instance");return r.get(t)}function s(t,r,n){if(!r.has(t))throw new TypeError("attempted to set private field on non-instance");return r.set(t,n),n}function c(t){return r(this,void 0,void 0,(function*(){try{return[!0,yield t]}catch(t){return[!1,void 0]}}))}function f(t){return r(this,void 0,void 0,(function*(){try{return yield t,[!1,void 0]}catch(t){return[!0,t]}}))}function d(t){return r(this,void 0,void 0,(function*(){try{return yield t,!0}catch(t){return!1}}))}function a(t){return r(this,void 0,void 0,(function*(){try{return yield t,!1}catch(t){return!0}}))}var h,l,y,v,m;class w{static Ok(t){return p.of(t)}static Err(t){return g.of(t)}}class p extends w{constructor(t){super(),h.set(this,void 0),s(this,h,t)}static of(t){return new p(t)}*[(h=new WeakMap,Symbol.iterator)](){yield u(this,h)}isOk(){return!0}isErr(){return!1}onOk(t){return t(u(this,h)),p.of(u(this,h))}onErr(){return p.of(u(this,h))}orElse(){return p.of(u(this,h))}map(t){return p.of(t(u(this,h)))}get(){return u(this,h)}}class g extends w{constructor(t){super(),l.set(this,void 0),s(this,l,t)}static of(t){return new g(t)}*[(l=new WeakMap,Symbol.iterator)](){}isOk(){return!1}isErr(){return!0}onOk(){return g.of(u(this,l))}onErr(t){return t(u(this,l)),g.of(u(this,l))}orElse(t){return p.of(t)}map(){return g.of(u(this,l))}get(){throw u(this,l)}}class E{constructor(t){y.set(this,void 0),s(this,y,t)}static Ok(t){return S.of(t)}static Err(t){return b.of(t)}[(y=new WeakMap,Symbol.asyncIterator)](){return i(this,arguments,(function*(){const[t,r]=yield e(c(u(this,y)));t&&(yield yield e(r))}))}onOk(t){return(()=>{r(this,void 0,void 0,(function*(){const[r,n]=yield c(u(this,y));r&&t(n)}))})(),new E(u(this,y))}onErr(t){return(()=>{r(this,void 0,void 0,(function*(){const[r,n]=yield f(u(this,y));r&&t(n)}))})(),new E(u(this,y))}isOk(){return r(this,void 0,void 0,(function*(){return yield d(u(this,y))}))}isErr(){return r(this,void 0,void 0,(function*(){return yield a(u(this,y))}))}orElse(t){return new E((()=>r(this,void 0,void 0,(function*(){try{return yield u(this,y)}catch(r){return t}})))())}map(t){return new E((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,y);return t(r)})))())}get(){return r(this,void 0,void 0,(function*(){return yield u(this,y)}))}}class S extends E{static of(t){return new S(t)}constructor(t){super(Promise.resolve(t))}}class b extends E{static of(t){return new b(t)}constructor(t){super(Promise.reject(t))}}class P{static Some(t){return x.of(t)}static None(){return O.of()}}class x extends P{constructor(t){super(),v.set(this,void 0),s(this,v,t)}static of(t){return new x(t)}*[(v=new WeakMap,Symbol.iterator)](){yield u(this,v)}isSome(){return!0}isNone(){return!1}onSome(t){return t(u(this,v)),x.of(u(this,v))}onNone(){return x.of(u(this,v))}orElse(){return x.of(u(this,v))}map(t){return x.of(t(u(this,v)))}filter(t){return t(u(this,v))?x.of(u(this,v)):O.of()}get(){return u(this,v)}}class O extends P{static of(){return new O}constructor(){super()}*[Symbol.iterator](){}isSome(){return!1}isNone(){return!0}onSome(){return O.of()}onNone(t){return t(),O.of()}orElse(t){return x.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)?P.None():P.Some(n)}const R=Symbol();class N{constructor(t){m.set(this,void 0),s(this,m,t)}static Some(t){return I.of(t)}static None(){return A.of()}[(m=new WeakMap,Symbol.asyncIterator)](){return i(this,arguments,(function*(){const t=yield e(u(this,m));t!==R&&(yield yield e(t))}))}onSome(t){return(()=>{r(this,void 0,void 0,(function*(){const r=yield u(this,m);r!==R&&t(r)}))})(),new N(u(this,m))}onNone(t){return(()=>{r(this,void 0,void 0,(function*(){(yield u(this,m))===R&&t()}))})(),new N(u(this,m))}isSome(){return r(this,void 0,void 0,(function*(){return(yield u(this,m))!==R}))}isNone(){return r(this,void 0,void 0,(function*(){return(yield u(this,m))===R}))}orElse(t){return new N((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,m);return r===R?t:r})))())}map(t){return new N((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,m);return r===R?R:t(r)})))())}filter(t){return new N((()=>r(this,void 0,void 0,(function*(){const r=yield u(this,m);return r===R?R:t(r)?r:R})))())}get(){return r(this,void 0,void 0,(function*(){const t=yield u(this,m);if(t===R)throw new Error("Cannot get value from None");return t}))}}class A extends N{static of(){return new A}constructor(){super(Promise.resolve(R))}}class I extends N{static of(t){return new I(t)}constructor(t){super(Promise.resolve(t))}}function T(t,n){return new N((()=>r(this,void 0,void 0,(function*(){const r=yield t;return n(r)?R:r})))())}t.getError=function(t){try{t()}catch(t){return t}},t.getErrorAsync=function(t){return r(this,void 0,void 0,(function*(){try{yield t()}catch(t){return t}}))},t.getErrorAsyncIterable=function(t){var n,e,i,u;return r(this,void 0,void 0,(function*(){try{try{for(n=o(t);!(e=yield n.next()).done;){e.value}}catch(t){i={error:t}}finally{try{e&&!e.done&&(u=n.return)&&(yield u.call(n))}finally{if(i)throw i.error}}}catch(t){return t}}))},t.getErrorPromise=function(t){return r(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 r(this,void 0,void 0,(function*(){try{return[void 0,yield t()]}catch(t){return[t,void 0]}}))},t.getErrorResultPromise=function(t){return r(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 r(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 r(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 r(this,void 0,void 0,(function*(){try{return[yield t(),void 0]}catch(t){return[void 0,t]}}))},t.getResultErrorPromise=function(t){return r(this,void 0,void 0,(function*(){try{return[yield t,void 0]}catch(t){return[void 0,t]}}))},t.getResultPromise=function(t){return r(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 r(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 r(this,void 0,void 0,(function*(){try{return yield t(),!1}catch(t){return!0}}))},t.isFailurePromise=a,t.isSuccess=function(t){try{return t(),!0}catch(t){return!1}},t.isSuccessAsync=function(t){return r(this,void 0,void 0,(function*(){try{return yield t(),!0}catch(t){return!1}}))},t.isSuccessPromise=d,t.toOptional=k,t.toOptionalPartial=function(t){return r=>k(r,t)},t.toOptionalPromise=T,t.toOptionalPromisePartial=function(t){return r=>T(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 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 |
@@ -284,10 +284,9 @@ (function (global, factory) { | ||
// Don't try to refactor it, You will lose to TypeScript. | ||
var _value, _value_1; | ||
class Result { | ||
static of(value) { | ||
return new Ok(value); | ||
static Ok(value) { | ||
return Ok.of(value); | ||
} | ||
static ofErr(error) { | ||
return new Err(error); | ||
static Err(error) { | ||
return Err.of(error); | ||
} | ||
@@ -301,2 +300,5 @@ } | ||
} | ||
static of(value) { | ||
return new Ok(value); | ||
} | ||
*[(_value = new WeakMap(), Symbol.iterator)]() { | ||
@@ -313,12 +315,12 @@ yield __classPrivateFieldGet(this, _value); | ||
callback(__classPrivateFieldGet(this, _value)); | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
onErr() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
orElse() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
map(mapper) { | ||
return Result.of(mapper(__classPrivateFieldGet(this, _value))); | ||
map(fn) { | ||
return Ok.of(fn(__classPrivateFieldGet(this, _value))); | ||
} | ||
@@ -335,2 +337,5 @@ get() { | ||
} | ||
static of(error) { | ||
return new Err(error); | ||
} | ||
*[(_value_1 = new WeakMap(), Symbol.iterator)]() { } | ||
@@ -344,13 +349,13 @@ isOk() { | ||
onOk() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
onErr(callback) { | ||
callback(__classPrivateFieldGet(this, _value_1)); | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
orElse(defaultValue) { | ||
return Result.of(defaultValue); | ||
return Ok.of(defaultValue); | ||
} | ||
map() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
@@ -365,6 +370,6 @@ get() { | ||
const result = fn(); | ||
return Result.of(result); | ||
return Result.Ok(result); | ||
} | ||
catch (e) { | ||
return Result.ofErr(e); | ||
return Result.Err(e); | ||
} | ||
@@ -379,7 +384,7 @@ } | ||
} | ||
static of(value) { | ||
return new AsyncOk(value); | ||
static Ok(value) { | ||
return AsyncOk.of(value); | ||
} | ||
static ofErr(error) { | ||
return new AsyncErr(error); | ||
static Err(error) { | ||
return AsyncErr.of(error); | ||
} | ||
@@ -434,2 +439,5 @@ async *[(_promise = new WeakMap(), Symbol.asyncIterator)]() { | ||
class AsyncOk extends AsyncResult { | ||
static of(value) { | ||
return new AsyncOk(value); | ||
} | ||
constructor(value) { | ||
@@ -440,2 +448,5 @@ super(Promise.resolve(value)); | ||
class AsyncErr extends AsyncResult { | ||
static of(value) { | ||
return new AsyncErr(value); | ||
} | ||
constructor(err) { | ||
@@ -452,3 +463,3 @@ super(Promise.reject(err)); | ||
catch (e) { | ||
return AsyncResult.ofErr(e); | ||
return AsyncResult.Err(e); | ||
} | ||
@@ -461,10 +472,9 @@ } | ||
// Don't try to refactor it, You will lose to TypeScript. | ||
var _value$1; | ||
class Optional { | ||
static of(value) { | ||
return new Some(value); | ||
static Some(value) { | ||
return Some.of(value); | ||
} | ||
static ofNone() { | ||
return new None(); | ||
static None() { | ||
return None.of(); | ||
} | ||
@@ -478,2 +488,5 @@ } | ||
} | ||
static of(value) { | ||
return new Some(value); | ||
} | ||
*[(_value$1 = new WeakMap(), Symbol.iterator)]() { | ||
@@ -490,19 +503,19 @@ yield __classPrivateFieldGet(this, _value$1); | ||
callback(__classPrivateFieldGet(this, _value$1)); | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
onNone() { | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
orElse() { | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
map(mapper) { | ||
return Optional.of(mapper(__classPrivateFieldGet(this, _value$1))); | ||
return Some.of(mapper(__classPrivateFieldGet(this, _value$1))); | ||
} | ||
filter(predicate) { | ||
if (predicate(__classPrivateFieldGet(this, _value$1))) { | ||
return Optional.of(__classPrivateFieldGet(this, _value$1)); | ||
return Some.of(__classPrivateFieldGet(this, _value$1)); | ||
} | ||
else { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -515,2 +528,8 @@ } | ||
class None extends Optional { | ||
static of() { | ||
return new None(); | ||
} | ||
constructor() { | ||
super(); | ||
} | ||
*[Symbol.iterator]() { } | ||
@@ -523,17 +542,17 @@ isSome() { | ||
} | ||
onSome(_) { | ||
return Optional.ofNone(); | ||
onSome() { | ||
return None.of(); | ||
} | ||
onNone(callback) { | ||
callback(); | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
orElse(defaultValue) { | ||
return Optional.of(defaultValue); | ||
return Some.of(defaultValue); | ||
} | ||
map() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
filter() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -551,6 +570,6 @@ get() { | ||
if (isNone(result)) { | ||
return Optional.ofNone(); | ||
return Optional.None(); | ||
} | ||
else { | ||
return Optional.of(result); | ||
return Optional.Some(result); | ||
} | ||
@@ -560,3 +579,3 @@ } | ||
var _promise$1; | ||
const None$1 = Symbol(); | ||
const Nil = Symbol(); | ||
class AsyncOptional { | ||
@@ -567,11 +586,11 @@ constructor(promise) { | ||
} | ||
static of(value) { | ||
return new AsyncSome(value); | ||
static Some(value) { | ||
return AsyncSome.of(value); | ||
} | ||
static ofNone() { | ||
return new AsyncNone(); | ||
static None() { | ||
return AsyncNone.of(); | ||
} | ||
async *[(_promise$1 = new WeakMap(), Symbol.asyncIterator)]() { | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
if (result !== None$1) | ||
if (result !== Nil) | ||
yield result; | ||
@@ -582,3 +601,3 @@ } | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
if (result !== None$1) | ||
if (result !== Nil) | ||
callback(result); | ||
@@ -591,3 +610,3 @@ })(); | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
if (result === Nil) | ||
callback(); | ||
@@ -599,7 +618,7 @@ })(); | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
return result !== None$1; | ||
return result !== Nil; | ||
} | ||
async isNone() { | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
return result === None$1; | ||
return result === Nil; | ||
} | ||
@@ -609,3 +628,3 @@ orElse(defaultValue) { | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
if (result === Nil) | ||
return defaultValue; | ||
@@ -618,4 +637,4 @@ return result; | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
return None$1; | ||
if (result === Nil) | ||
return Nil; | ||
return mapper(result); | ||
@@ -627,7 +646,7 @@ })()); | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
return None$1; | ||
if (result === Nil) | ||
return Nil; | ||
if (predicate(result)) | ||
return result; | ||
return None$1; | ||
return Nil; | ||
})()); | ||
@@ -637,3 +656,3 @@ } | ||
const result = await __classPrivateFieldGet(this, _promise$1); | ||
if (result === None$1) | ||
if (result === Nil) | ||
throw new Error('Cannot get value from None'); | ||
@@ -644,7 +663,13 @@ return result; | ||
class AsyncNone extends AsyncOptional { | ||
static of() { | ||
return new AsyncNone(); | ||
} | ||
constructor() { | ||
super(Promise.resolve(None$1)); | ||
super(Promise.resolve(Nil)); | ||
} | ||
} | ||
class AsyncSome extends AsyncOptional { | ||
static of(value) { | ||
return new AsyncSome(value); | ||
} | ||
constructor(value) { | ||
@@ -662,3 +687,3 @@ super(Promise.resolve(value)); | ||
if (isNone(result)) | ||
return None$1; | ||
return Nil; | ||
return result; | ||
@@ -665,0 +690,0 @@ })()); |
@@ -16,3 +16,3 @@ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnStyle={})}(this,(function(t){"use strict";async function r(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 e(t){try{return await t,!0}catch(t){return!1}}async function s(t){try{return await t,!1}catch(t){return!0}} | ||
***************************************************************************** */ | ||
function o(t,r){if(!r.has(t))throw new TypeError("attempted to get private field on non-instance");return r.get(t)}function i(t,r,n){if(!r.has(t))throw new TypeError("attempted to set private field on non-instance");return r.set(t,n),n}var c,a,u,y,f;class h{static of(t){return new l(t)}static ofErr(t){return new w(t)}}class l extends h{constructor(t){super(),c.set(this,void 0),i(this,c,t)}*[(c=new WeakMap,Symbol.iterator)](){yield o(this,c)}isOk(){return!0}isErr(){return!1}onOk(t){return t(o(this,c)),h.of(o(this,c))}onErr(){return h.of(o(this,c))}orElse(){return h.of(o(this,c))}map(t){return h.of(t(o(this,c)))}get(){return o(this,c)}}class w extends h{constructor(t){super(),a.set(this,void 0),i(this,a,t)}*[(a=new WeakMap,Symbol.iterator)](){}isOk(){return!1}isErr(){return!0}onOk(){return h.ofErr(o(this,a))}onErr(t){return t(o(this,a)),h.ofErr(o(this,a))}orElse(t){return h.of(t)}map(){return h.ofErr(o(this,a))}get(){throw o(this,a)}}class d{constructor(t){u.set(this,void 0),i(this,u,t)}static of(t){return new m(t)}static ofErr(t){return new p(t)}async*[(u=new WeakMap,Symbol.asyncIterator)](){const[t,n]=await r(o(this,u));t&&(yield n)}onOk(t){return(async()=>{const[n,e]=await r(o(this,u));n&&t(e)})(),new d(o(this,u))}onErr(t){return(async()=>{const[r,e]=await n(o(this,u));r&&t(e)})(),new d(o(this,u))}async isOk(){return await e(o(this,u))}async isErr(){return await s(o(this,u))}orElse(t){return new d((async()=>{try{return await o(this,u)}catch(r){return t}})())}map(t){return new d((async()=>{const r=await o(this,u);return t(r)})())}async get(){return await o(this,u)}}class m extends d{constructor(t){super(Promise.resolve(t))}}class p extends d{constructor(t){super(Promise.reject(t))}}class E{static of(t){return new v(t)}static ofNone(){return new g}}class v extends E{constructor(t){super(),y.set(this,void 0),i(this,y,t)}*[(y=new WeakMap,Symbol.iterator)](){yield o(this,y)}isSome(){return!0}isNone(){return!1}onSome(t){return t(o(this,y)),E.of(o(this,y))}onNone(){return E.of(o(this,y))}orElse(){return E.of(o(this,y))}map(t){return E.of(t(o(this,y)))}filter(t){return t(o(this,y))?E.of(o(this,y)):E.ofNone()}get(){return o(this,y)}}class g extends E{*[Symbol.iterator](){}isSome(){return!1}isNone(){return!0}onSome(t){return E.ofNone()}onNone(t){return t(),E.ofNone()}orElse(t){return E.of(t)}map(){return E.ofNone()}filter(){return E.ofNone()}get(){throw new Error("Cannot get value from None")}}function S(t,r){const n=t();return r(n)?E.ofNone():E.of(n)}const P=Symbol();class N{constructor(t){f.set(this,void 0),i(this,f,t)}static of(t){return new b(t)}static ofNone(){return new R}async*[(f=new WeakMap,Symbol.asyncIterator)](){const t=await o(this,f);t!==P&&(yield t)}onSome(t){return(async()=>{const r=await o(this,f);r!==P&&t(r)})(),new N(o(this,f))}onNone(t){return(async()=>{await o(this,f)===P&&t()})(),new N(o(this,f))}async isSome(){return await o(this,f)!==P}async isNone(){return await o(this,f)===P}orElse(t){return new N((async()=>{const r=await o(this,f);return r===P?t:r})())}map(t){return new N((async()=>{const r=await o(this,f);return r===P?P:t(r)})())}filter(t){return new N((async()=>{const r=await o(this,f);return r===P?P:t(r)?r:P})())}async get(){const t=await o(this,f);if(t===P)throw new Error("Cannot get value from None");return t}}class R extends N{constructor(){super(Promise.resolve(P))}}class b extends N{constructor(t){super(Promise.resolve(t))}}function k(t,r){return new N((async()=>{const n=await t;return r(n)?P:n})())}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=r,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=e,t.toOptional=S,t.toOptionalPartial=function(t){return r=>S(r,t)},t.toOptionalPromise=k,t.toOptionalPromisePartial=function(t){return r=>k(r,t)},t.toResult=function(t){try{const r=t();return h.of(r)}catch(t){return h.ofErr(t)}},t.toResultAsync=function(t){try{const r=t();return new d(r)}catch(t){return d.ofErr(t)}},t.toResultPromise=function(t){return new d(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
function o(t,r){if(!r.has(t))throw new TypeError("attempted to get private field on non-instance");return r.get(t)}function i(t,r,n){if(!r.has(t))throw new TypeError("attempted to set private field on non-instance");return r.set(t,n),n}var c,a,u,f,y;class h{static Ok(t){return l.of(t)}static Err(t){return w.of(t)}}class l extends h{constructor(t){super(),c.set(this,void 0),i(this,c,t)}static of(t){return new l(t)}*[(c=new WeakMap,Symbol.iterator)](){yield o(this,c)}isOk(){return!0}isErr(){return!1}onOk(t){return t(o(this,c)),l.of(o(this,c))}onErr(){return l.of(o(this,c))}orElse(){return l.of(o(this,c))}map(t){return l.of(t(o(this,c)))}get(){return o(this,c)}}class w extends h{constructor(t){super(),a.set(this,void 0),i(this,a,t)}static of(t){return new w(t)}*[(a=new WeakMap,Symbol.iterator)](){}isOk(){return!1}isErr(){return!0}onOk(){return w.of(o(this,a))}onErr(t){return t(o(this,a)),w.of(o(this,a))}orElse(t){return l.of(t)}map(){return w.of(o(this,a))}get(){throw o(this,a)}}class d{constructor(t){u.set(this,void 0),i(this,u,t)}static Ok(t){return m.of(t)}static Err(t){return p.of(t)}async*[(u=new WeakMap,Symbol.asyncIterator)](){const[t,n]=await r(o(this,u));t&&(yield n)}onOk(t){return(async()=>{const[n,e]=await r(o(this,u));n&&t(e)})(),new d(o(this,u))}onErr(t){return(async()=>{const[r,e]=await n(o(this,u));r&&t(e)})(),new d(o(this,u))}async isOk(){return await e(o(this,u))}async isErr(){return await s(o(this,u))}orElse(t){return new d((async()=>{try{return await o(this,u)}catch(r){return t}})())}map(t){return new d((async()=>{const r=await o(this,u);return t(r)})())}async get(){return await o(this,u)}}class m extends d{static of(t){return new m(t)}constructor(t){super(Promise.resolve(t))}}class p extends d{static of(t){return new p(t)}constructor(t){super(Promise.reject(t))}}class v{static Some(t){return g.of(t)}static None(){return E.of()}}class g extends v{constructor(t){super(),f.set(this,void 0),i(this,f,t)}static of(t){return new g(t)}*[(f=new WeakMap,Symbol.iterator)](){yield o(this,f)}isSome(){return!0}isNone(){return!1}onSome(t){return t(o(this,f)),g.of(o(this,f))}onNone(){return g.of(o(this,f))}orElse(){return g.of(o(this,f))}map(t){return g.of(t(o(this,f)))}filter(t){return t(o(this,f))?g.of(o(this,f)):E.of()}get(){return o(this,f)}}class E extends v{static of(){return new E}constructor(){super()}*[Symbol.iterator](){}isSome(){return!1}isNone(){return!0}onSome(){return E.of()}onNone(t){return t(),E.of()}orElse(t){return g.of(t)}map(){return E.of()}filter(){return E.of()}get(){throw new Error("Cannot get value from None")}}function S(t,r){const n=t();return r(n)?v.None():v.Some(n)}const P=Symbol();class k{constructor(t){y.set(this,void 0),i(this,y,t)}static Some(t){return R.of(t)}static None(){return O.of()}async*[(y=new WeakMap,Symbol.asyncIterator)](){const t=await o(this,y);t!==P&&(yield t)}onSome(t){return(async()=>{const r=await o(this,y);r!==P&&t(r)})(),new k(o(this,y))}onNone(t){return(async()=>{await o(this,y)===P&&t()})(),new k(o(this,y))}async isSome(){return await o(this,y)!==P}async isNone(){return await o(this,y)===P}orElse(t){return new k((async()=>{const r=await o(this,y);return r===P?t:r})())}map(t){return new k((async()=>{const r=await o(this,y);return r===P?P:t(r)})())}filter(t){return new k((async()=>{const r=await o(this,y);return r===P?P:t(r)?r:P})())}async get(){const t=await o(this,y);if(t===P)throw new Error("Cannot get value from None");return t}}class O extends k{static of(){return new O}constructor(){super(Promise.resolve(P))}}class R extends k{static of(t){return new R(t)}constructor(t){super(Promise.resolve(t))}}function b(t,r){return new k((async()=>{const n=await t;return r(n)?P:n})())}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=r,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=e,t.toOptional=S,t.toOptionalPartial=function(t){return r=>S(r,t)},t.toOptionalPromise=b,t.toOptionalPromisePartial=function(t){return r=>b(r,t)},t.toResult=function(t){try{const r=t();return h.Ok(r)}catch(t){return h.Err(t)}},t.toResultAsync=function(t){try{const r=t();return new d(r)}catch(t){return d.Err(t)}},t.toResultPromise=function(t){return new d(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.min.js.map |
@@ -1,4 +0,4 @@ | ||
export declare const None: unique symbol; | ||
interface IAsyncOptional<T> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
export declare const Nil: unique symbol; | ||
export interface IAsyncOptional<T> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onSome(callback: (val: T) => void): IAsyncOptional<T>; | ||
@@ -15,15 +15,14 @@ onNone(callback: () => void): IAsyncOptional<T>; | ||
#private; | ||
static of<T>(value: T): AsyncOptional<T>; | ||
static ofNone(): AsyncOptional<never>; | ||
constructor(promise: PromiseLike<T | typeof None>); | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
onSome(callback: (val: T) => void): AsyncOptional<T>; | ||
onNone(callback: () => void): AsyncOptional<T>; | ||
static Some<T>(value: T): IAsyncOptional<T>; | ||
static None(): IAsyncOptional<never>; | ||
constructor(promise: PromiseLike<T | typeof Nil>); | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onSome(callback: (val: T) => void): IAsyncOptional<T>; | ||
onNone(callback: () => void): IAsyncOptional<T>; | ||
isSome(): Promise<boolean>; | ||
isNone(): Promise<boolean>; | ||
orElse<U>(defaultValue: U): AsyncOptional<T | U>; | ||
map<U>(mapper: (val: T) => U): AsyncOptional<U>; | ||
filter<U extends T = T>(predicate: (val: T) => boolean): AsyncOptional<U>; | ||
orElse<U>(defaultValue: U): IAsyncOptional<T | U>; | ||
map<U>(mapper: (val: T) => U): IAsyncOptional<U>; | ||
filter<U extends T = T>(predicate: (val: T) => boolean): IAsyncOptional<U>; | ||
get(): Promise<T>; | ||
} | ||
export {}; |
@@ -38,4 +38,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AsyncOptional = exports.None = void 0; | ||
exports.None = Symbol(); | ||
exports.AsyncOptional = exports.Nil = void 0; | ||
exports.Nil = Symbol(); | ||
class AsyncOptional { | ||
@@ -46,7 +46,7 @@ constructor(promise) { | ||
} | ||
static of(value) { | ||
return new AsyncSome(value); | ||
static Some(value) { | ||
return AsyncSome.of(value); | ||
} | ||
static ofNone() { | ||
return new AsyncNone(); | ||
static None() { | ||
return AsyncNone.of(); | ||
} | ||
@@ -56,3 +56,3 @@ [(_promise = new WeakMap(), Symbol.asyncIterator)]() { | ||
const result = yield __await(__classPrivateFieldGet(this, _promise)); | ||
if (result !== exports.None) | ||
if (result !== exports.Nil) | ||
yield yield __await(result); | ||
@@ -64,3 +64,3 @@ }); | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
if (result !== exports.None) | ||
if (result !== exports.Nil) | ||
callback(result); | ||
@@ -73,3 +73,3 @@ }))(); | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
if (result === exports.Nil) | ||
callback(); | ||
@@ -82,3 +82,3 @@ }))(); | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
return result !== exports.None; | ||
return result !== exports.Nil; | ||
}); | ||
@@ -89,3 +89,3 @@ } | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
return result === exports.None; | ||
return result === exports.Nil; | ||
}); | ||
@@ -96,3 +96,3 @@ } | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
if (result === exports.Nil) | ||
return defaultValue; | ||
@@ -105,4 +105,4 @@ return result; | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
return exports.None; | ||
if (result === exports.Nil) | ||
return exports.Nil; | ||
return mapper(result); | ||
@@ -114,7 +114,7 @@ }))()); | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
return exports.None; | ||
if (result === exports.Nil) | ||
return exports.Nil; | ||
if (predicate(result)) | ||
return result; | ||
return exports.None; | ||
return exports.Nil; | ||
}))()); | ||
@@ -125,3 +125,3 @@ } | ||
const result = yield __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
if (result === exports.Nil) | ||
throw new Error('Cannot get value from None'); | ||
@@ -134,7 +134,13 @@ return result; | ||
class AsyncNone extends AsyncOptional { | ||
static of() { | ||
return new AsyncNone(); | ||
} | ||
constructor() { | ||
super(Promise.resolve(exports.None)); | ||
super(Promise.resolve(exports.Nil)); | ||
} | ||
} | ||
class AsyncSome extends AsyncOptional { | ||
static of(value) { | ||
return new AsyncSome(value); | ||
} | ||
constructor(value) { | ||
@@ -141,0 +147,0 @@ super(Promise.resolve(value)); |
@@ -1,3 +0,3 @@ | ||
interface IAsyncResult<T, X> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
export interface IAsyncResult<T, X> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onOk(callback: (val: T) => void): IAsyncResult<T, X>; | ||
@@ -13,14 +13,13 @@ onErr(callback: (err: X) => void): IAsyncResult<T, X>; | ||
#private; | ||
static of<T>(value: T): AsyncResult<T, never>; | ||
static ofErr<X>(error: X): AsyncResult<never, X>; | ||
static Ok<T>(value: T): IAsyncResult<T, never>; | ||
static Err<T>(error: T): IAsyncResult<never, T>; | ||
constructor(promise: PromiseLike<T>); | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
onOk(callback: (val: T) => void): AsyncResult<T, X>; | ||
onErr(callback: (err: X) => void): AsyncResult<T, X>; | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onOk(callback: (val: T) => void): IAsyncResult<T, X>; | ||
onErr(callback: (err: X) => void): IAsyncResult<T, X>; | ||
isOk(): Promise<boolean>; | ||
isErr(): Promise<boolean>; | ||
orElse<U>(defaultValue: U): AsyncResult<T | U, never>; | ||
map<U>(mapper: (val: T) => U): AsyncResult<U, X>; | ||
orElse<U>(defaultValue: U): IAsyncResult<T | U, never>; | ||
map<U>(mapper: (val: T) => U): IAsyncResult<U, X>; | ||
get(): Promise<T>; | ||
} | ||
export {}; |
@@ -48,7 +48,7 @@ "use strict"; | ||
} | ||
static of(value) { | ||
return new AsyncOk(value); | ||
static Ok(value) { | ||
return AsyncOk.of(value); | ||
} | ||
static ofErr(error) { | ||
return new AsyncErr(error); | ||
static Err(error) { | ||
return AsyncErr.of(error); | ||
} | ||
@@ -112,2 +112,5 @@ [(_promise = new WeakMap(), Symbol.asyncIterator)]() { | ||
class AsyncOk extends AsyncResult { | ||
static of(value) { | ||
return new AsyncOk(value); | ||
} | ||
constructor(value) { | ||
@@ -118,2 +121,5 @@ super(Promise.resolve(value)); | ||
class AsyncErr extends AsyncResult { | ||
static of(value) { | ||
return new AsyncErr(value); | ||
} | ||
constructor(err) { | ||
@@ -120,0 +126,0 @@ super(Promise.reject(err)); |
@@ -1,13 +0,15 @@ | ||
export declare abstract class Optional<T> implements Iterable<T> { | ||
static of<T>(value: T): Optional<T>; | ||
static ofNone(): Optional<never>; | ||
abstract [Symbol.iterator](): Iterator<T>; | ||
abstract isSome(): boolean; | ||
abstract isNone(): boolean; | ||
abstract onSome(callback: (val: T) => void): Optional<T>; | ||
abstract onNone(callback: () => void): Optional<T>; | ||
abstract orElse<U>(defaultValue: U): Optional<T | U>; | ||
abstract map<U>(mapper: (val: T) => U): Optional<U>; | ||
abstract filter<U extends T = T>(predicate: (val: T) => boolean): Optional<U>; | ||
abstract get(): T; | ||
export interface IOptional<T> extends Iterable<T> { | ||
[Symbol.iterator](): Iterator<T, void>; | ||
isSome(): boolean; | ||
isNone(): boolean; | ||
onSome(callback: (val: T) => void): IOptional<T>; | ||
onNone(callback: () => void): IOptional<T>; | ||
orElse<U>(defaultValue: U): IOptional<T | U>; | ||
map<U>(mapper: (val: T) => U): IOptional<U>; | ||
filter<U extends T = T>(predicate: (val: T) => boolean): IOptional<U>; | ||
get(): T; | ||
} | ||
export declare abstract class Optional { | ||
static Some<T>(value: T): IOptional<T>; | ||
static None(): IOptional<never>; | ||
} |
@@ -19,7 +19,7 @@ "use strict"; | ||
class Optional { | ||
static of(value) { | ||
return new Some(value); | ||
static Some(value) { | ||
return Some.of(value); | ||
} | ||
static ofNone() { | ||
return new None(); | ||
static None() { | ||
return None.of(); | ||
} | ||
@@ -34,2 +34,5 @@ } | ||
} | ||
static of(value) { | ||
return new Some(value); | ||
} | ||
*[(_value = new WeakMap(), Symbol.iterator)]() { | ||
@@ -46,19 +49,19 @@ yield __classPrivateFieldGet(this, _value); | ||
callback(__classPrivateFieldGet(this, _value)); | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
onNone() { | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
orElse() { | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
map(mapper) { | ||
return Optional.of(mapper(__classPrivateFieldGet(this, _value))); | ||
return Some.of(mapper(__classPrivateFieldGet(this, _value))); | ||
} | ||
filter(predicate) { | ||
if (predicate(__classPrivateFieldGet(this, _value))) { | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
else { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -71,2 +74,8 @@ } | ||
class None extends Optional { | ||
static of() { | ||
return new None(); | ||
} | ||
constructor() { | ||
super(); | ||
} | ||
*[Symbol.iterator]() { } | ||
@@ -79,17 +88,17 @@ isSome() { | ||
} | ||
onSome(_) { | ||
return Optional.ofNone(); | ||
onSome() { | ||
return None.of(); | ||
} | ||
onNone(callback) { | ||
callback(); | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
orElse(defaultValue) { | ||
return Optional.of(defaultValue); | ||
return Some.of(defaultValue); | ||
} | ||
map() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
filter() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -96,0 +105,0 @@ get() { |
@@ -1,12 +0,14 @@ | ||
export declare abstract class Result<T, X> implements Iterable<T> { | ||
static of<T>(value: T): Result<T, never>; | ||
static ofErr<X>(error: X): Result<never, X>; | ||
abstract [Symbol.iterator](): Iterator<T>; | ||
abstract isOk(): boolean; | ||
abstract isErr(): boolean; | ||
abstract onOk(callback: (val: T) => void): Result<T, X>; | ||
abstract onErr(callback: (err: X) => void): Result<T, X>; | ||
abstract orElse<U>(defaultValue: U): Result<T | U, never>; | ||
abstract map<U>(mapper: (val: T) => U): Result<U, X>; | ||
abstract get(): T; | ||
export interface IResult<T, X> extends Iterable<T> { | ||
[Symbol.iterator](): Iterator<T, void>; | ||
isOk(): boolean; | ||
isErr(): boolean; | ||
onOk(callback: (val: T) => void): IResult<T, X>; | ||
onErr(callback: (err: X) => void): IResult<T, X>; | ||
orElse<U>(defaultValue: U): IResult<T, never> | IResult<U, never>; | ||
map<U>(mapper: (val: T) => U): IResult<U, X>; | ||
get(): T; | ||
} | ||
export declare abstract class Result { | ||
static Ok<T>(value: T): IResult<T, never>; | ||
static Err<T>(error: T): IResult<never, T>; | ||
} |
@@ -19,7 +19,7 @@ "use strict"; | ||
class Result { | ||
static of(value) { | ||
return new Ok(value); | ||
static Ok(value) { | ||
return Ok.of(value); | ||
} | ||
static ofErr(error) { | ||
return new Err(error); | ||
static Err(error) { | ||
return Err.of(error); | ||
} | ||
@@ -34,2 +34,5 @@ } | ||
} | ||
static of(value) { | ||
return new Ok(value); | ||
} | ||
*[(_value = new WeakMap(), Symbol.iterator)]() { | ||
@@ -46,12 +49,12 @@ yield __classPrivateFieldGet(this, _value); | ||
callback(__classPrivateFieldGet(this, _value)); | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
onErr() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
orElse() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
map(mapper) { | ||
return Result.of(mapper(__classPrivateFieldGet(this, _value))); | ||
map(fn) { | ||
return Ok.of(fn(__classPrivateFieldGet(this, _value))); | ||
} | ||
@@ -68,2 +71,5 @@ get() { | ||
} | ||
static of(error) { | ||
return new Err(error); | ||
} | ||
*[(_value_1 = new WeakMap(), Symbol.iterator)]() { } | ||
@@ -77,13 +83,13 @@ isOk() { | ||
onOk() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
onErr(callback) { | ||
callback(__classPrivateFieldGet(this, _value_1)); | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
orElse(defaultValue) { | ||
return Result.of(defaultValue); | ||
return Ok.of(defaultValue); | ||
} | ||
map() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
@@ -90,0 +96,0 @@ get() { |
@@ -1,3 +0,3 @@ | ||
import { AsyncOptional } from '../classes/async-optional'; | ||
export declare function toOptionalPromisePartial<T>(isNone: (val: T) => boolean): (promise: PromiseLike<T>) => AsyncOptional<T>; | ||
export declare function toOptionalPromise<T>(promise: PromiseLike<T>, isNone: (val: T) => boolean): AsyncOptional<T>; | ||
import { IAsyncOptional } from '../classes/async-optional'; | ||
export declare function toOptionalPromisePartial<T>(isNone: (val: T) => boolean): (promise: PromiseLike<T>) => IAsyncOptional<T>; | ||
export declare function toOptionalPromise<T>(promise: PromiseLike<T>, isNone: (val: T) => boolean): IAsyncOptional<T>; |
@@ -22,3 +22,3 @@ "use strict"; | ||
if (isNone(result)) | ||
return async_optional_1.None; | ||
return async_optional_1.Nil; | ||
return result; | ||
@@ -25,0 +25,0 @@ }))()); |
@@ -1,3 +0,3 @@ | ||
import { Optional } from '../classes/optional'; | ||
export declare function toOptionalPartial<T>(isNone: (val: T) => boolean): (fn: () => T) => Optional<T>; | ||
export declare function toOptional<T>(fn: () => T, isNone: (val: T) => boolean): Optional<T>; | ||
import { IOptional } from '../classes/optional'; | ||
export declare function toOptionalPartial<T>(isNone: (val: T) => boolean): (fn: () => T) => IOptional<T>; | ||
export declare function toOptional<T>(fn: () => T, isNone: (val: T) => boolean): IOptional<T>; |
@@ -12,6 +12,6 @@ "use strict"; | ||
if (isNone(result)) { | ||
return optional_1.Optional.ofNone(); | ||
return optional_1.Optional.None(); | ||
} | ||
else { | ||
return optional_1.Optional.of(result); | ||
return optional_1.Optional.Some(result); | ||
} | ||
@@ -18,0 +18,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AsyncResult } from '../classes/async-result'; | ||
export declare function toResultAsync<T, X = any>(fn: () => PromiseLike<T>): AsyncResult<T, X>; | ||
import { IAsyncResult } from '../classes/async-result'; | ||
export declare function toResultAsync<T, X = any>(fn: () => PromiseLike<T>): IAsyncResult<T, X>; |
@@ -11,3 +11,3 @@ "use strict"; | ||
catch (e) { | ||
return async_result_1.AsyncResult.ofErr(e); | ||
return async_result_1.AsyncResult.Err(e); | ||
} | ||
@@ -14,0 +14,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AsyncResult } from '../classes/async-result'; | ||
export declare function toResultPromise<T, X = any>(promise: PromiseLike<T>): AsyncResult<T, X>; | ||
import { IAsyncResult } from '../classes/async-result'; | ||
export declare function toResultPromise<T, X = any>(promise: PromiseLike<T>): IAsyncResult<T, X>; |
@@ -1,2 +0,2 @@ | ||
import { Result } from '../classes/result'; | ||
export declare function toResult<T, X = any>(fn: () => T): Result<T, X>; | ||
import { IResult } from '../classes/result'; | ||
export declare function toResult<T, X = any>(fn: () => T): IResult<T, X>; |
@@ -8,6 +8,6 @@ "use strict"; | ||
const result = fn(); | ||
return result_1.Result.of(result); | ||
return result_1.Result.Ok(result); | ||
} | ||
catch (e) { | ||
return result_1.Result.ofErr(e); | ||
return result_1.Result.Err(e); | ||
} | ||
@@ -14,0 +14,0 @@ } |
@@ -1,4 +0,4 @@ | ||
export declare const None: unique symbol; | ||
interface IAsyncOptional<T> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
export declare const Nil: unique symbol; | ||
export interface IAsyncOptional<T> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onSome(callback: (val: T) => void): IAsyncOptional<T>; | ||
@@ -15,15 +15,14 @@ onNone(callback: () => void): IAsyncOptional<T>; | ||
#private; | ||
static of<T>(value: T): AsyncOptional<T>; | ||
static ofNone(): AsyncOptional<never>; | ||
constructor(promise: PromiseLike<T | typeof None>); | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
onSome(callback: (val: T) => void): AsyncOptional<T>; | ||
onNone(callback: () => void): AsyncOptional<T>; | ||
static Some<T>(value: T): IAsyncOptional<T>; | ||
static None(): IAsyncOptional<never>; | ||
constructor(promise: PromiseLike<T | typeof Nil>); | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onSome(callback: (val: T) => void): IAsyncOptional<T>; | ||
onNone(callback: () => void): IAsyncOptional<T>; | ||
isSome(): Promise<boolean>; | ||
isNone(): Promise<boolean>; | ||
orElse<U>(defaultValue: U): AsyncOptional<T | U>; | ||
map<U>(mapper: (val: T) => U): AsyncOptional<U>; | ||
filter<U extends T = T>(predicate: (val: T) => boolean): AsyncOptional<U>; | ||
orElse<U>(defaultValue: U): IAsyncOptional<T | U>; | ||
map<U>(mapper: (val: T) => U): IAsyncOptional<U>; | ||
filter<U extends T = T>(predicate: (val: T) => boolean): IAsyncOptional<U>; | ||
get(): Promise<T>; | ||
} | ||
export {}; |
@@ -17,4 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AsyncOptional = exports.None = void 0; | ||
exports.None = Symbol(); | ||
exports.AsyncOptional = exports.Nil = void 0; | ||
exports.Nil = Symbol(); | ||
class AsyncOptional { | ||
@@ -25,11 +25,11 @@ constructor(promise) { | ||
} | ||
static of(value) { | ||
return new AsyncSome(value); | ||
static Some(value) { | ||
return AsyncSome.of(value); | ||
} | ||
static ofNone() { | ||
return new AsyncNone(); | ||
static None() { | ||
return AsyncNone.of(); | ||
} | ||
async *[(_promise = new WeakMap(), Symbol.asyncIterator)]() { | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
if (result !== exports.None) | ||
if (result !== exports.Nil) | ||
yield result; | ||
@@ -40,3 +40,3 @@ } | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
if (result !== exports.None) | ||
if (result !== exports.Nil) | ||
callback(result); | ||
@@ -49,3 +49,3 @@ })(); | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
if (result === exports.Nil) | ||
callback(); | ||
@@ -57,7 +57,7 @@ })(); | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
return result !== exports.None; | ||
return result !== exports.Nil; | ||
} | ||
async isNone() { | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
return result === exports.None; | ||
return result === exports.Nil; | ||
} | ||
@@ -67,3 +67,3 @@ orElse(defaultValue) { | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
if (result === exports.Nil) | ||
return defaultValue; | ||
@@ -76,4 +76,4 @@ return result; | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
return exports.None; | ||
if (result === exports.Nil) | ||
return exports.Nil; | ||
return mapper(result); | ||
@@ -85,7 +85,7 @@ })()); | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
return exports.None; | ||
if (result === exports.Nil) | ||
return exports.Nil; | ||
if (predicate(result)) | ||
return result; | ||
return exports.None; | ||
return exports.Nil; | ||
})()); | ||
@@ -95,3 +95,3 @@ } | ||
const result = await __classPrivateFieldGet(this, _promise); | ||
if (result === exports.None) | ||
if (result === exports.Nil) | ||
throw new Error('Cannot get value from None'); | ||
@@ -103,7 +103,13 @@ return result; | ||
class AsyncNone extends AsyncOptional { | ||
static of() { | ||
return new AsyncNone(); | ||
} | ||
constructor() { | ||
super(Promise.resolve(exports.None)); | ||
super(Promise.resolve(exports.Nil)); | ||
} | ||
} | ||
class AsyncSome extends AsyncOptional { | ||
static of(value) { | ||
return new AsyncSome(value); | ||
} | ||
constructor(value) { | ||
@@ -110,0 +116,0 @@ super(Promise.resolve(value)); |
@@ -1,3 +0,3 @@ | ||
interface IAsyncResult<T, X> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
export interface IAsyncResult<T, X> extends AsyncIterable<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onOk(callback: (val: T) => void): IAsyncResult<T, X>; | ||
@@ -13,14 +13,13 @@ onErr(callback: (err: X) => void): IAsyncResult<T, X>; | ||
#private; | ||
static of<T>(value: T): AsyncResult<T, never>; | ||
static ofErr<X>(error: X): AsyncResult<never, X>; | ||
static Ok<T>(value: T): IAsyncResult<T, never>; | ||
static Err<T>(error: T): IAsyncResult<never, T>; | ||
constructor(promise: PromiseLike<T>); | ||
[Symbol.asyncIterator](): AsyncIterator<T>; | ||
onOk(callback: (val: T) => void): AsyncResult<T, X>; | ||
onErr(callback: (err: X) => void): AsyncResult<T, X>; | ||
[Symbol.asyncIterator](): AsyncIterator<T, void>; | ||
onOk(callback: (val: T) => void): IAsyncResult<T, X>; | ||
onErr(callback: (err: X) => void): IAsyncResult<T, X>; | ||
isOk(): Promise<boolean>; | ||
isErr(): Promise<boolean>; | ||
orElse<U>(defaultValue: U): AsyncResult<T | U, never>; | ||
map<U>(mapper: (val: T) => U): AsyncResult<U, X>; | ||
orElse<U>(defaultValue: U): IAsyncResult<T | U, never>; | ||
map<U>(mapper: (val: T) => U): IAsyncResult<U, X>; | ||
get(): Promise<T>; | ||
} | ||
export {}; |
@@ -27,7 +27,7 @@ "use strict"; | ||
} | ||
static of(value) { | ||
return new AsyncOk(value); | ||
static Ok(value) { | ||
return AsyncOk.of(value); | ||
} | ||
static ofErr(error) { | ||
return new AsyncErr(error); | ||
static Err(error) { | ||
return AsyncErr.of(error); | ||
} | ||
@@ -83,2 +83,5 @@ async *[(_promise = new WeakMap(), Symbol.asyncIterator)]() { | ||
class AsyncOk extends AsyncResult { | ||
static of(value) { | ||
return new AsyncOk(value); | ||
} | ||
constructor(value) { | ||
@@ -89,2 +92,5 @@ super(Promise.resolve(value)); | ||
class AsyncErr extends AsyncResult { | ||
static of(value) { | ||
return new AsyncErr(value); | ||
} | ||
constructor(err) { | ||
@@ -91,0 +97,0 @@ super(Promise.reject(err)); |
@@ -1,13 +0,15 @@ | ||
export declare abstract class Optional<T> implements Iterable<T> { | ||
static of<T>(value: T): Optional<T>; | ||
static ofNone(): Optional<never>; | ||
abstract [Symbol.iterator](): Iterator<T>; | ||
abstract isSome(): boolean; | ||
abstract isNone(): boolean; | ||
abstract onSome(callback: (val: T) => void): Optional<T>; | ||
abstract onNone(callback: () => void): Optional<T>; | ||
abstract orElse<U>(defaultValue: U): Optional<T | U>; | ||
abstract map<U>(mapper: (val: T) => U): Optional<U>; | ||
abstract filter<U extends T = T>(predicate: (val: T) => boolean): Optional<U>; | ||
abstract get(): T; | ||
export interface IOptional<T> extends Iterable<T> { | ||
[Symbol.iterator](): Iterator<T, void>; | ||
isSome(): boolean; | ||
isNone(): boolean; | ||
onSome(callback: (val: T) => void): IOptional<T>; | ||
onNone(callback: () => void): IOptional<T>; | ||
orElse<U>(defaultValue: U): IOptional<T | U>; | ||
map<U>(mapper: (val: T) => U): IOptional<U>; | ||
filter<U extends T = T>(predicate: (val: T) => boolean): IOptional<U>; | ||
get(): T; | ||
} | ||
export declare abstract class Optional { | ||
static Some<T>(value: T): IOptional<T>; | ||
static None(): IOptional<never>; | ||
} |
@@ -19,7 +19,7 @@ "use strict"; | ||
class Optional { | ||
static of(value) { | ||
return new Some(value); | ||
static Some(value) { | ||
return Some.of(value); | ||
} | ||
static ofNone() { | ||
return new None(); | ||
static None() { | ||
return None.of(); | ||
} | ||
@@ -34,2 +34,5 @@ } | ||
} | ||
static of(value) { | ||
return new Some(value); | ||
} | ||
*[(_value = new WeakMap(), Symbol.iterator)]() { | ||
@@ -46,19 +49,19 @@ yield __classPrivateFieldGet(this, _value); | ||
callback(__classPrivateFieldGet(this, _value)); | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
onNone() { | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
orElse() { | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
map(mapper) { | ||
return Optional.of(mapper(__classPrivateFieldGet(this, _value))); | ||
return Some.of(mapper(__classPrivateFieldGet(this, _value))); | ||
} | ||
filter(predicate) { | ||
if (predicate(__classPrivateFieldGet(this, _value))) { | ||
return Optional.of(__classPrivateFieldGet(this, _value)); | ||
return Some.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
else { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -71,2 +74,8 @@ } | ||
class None extends Optional { | ||
static of() { | ||
return new None(); | ||
} | ||
constructor() { | ||
super(); | ||
} | ||
*[Symbol.iterator]() { } | ||
@@ -79,17 +88,17 @@ isSome() { | ||
} | ||
onSome(_) { | ||
return Optional.ofNone(); | ||
onSome() { | ||
return None.of(); | ||
} | ||
onNone(callback) { | ||
callback(); | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
orElse(defaultValue) { | ||
return Optional.of(defaultValue); | ||
return Some.of(defaultValue); | ||
} | ||
map() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
filter() { | ||
return Optional.ofNone(); | ||
return None.of(); | ||
} | ||
@@ -96,0 +105,0 @@ get() { |
@@ -1,12 +0,14 @@ | ||
export declare abstract class Result<T, X> implements Iterable<T> { | ||
static of<T>(value: T): Result<T, never>; | ||
static ofErr<X>(error: X): Result<never, X>; | ||
abstract [Symbol.iterator](): Iterator<T>; | ||
abstract isOk(): boolean; | ||
abstract isErr(): boolean; | ||
abstract onOk(callback: (val: T) => void): Result<T, X>; | ||
abstract onErr(callback: (err: X) => void): Result<T, X>; | ||
abstract orElse<U>(defaultValue: U): Result<T | U, never>; | ||
abstract map<U>(mapper: (val: T) => U): Result<U, X>; | ||
abstract get(): T; | ||
export interface IResult<T, X> extends Iterable<T> { | ||
[Symbol.iterator](): Iterator<T, void>; | ||
isOk(): boolean; | ||
isErr(): boolean; | ||
onOk(callback: (val: T) => void): IResult<T, X>; | ||
onErr(callback: (err: X) => void): IResult<T, X>; | ||
orElse<U>(defaultValue: U): IResult<T, never> | IResult<U, never>; | ||
map<U>(mapper: (val: T) => U): IResult<U, X>; | ||
get(): T; | ||
} | ||
export declare abstract class Result { | ||
static Ok<T>(value: T): IResult<T, never>; | ||
static Err<T>(error: T): IResult<never, T>; | ||
} |
@@ -19,7 +19,7 @@ "use strict"; | ||
class Result { | ||
static of(value) { | ||
return new Ok(value); | ||
static Ok(value) { | ||
return Ok.of(value); | ||
} | ||
static ofErr(error) { | ||
return new Err(error); | ||
static Err(error) { | ||
return Err.of(error); | ||
} | ||
@@ -34,2 +34,5 @@ } | ||
} | ||
static of(value) { | ||
return new Ok(value); | ||
} | ||
*[(_value = new WeakMap(), Symbol.iterator)]() { | ||
@@ -46,12 +49,12 @@ yield __classPrivateFieldGet(this, _value); | ||
callback(__classPrivateFieldGet(this, _value)); | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
onErr() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
orElse() { | ||
return Result.of(__classPrivateFieldGet(this, _value)); | ||
return Ok.of(__classPrivateFieldGet(this, _value)); | ||
} | ||
map(mapper) { | ||
return Result.of(mapper(__classPrivateFieldGet(this, _value))); | ||
map(fn) { | ||
return Ok.of(fn(__classPrivateFieldGet(this, _value))); | ||
} | ||
@@ -68,2 +71,5 @@ get() { | ||
} | ||
static of(error) { | ||
return new Err(error); | ||
} | ||
*[(_value_1 = new WeakMap(), Symbol.iterator)]() { } | ||
@@ -77,13 +83,13 @@ isOk() { | ||
onOk() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
onErr(callback) { | ||
callback(__classPrivateFieldGet(this, _value_1)); | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
orElse(defaultValue) { | ||
return Result.of(defaultValue); | ||
return Ok.of(defaultValue); | ||
} | ||
map() { | ||
return Result.ofErr(__classPrivateFieldGet(this, _value_1)); | ||
return Err.of(__classPrivateFieldGet(this, _value_1)); | ||
} | ||
@@ -90,0 +96,0 @@ get() { |
@@ -1,3 +0,3 @@ | ||
import { AsyncOptional } from '../classes/async-optional'; | ||
export declare function toOptionalPromisePartial<T>(isNone: (val: T) => boolean): (promise: PromiseLike<T>) => AsyncOptional<T>; | ||
export declare function toOptionalPromise<T>(promise: PromiseLike<T>, isNone: (val: T) => boolean): AsyncOptional<T>; | ||
import { IAsyncOptional } from '../classes/async-optional'; | ||
export declare function toOptionalPromisePartial<T>(isNone: (val: T) => boolean): (promise: PromiseLike<T>) => IAsyncOptional<T>; | ||
export declare function toOptionalPromise<T>(promise: PromiseLike<T>, isNone: (val: T) => boolean): IAsyncOptional<T>; |
@@ -13,3 +13,3 @@ "use strict"; | ||
if (isNone(result)) | ||
return async_optional_1.None; | ||
return async_optional_1.Nil; | ||
return result; | ||
@@ -16,0 +16,0 @@ })()); |
@@ -1,3 +0,3 @@ | ||
import { Optional } from '../classes/optional'; | ||
export declare function toOptionalPartial<T>(isNone: (val: T) => boolean): (fn: () => T) => Optional<T>; | ||
export declare function toOptional<T>(fn: () => T, isNone: (val: T) => boolean): Optional<T>; | ||
import { IOptional } from '../classes/optional'; | ||
export declare function toOptionalPartial<T>(isNone: (val: T) => boolean): (fn: () => T) => IOptional<T>; | ||
export declare function toOptional<T>(fn: () => T, isNone: (val: T) => boolean): IOptional<T>; |
@@ -12,6 +12,6 @@ "use strict"; | ||
if (isNone(result)) { | ||
return optional_1.Optional.ofNone(); | ||
return optional_1.Optional.None(); | ||
} | ||
else { | ||
return optional_1.Optional.of(result); | ||
return optional_1.Optional.Some(result); | ||
} | ||
@@ -18,0 +18,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AsyncResult } from '../classes/async-result'; | ||
export declare function toResultAsync<T, X = any>(fn: () => PromiseLike<T>): AsyncResult<T, X>; | ||
import { IAsyncResult } from '../classes/async-result'; | ||
export declare function toResultAsync<T, X = any>(fn: () => PromiseLike<T>): IAsyncResult<T, X>; |
@@ -11,3 +11,3 @@ "use strict"; | ||
catch (e) { | ||
return async_result_1.AsyncResult.ofErr(e); | ||
return async_result_1.AsyncResult.Err(e); | ||
} | ||
@@ -14,0 +14,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AsyncResult } from '../classes/async-result'; | ||
export declare function toResultPromise<T, X = any>(promise: PromiseLike<T>): AsyncResult<T, X>; | ||
import { IAsyncResult } from '../classes/async-result'; | ||
export declare function toResultPromise<T, X = any>(promise: PromiseLike<T>): IAsyncResult<T, X>; |
@@ -1,2 +0,2 @@ | ||
import { Result } from '../classes/result'; | ||
export declare function toResult<T, X = any>(fn: () => T): Result<T, X>; | ||
import { IResult } from '../classes/result'; | ||
export declare function toResult<T, X = any>(fn: () => T): IResult<T, X>; |
@@ -8,6 +8,6 @@ "use strict"; | ||
const result = fn(); | ||
return result_1.Result.of(result); | ||
return result_1.Result.Ok(result); | ||
} | ||
catch (e) { | ||
return result_1.Result.ofErr(e); | ||
return result_1.Result.Err(e); | ||
} | ||
@@ -14,0 +14,0 @@ } |
{ | ||
"name": "return-style", | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"description": "Non-intrusively convert the result of any function or promise to the user's desired style.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -192,3 +192,3 @@ # return-style | ||
### Result: Ok / Err | ||
### Result<T, X> = Ok<T> | Err<X> | ||
@@ -201,3 +201,3 @@ * `function toResult<T, X = any>(fn: () => T): Result<T, X>` | ||
interface Result<T, X> { | ||
[Symbol.iterator](): Iterator<T> | ||
[Symbol.iterator](): Iterator<T, void> | ||
@@ -217,3 +217,3 @@ onOk(callback: (val: T) => void): Result<T, X> | ||
interface AsyncResult<T, X> { | ||
[Symbol.asyncIterator](): AsyncIterator<T> | ||
[Symbol.asyncIterator](): AsyncIterator<T, void> | ||
@@ -233,6 +233,6 @@ onOk(callback: (val: T) => void): AsyncResult<T, X> | ||
### Optional: Some / None | ||
### Optional<T> = Some<T> | None | ||
* `function toOptional<T>(fn: () => T | U, isNone: (val: T) => boolean): Option<T>` | ||
* `function toOptionalPartial<T>(isNone: (val: T) => boolean): (fn: () => T | U) => Option<T>` | ||
* `function toOptional<T>(fn: () => T | U, isNone: (val: T) => boolean): Optional<T>` | ||
* `function toOptionalPartial<T>(isNone: (val: T) => boolean): (fn: () => T | U) => Optional<T>` | ||
* `function toOptionalPromise<T>(promise: PromiseLike<T>, isNone: (val: T) => boolean): AsyncOptional<T>` | ||
@@ -243,3 +243,3 @@ * `function toOptionalPromisePartial<T>(isNone: (val: T) => boolean): (promise: PromiseLike<T>) => AsyncOptional<T>` | ||
interface Optional<T> { | ||
[Symbol.iterator](): Iterator<T> | ||
[Symbol.iterator](): Iterator<T, void> | ||
@@ -260,3 +260,3 @@ onSome(callback: (val: T) => void): this | ||
interface AsyncOptional<T> { | ||
[Symbol.asyncIterator](): AsyncIterator<T> | ||
[Symbol.asyncIterator](): AsyncIterator<T, void> | ||
@@ -263,0 +263,0 @@ onSome(callback: (val: T) => void): this |
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
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
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
581850
5234