Comparing version 0.16.3 to 1.0.0
@@ -62,6 +62,2 @@ import { Maybe } from './Maybe'; | ||
leftToMaybe(): Maybe<L>; | ||
/** Given two map functions, maps using the first if `this` is `Left` or using the second one if `this` is `Right`. | ||
* If you want the functions to return different types depending on the either you may want to use `Either#bimap` instead | ||
* */ | ||
either<T>(ifLeft: (value: L) => T, ifRight: (value: R) => T): T; | ||
/** Extracts the value out of `this` */ | ||
@@ -68,0 +64,0 @@ extract(): L | R; |
@@ -190,5 +190,2 @@ "use strict"; | ||
}; | ||
Right.prototype.either = function (_, ifRight) { | ||
return ifRight(this.__value); | ||
}; | ||
Right.prototype.extract = function () { | ||
@@ -300,5 +297,2 @@ return this.__value; | ||
}; | ||
Left.prototype.either = function (ifLeft, _) { | ||
return ifLeft(this.__value); | ||
}; | ||
Left.prototype.extract = function () { | ||
@@ -305,0 +299,0 @@ return this.__value; |
@@ -1,2 +0,2 @@ | ||
import { Either } from './Either'; | ||
import { Either, EitherPatterns } from './Either'; | ||
import { MaybeAsync } from './MaybeAsync'; | ||
@@ -66,2 +66,5 @@ export interface EitherAsyncTypeRef { | ||
void(): EitherAsync<L, void>; | ||
/** Structural pattern matching for `EitherAsync` in the form of a function */ | ||
caseOf<T>(patterns: EitherPatterns<L, R, T>): Promise<T>; | ||
finally(effect: () => any): EitherAsync<L, R>; | ||
'fantasy-land/map'<R2>(f: (value: R) => R2): EitherAsync<L, R2>; | ||
@@ -68,0 +71,0 @@ 'fantasy-land/bimap'<L2, R2>(f: (value: L) => L2, g: (value: R) => R2): EitherAsync<L2, R2>; |
@@ -45,2 +45,3 @@ "use strict"; | ||
}; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -68,3 +69,3 @@ exports.EitherAsync = void 0; | ||
this.runPromise = runPromise; | ||
this[Symbol.toStringTag] = 'EitherAsync'; | ||
this[_a] = 'EitherAsync'; | ||
this['fantasy-land/map'] = this.map; | ||
@@ -90,11 +91,11 @@ this['fantasy-land/bimap'] = this.bimap; | ||
var either, nestedEither; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this]; | ||
case 1: | ||
either = _a.sent(); | ||
either = _b.sent(); | ||
if (!either.isRight()) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, either.extract()]; | ||
case 2: | ||
nestedEither = _a.sent(); | ||
nestedEither = _b.sent(); | ||
return [2 /*return*/, helpers.liftEither(nestedEither)]; | ||
@@ -110,11 +111,11 @@ case 3: return [2 /*return*/, helpers.liftEither(either)]; | ||
var otherValue, thisValue; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, eitherF]; | ||
case 1: | ||
otherValue = _a.sent(); | ||
otherValue = _b.sent(); | ||
if (!otherValue.isRight()) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, this]; | ||
case 2: | ||
thisValue = _a.sent(); | ||
thisValue = _b.sent(); | ||
if (thisValue.isRight()) { | ||
@@ -126,3 +127,3 @@ return [2 /*return*/, otherValue.extract()(thisValue.extract())]; | ||
} | ||
_a.label = 3; | ||
_b.label = 3; | ||
case 3: return [2 /*return*/, helpers.liftEither(otherValue)]; | ||
@@ -137,7 +138,7 @@ } | ||
var thisValue, otherValue; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this]; | ||
case 1: | ||
thisValue = _a.sent(); | ||
thisValue = _b.sent(); | ||
if (!thisValue.isRight()) return [3 /*break*/, 2]; | ||
@@ -147,3 +148,3 @@ return [2 /*return*/, thisValue.extract()]; | ||
case 3: | ||
otherValue = _a.sent(); | ||
otherValue = _b.sent(); | ||
return [2 /*return*/, helpers.liftEither(otherValue)]; | ||
@@ -158,7 +159,7 @@ } | ||
var either, v; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
either = _a.sent(); | ||
either = _b.sent(); | ||
if (either.isRight()) { | ||
@@ -175,12 +176,12 @@ v = exports.EitherAsync.liftEither(either); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, e_1; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var _b, e_1; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
_a = Either_1.Right; | ||
_c.trys.push([0, 2, , 3]); | ||
_b = Either_1.Right; | ||
return [4 /*yield*/, this.runPromise(helpers)]; | ||
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])]; | ||
case 1: return [2 /*return*/, _b.apply(void 0, [_c.sent()])]; | ||
case 2: | ||
e_1 = _b.sent(); | ||
e_1 = _c.sent(); | ||
return [2 /*return*/, Either_1.Left(e_1)]; | ||
@@ -196,7 +197,7 @@ case 3: return [2 /*return*/]; | ||
var either; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
either = _a.sent(); | ||
either = _b.sent(); | ||
return [2 /*return*/, helpers.liftEither(either.bimap(f, g))]; | ||
@@ -215,10 +216,10 @@ } | ||
var e_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
_b.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.runPromise(helpers)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 1: return [2 /*return*/, _b.sent()]; | ||
case 2: | ||
e_2 = _a.sent(); | ||
e_2 = _b.sent(); | ||
throw f(e_2); | ||
@@ -234,7 +235,7 @@ case 3: return [2 /*return*/]; | ||
var value; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.runPromise(helpers)]; | ||
case 1: | ||
value = _a.sent(); | ||
value = _b.sent(); | ||
return [2 /*return*/, helpers.fromPromise(f(value))]; | ||
@@ -249,10 +250,10 @@ } | ||
var e_3; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
_b.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.runPromise(helpers)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 1: return [2 /*return*/, _b.sent()]; | ||
case 2: | ||
e_3 = _a.sent(); | ||
e_3 = _b.sent(); | ||
return [2 /*return*/, helpers.fromPromise(f(e_3))]; | ||
@@ -266,11 +267,11 @@ case 3: return [2 /*return*/]; | ||
var _this = this; | ||
return MaybeAsync_1.MaybeAsync(function (_a) { | ||
var liftMaybe = _a.liftMaybe; | ||
return MaybeAsync_1.MaybeAsync(function (_b) { | ||
var liftMaybe = _b.liftMaybe; | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var either; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
either = _b.sent(); | ||
either = _c.sent(); | ||
return [2 /*return*/, liftMaybe(either.toMaybe())]; | ||
@@ -286,7 +287,7 @@ } | ||
var either; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
either = _a.sent(); | ||
either = _b.sent(); | ||
if (either.isRight()) | ||
@@ -303,7 +304,7 @@ helpers.throwE(either.extract()); | ||
var either; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
either = _a.sent(); | ||
either = _b.sent(); | ||
either.ifLeft(effect); | ||
@@ -319,7 +320,7 @@ return [2 /*return*/, helpers.liftEither(either)]; | ||
var either; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
either = _a.sent(); | ||
either = _b.sent(); | ||
either.ifRight(effect); | ||
@@ -334,12 +335,23 @@ return [2 /*return*/, helpers.liftEither(either)]; | ||
}; | ||
EitherAsyncImpl.prototype.caseOf = function (patterns) { | ||
return this.run().then(function (x) { return x.caseOf(patterns); }); | ||
}; | ||
EitherAsyncImpl.prototype.finally = function (effect) { | ||
var _this = this; | ||
return exports.EitherAsync(function (_b) { | ||
var fromPromise = _b.fromPromise; | ||
return fromPromise(_this.run().finally(effect)); | ||
}); | ||
}; | ||
return EitherAsyncImpl; | ||
}()); | ||
_a = Symbol.toStringTag; | ||
exports.EitherAsync = Object.assign(function (runPromise) { return new EitherAsyncImpl(runPromise); }, { | ||
fromPromise: function (f) { return exports.EitherAsync(function (_a) { | ||
var fP = _a.fromPromise; | ||
fromPromise: function (f) { return exports.EitherAsync(function (_b) { | ||
var fP = _b.fromPromise; | ||
return fP(f()); | ||
}); }, | ||
liftEither: function (either) { | ||
return exports.EitherAsync(function (_a) { | ||
var liftEither = _a.liftEither; | ||
return exports.EitherAsync(function (_b) { | ||
var liftEither = _b.liftEither; | ||
return liftEither(either); | ||
@@ -357,15 +369,15 @@ }); | ||
var res, eas_1, eas_1_1, e, e_4_1; | ||
var e_4, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var e_4, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
res = []; | ||
_b.label = 1; | ||
_c.label = 1; | ||
case 1: | ||
_b.trys.push([1, 6, 7, 12]); | ||
_c.trys.push([1, 6, 7, 12]); | ||
eas_1 = __asyncValues(eas); | ||
_b.label = 2; | ||
_c.label = 2; | ||
case 2: return [4 /*yield*/, eas_1.next()]; | ||
case 3: | ||
if (!(eas_1_1 = _b.sent(), !eas_1_1.done)) return [3 /*break*/, 5]; | ||
if (!(eas_1_1 = _c.sent(), !eas_1_1.done)) return [3 /*break*/, 5]; | ||
e = eas_1_1.value; | ||
@@ -376,16 +388,16 @@ if (e.isLeft()) { | ||
res.push(e.extract()); | ||
_b.label = 4; | ||
_c.label = 4; | ||
case 4: return [3 /*break*/, 2]; | ||
case 5: return [3 /*break*/, 12]; | ||
case 6: | ||
e_4_1 = _b.sent(); | ||
e_4_1 = _c.sent(); | ||
e_4 = { error: e_4_1 }; | ||
return [3 /*break*/, 12]; | ||
case 7: | ||
_b.trys.push([7, , 10, 11]); | ||
if (!(eas_1_1 && !eas_1_1.done && (_a = eas_1.return))) return [3 /*break*/, 9]; | ||
return [4 /*yield*/, _a.call(eas_1)]; | ||
_c.trys.push([7, , 10, 11]); | ||
if (!(eas_1_1 && !eas_1_1.done && (_b = eas_1.return))) return [3 /*break*/, 9]; | ||
return [4 /*yield*/, _b.call(eas_1)]; | ||
case 8: | ||
_b.sent(); | ||
_b.label = 9; | ||
_c.sent(); | ||
_c.label = 9; | ||
case 9: return [3 /*break*/, 11]; | ||
@@ -402,3 +414,3 @@ case 10: | ||
all: function (eas) { | ||
return exports.EitherAsync.fromPromise(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return exports.EitherAsync.fromPromise(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_b) { | ||
return [2 /*return*/, Promise.all(eas).then(Either_1.Either.sequence)]; | ||
@@ -405,0 +417,0 @@ }); }); }); |
@@ -62,6 +62,2 @@ import { Maybe } from './Maybe'; | ||
leftToMaybe(): Maybe<L>; | ||
/** Given two map functions, maps using the first if `this` is `Left` or using the second one if `this` is `Right`. | ||
* If you want the functions to return different types depending on the either you may want to use `Either#bimap` instead | ||
* */ | ||
either<T>(ifLeft: (value: L) => T, ifRight: (value: R) => T): T; | ||
/** Extracts the value out of `this` */ | ||
@@ -68,0 +64,0 @@ extract(): L | R; |
@@ -146,5 +146,2 @@ "use strict"; | ||
} | ||
either(_, ifRight) { | ||
return ifRight(this.__value); | ||
} | ||
extract() { | ||
@@ -255,5 +252,2 @@ return this.__value; | ||
} | ||
either(ifLeft, _) { | ||
return ifLeft(this.__value); | ||
} | ||
extract() { | ||
@@ -260,0 +254,0 @@ return this.__value; |
@@ -1,2 +0,2 @@ | ||
import { Either } from './Either'; | ||
import { Either, EitherPatterns } from './Either'; | ||
import { MaybeAsync } from './MaybeAsync'; | ||
@@ -66,2 +66,5 @@ export interface EitherAsyncTypeRef { | ||
void(): EitherAsync<L, void>; | ||
/** Structural pattern matching for `EitherAsync` in the form of a function */ | ||
caseOf<T>(patterns: EitherPatterns<L, R, T>): Promise<T>; | ||
finally(effect: () => any): EitherAsync<L, R>; | ||
'fantasy-land/map'<R2>(f: (value: R) => R2): EitherAsync<L, R2>; | ||
@@ -68,0 +71,0 @@ 'fantasy-land/bimap'<L2, R2>(f: (value: L) => L2, g: (value: R) => R2): EitherAsync<L2, R2>; |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -23,3 +24,3 @@ exports.EitherAsync = void 0; | ||
this.runPromise = runPromise; | ||
this[Symbol.toStringTag] = 'EitherAsync'; | ||
this[_a] = 'EitherAsync'; | ||
this['fantasy-land/map'] = this.map; | ||
@@ -162,3 +163,10 @@ this['fantasy-land/bimap'] = this.bimap; | ||
} | ||
caseOf(patterns) { | ||
return this.run().then((x) => x.caseOf(patterns)); | ||
} | ||
finally(effect) { | ||
return exports.EitherAsync(({ fromPromise }) => fromPromise(this.run().finally(effect))); | ||
} | ||
} | ||
_a = Symbol.toStringTag; | ||
exports.EitherAsync = Object.assign((runPromise) => new EitherAsyncImpl(runPromise), { | ||
@@ -165,0 +173,0 @@ fromPromise: (f) => exports.EitherAsync(({ fromPromise: fP }) => fP(f())), |
@@ -17,5 +17,5 @@ /** The identity function, returns the value it was given */ | ||
}, any[]>; | ||
declare type CurriedFn<TAllArgs extends any[], TReturn> = <TProvidedArgs extends TAllArgs extends [infer TFirstArg, ...infer TRestOfArgs] ? [TFirstArg, ...Partial<TRestOfArgs>] : never>(...args: TProvidedArgs) => TProvidedArgs extends TAllArgs ? TReturn : TAllArgs extends [...TupleOfLength<TProvidedArgs>, ...infer TRestOfArgs] ? CurriedFn<TRestOfArgs, TReturn> : never; | ||
export declare type CurriedFn<TAllArgs extends any[], TReturn> = <TProvidedArgs extends TAllArgs extends [infer TFirstArg, ...infer TRestOfArgs] ? [TFirstArg, ...Partial<TRestOfArgs>] : never>(...args: TProvidedArgs) => TProvidedArgs extends TAllArgs ? TReturn : TAllArgs extends [...TupleOfLength<TProvidedArgs>, ...infer TRestOfArgs] ? CurriedFn<TRestOfArgs, TReturn> : never; | ||
/** Takes a function that receives multiple arguments and returns a "curried" version of that function that can take any number of those arguments and if they are less than needed a new function that takes the rest of them will be returned */ | ||
export declare const curry: <TArgs extends any[], TReturn>(fn: (...args: TArgs) => TReturn) => CurriedFn<TArgs, TReturn>; | ||
export {}; |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -20,3 +21,3 @@ exports.MaybeAsync = void 0; | ||
this.runPromise = runPromise; | ||
this[Symbol.toStringTag] = 'MaybeAsync'; | ||
this[_a] = 'MaybeAsync'; | ||
this['fantasy-land/map'] = this.map; | ||
@@ -89,3 +90,3 @@ this['fantasy-land/chain'] = this.chain; | ||
} | ||
catch (_a) { | ||
catch (_b) { | ||
return Maybe_1.Nothing; | ||
@@ -130,2 +131,3 @@ } | ||
} | ||
_a = Symbol.toStringTag; | ||
exports.MaybeAsync = Object.assign((runPromise) => new MaybeAsyncImpl(runPromise), { | ||
@@ -132,0 +134,0 @@ catMaybes: (list) => Promise.all(list).then(Maybe_1.Maybe.catMaybes), |
@@ -17,5 +17,5 @@ /** The identity function, returns the value it was given */ | ||
}, any[]>; | ||
declare type CurriedFn<TAllArgs extends any[], TReturn> = <TProvidedArgs extends TAllArgs extends [infer TFirstArg, ...infer TRestOfArgs] ? [TFirstArg, ...Partial<TRestOfArgs>] : never>(...args: TProvidedArgs) => TProvidedArgs extends TAllArgs ? TReturn : TAllArgs extends [...TupleOfLength<TProvidedArgs>, ...infer TRestOfArgs] ? CurriedFn<TRestOfArgs, TReturn> : never; | ||
export declare type CurriedFn<TAllArgs extends any[], TReturn> = <TProvidedArgs extends TAllArgs extends [infer TFirstArg, ...infer TRestOfArgs] ? [TFirstArg, ...Partial<TRestOfArgs>] : never>(...args: TProvidedArgs) => TProvidedArgs extends TAllArgs ? TReturn : TAllArgs extends [...TupleOfLength<TProvidedArgs>, ...infer TRestOfArgs] ? CurriedFn<TRestOfArgs, TReturn> : never; | ||
/** Takes a function that receives multiple arguments and returns a "curried" version of that function that can take any number of those arguments and if they are less than needed a new function that takes the rest of them will be returned */ | ||
export declare const curry: <TArgs extends any[], TReturn>(fn: (...args: TArgs) => TReturn) => CurriedFn<TArgs, TReturn>; | ||
export {}; |
@@ -29,3 +29,7 @@ "use strict"; | ||
/** Returns a function that always returns the same value. Also known as `const` in other languages */ | ||
var always = function (x) { return function () { return x; }; }; | ||
var always = function (x) { | ||
return function () { | ||
return x; | ||
}; | ||
}; | ||
exports.always = always; | ||
@@ -32,0 +36,0 @@ var Order; |
@@ -38,2 +38,3 @@ "use strict"; | ||
}; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -57,3 +58,3 @@ exports.MaybeAsync = void 0; | ||
this.runPromise = runPromise; | ||
this[Symbol.toStringTag] = 'MaybeAsync'; | ||
this[_a] = 'MaybeAsync'; | ||
this['fantasy-land/map'] = this.map; | ||
@@ -73,11 +74,11 @@ this['fantasy-land/chain'] = this.chain; | ||
var maybe, nestedMaybe; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
maybe = _a.sent(); | ||
maybe = _b.sent(); | ||
if (!maybe.isJust()) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, maybe.extract()]; | ||
case 2: | ||
nestedMaybe = _a.sent(); | ||
nestedMaybe = _b.sent(); | ||
return [2 /*return*/, helpers.liftMaybe(nestedMaybe)]; | ||
@@ -93,11 +94,11 @@ case 3: return [2 /*return*/, helpers.liftMaybe(Maybe_1.Nothing)]; | ||
var otherValue, thisValue; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, maybeF]; | ||
case 1: | ||
otherValue = _a.sent(); | ||
otherValue = _b.sent(); | ||
if (!otherValue.isJust()) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, this]; | ||
case 2: | ||
thisValue = _a.sent(); | ||
thisValue = _b.sent(); | ||
if (thisValue.isJust()) { | ||
@@ -109,3 +110,3 @@ return [2 /*return*/, otherValue.extract()(thisValue.extract())]; | ||
} | ||
_a.label = 3; | ||
_b.label = 3; | ||
case 3: return [2 /*return*/, helpers.liftMaybe(Maybe_1.Nothing)]; | ||
@@ -120,7 +121,7 @@ } | ||
var thisValue, otherValue; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this]; | ||
case 1: | ||
thisValue = _a.sent(); | ||
thisValue = _b.sent(); | ||
if (!thisValue.isJust()) return [3 /*break*/, 2]; | ||
@@ -130,3 +131,3 @@ return [2 /*return*/, thisValue.extract()]; | ||
case 3: | ||
otherValue = _a.sent(); | ||
otherValue = _b.sent(); | ||
return [2 /*return*/, helpers.liftMaybe(otherValue)]; | ||
@@ -141,7 +142,7 @@ } | ||
var maybe, v; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
maybe = _a.sent(); | ||
maybe = _b.sent(); | ||
if (maybe.isJust()) { | ||
@@ -160,7 +161,7 @@ v = exports.MaybeAsync.liftMaybe(maybe); | ||
var value; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
value = _a.sent(); | ||
value = _b.sent(); | ||
return [2 /*return*/, helpers.liftMaybe(value.filter(pred))]; | ||
@@ -173,12 +174,12 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var _b, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
_c.trys.push([0, 2, , 3]); | ||
_a = Maybe_1.Just; | ||
_d.trys.push([0, 2, , 3]); | ||
_b = Maybe_1.Just; | ||
return [4 /*yield*/, this.runPromise(helpers)]; | ||
case 1: return [2 /*return*/, _a.apply(void 0, [_c.sent()])]; | ||
case 1: return [2 /*return*/, _b.apply(void 0, [_d.sent()])]; | ||
case 2: | ||
_b = _c.sent(); | ||
_c = _d.sent(); | ||
return [2 /*return*/, Maybe_1.Nothing]; | ||
@@ -198,7 +199,7 @@ case 3: return [2 /*return*/]; | ||
var value; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.runPromise(helpers)]; | ||
case 1: | ||
value = _a.sent(); | ||
value = _b.sent(); | ||
return [2 /*return*/, helpers.fromPromise(f(value))]; | ||
@@ -211,11 +212,11 @@ } | ||
var _this = this; | ||
return EitherAsync_1.EitherAsync(function (_a) { | ||
var liftEither = _a.liftEither; | ||
return EitherAsync_1.EitherAsync(function (_b) { | ||
var liftEither = _b.liftEither; | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var maybe; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
maybe = _b.sent(); | ||
maybe = _c.sent(); | ||
return [2 /*return*/, liftEither(maybe.toEither(error))]; | ||
@@ -231,7 +232,7 @@ } | ||
var maybe; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
maybe = _a.sent(); | ||
maybe = _b.sent(); | ||
maybe.ifJust(effect); | ||
@@ -247,7 +248,7 @@ return [2 /*return*/, helpers.liftMaybe(maybe)]; | ||
var maybe; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.run()]; | ||
case 1: | ||
maybe = _a.sent(); | ||
maybe = _b.sent(); | ||
maybe.ifNothing(effect); | ||
@@ -267,2 +268,3 @@ return [2 /*return*/, helpers.liftMaybe(maybe)]; | ||
}()); | ||
_a = Symbol.toStringTag; | ||
exports.MaybeAsync = Object.assign(function (runPromise) { return new MaybeAsyncImpl(runPromise); }, { | ||
@@ -273,4 +275,4 @@ catMaybes: function (list) { | ||
fromPromise: function (f) { | ||
return exports.MaybeAsync(function (_a) { | ||
var fP = _a.fromPromise; | ||
return exports.MaybeAsync(function (_b) { | ||
var fP = _b.fromPromise; | ||
return fP(f()); | ||
@@ -280,4 +282,4 @@ }); | ||
liftMaybe: function (maybe) { | ||
return exports.MaybeAsync(function (_a) { | ||
var liftMaybe = _a.liftMaybe; | ||
return exports.MaybeAsync(function (_b) { | ||
var liftMaybe = _b.liftMaybe; | ||
return liftMaybe(maybe); | ||
@@ -284,0 +286,0 @@ }); |
{ | ||
"name": "purify-ts", | ||
"version": "0.16.3", | ||
"version": "1.0.0", | ||
"description": "Functional programming standard library for TypeScript ", | ||
@@ -15,3 +15,4 @@ "main": "index.js", | ||
"coverage": "coveralls < coverage/lcov.info", | ||
"test-watch": "jest --watch" | ||
"test-watch": "jest --watch", | ||
"pretty": "prettier --write \"**/*.ts\"" | ||
}, | ||
@@ -31,14 +32,14 @@ "jest": { | ||
"devDependencies": { | ||
"@types/jest": "26.0.23", | ||
"ajv": "8.2.0", | ||
"@types/jest": "26.0.24", | ||
"ajv": "8.6.1", | ||
"ajv-formats": "2.1.0", | ||
"coveralls": "3.1.0", | ||
"jest": "26.6.3", | ||
"prettier": "2.2.1", | ||
"ts-jest": "26.5.6", | ||
"typescript": "4.2.4" | ||
"coveralls": "3.1.1", | ||
"jest": "27.0.6", | ||
"prettier": "2.3.2", | ||
"ts-jest": "27.0.3", | ||
"typescript": "4.3.5" | ||
}, | ||
"dependencies": { | ||
"@types/json-schema": "7.0.7" | ||
"@types/json-schema": "7.0.8" | ||
} | ||
} |
@@ -137,5 +137,7 @@ "use strict"; | ||
default: | ||
return function (g) { return function (value) { | ||
return exports.Tuple.fanout(f, g, value); | ||
}; }; | ||
return function (g) { | ||
return function (value) { | ||
return exports.Tuple.fanout(f, g, value); | ||
}; | ||
}; | ||
} | ||
@@ -142,0 +144,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
0
240589
43
5287
+ Added@types/json-schema@7.0.8(transitive)
- Removed@types/json-schema@7.0.7(transitive)
Updated@types/json-schema@7.0.8