Socket
Socket
Sign inDemoInstall

fluture

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluture - npm Package Compare versions

Comparing version 4.3.3 to 4.3.4

348

es5.js

@@ -139,4 +139,41 @@ 'use strict';

//Creates a dispatcher for a nullary method.
function createNullaryDispatcher(method) {
return function nullaryDispatch(m) {
if (m && typeof m[method] === 'function') return m[method]();
return error$invalidArgument('Future.' + method, 1, 'have a "' + method + '" method', m);
};
}
//Creates a dispatcher for a unary method.
function createUnaryDispatcher(method) {
return function unaryDispatch(a, m) {
if (arguments.length === 1) return unaryPartial(unaryDispatch, a);
if (m && typeof m[method] === 'function') return m[method](a);
return error$invalidArgument('Future.' + method, 1, 'have a "' + method + '" method', m);
};
}
//Creates a dispatcher for a binary method.
function createBinaryDispatcher(method) {
return function binaryDispatch(a, b, m) {
if (arguments.length === 1) return unaryPartial(binaryDispatch, a);
if (arguments.length === 2) return binaryPartial(binaryDispatch, a, b);
if (m && typeof m[method] === 'function') return m[method](a, b);
return error$invalidArgument('Future.' + method, 2, 'have a "' + method + '" method', m);
};
}
//Creates a dispatcher for a binary method, but takes the object first rather than last.
function createInvertedBinaryDispatcher(method) {
return function invertedBinaryDispatch(m, a, b) {
if (arguments.length === 1) return unaryPartial(invertedBinaryDispatch, m);
if (arguments.length === 2) return binaryPartial(invertedBinaryDispatch, m, a);
if (m && typeof m[method] === 'function') return m[method](a, b);
return error$invalidArgument('Future.' + method, 0, 'have a "' + method + '" method', m);
};
}
//Creates an error about an invalid argument.
function invalidArgument(it, at, expected, actual) {
function error$invalidArgument(it, at, expected, actual) {
throw new TypeError(it + ' expects its ' + ordinal[at] + ' argument to ' + expected + '\n Actual: ' + show(actual));

@@ -146,3 +183,3 @@ }

//Creates an error message about a method being called with an invalid context.
function invalidContext(it, actual) {
function error$invalidContext(it, actual) {
throw new TypeError(it + ' was invoked outside the context of a Future. You might want to use' + (' a dispatcher instead\n Called on: ' + show(actual)));

@@ -156,3 +193,3 @@ }

function Future(f) {
if (!isFunction(f)) invalidArgument('Future', 0, 'be a function', f);
if (!isFunction(f)) error$invalidArgument('Future', 0, 'be a function', f);
return new SafeFuture(f);

@@ -167,3 +204,3 @@ }

if (arguments.length === 1) return unaryPartial(Future$chainRec, f);
if (!isFunction(f)) invalidArgument('Future.chainRec', 0, 'be a function', f);
if (!isFunction(f)) error$invalidArgument('Future.chainRec', 0, 'be a function', f);
return new ChainRec(f, init);

@@ -183,4 +220,4 @@ }

Future.prototype.ap = function Future$ap(m) {
if (!isFuture(this)) invalidContext('Future#ap', this);
if (!isFuture(m)) invalidArgument('Future#ap', 0, 'be a Future', m);
if (!isFuture(this)) error$invalidContext('Future#ap', this);
if (!isFuture(m)) error$invalidArgument('Future#ap', 0, 'be a Future', m);
return new FutureAp(this, m);

@@ -190,4 +227,4 @@ };

Future.prototype.map = function Future$map(f) {
if (!isFuture(this)) invalidContext('Future#map', this);
if (!isFunction(f)) invalidArgument('Future#map', 0, 'be a function', f);
if (!isFuture(this)) error$invalidContext('Future#map', this);
if (!isFunction(f)) error$invalidArgument('Future#map', 0, 'be a function', f);
return new FutureMap(this, f);

@@ -197,5 +234,5 @@ };

Future.prototype.bimap = function Future$bimap(f, g) {
if (!isFuture(this)) invalidContext('Future#bimap', this);
if (!isFunction(f)) invalidArgument('Future#bimap', 0, 'be a function', f);
if (!isFunction(g)) invalidArgument('Future#bimap', 1, 'be a function', g);
if (!isFuture(this)) error$invalidContext('Future#bimap', this);
if (!isFunction(f)) error$invalidArgument('Future#bimap', 0, 'be a function', f);
if (!isFunction(g)) error$invalidArgument('Future#bimap', 1, 'be a function', g);
return new FutureBimap(this, f, g);

@@ -205,4 +242,4 @@ };

Future.prototype.chain = function Future$chain(f) {
if (!isFuture(this)) invalidContext('Future#chain', this);
if (!isFunction(f)) invalidArgument('Future#chain', 0, 'be a function', f);
if (!isFuture(this)) error$invalidContext('Future#chain', this);
if (!isFunction(f)) error$invalidArgument('Future#chain', 0, 'be a function', f);
return new FutureChain(this, f);

@@ -212,4 +249,4 @@ };

Future.prototype.chainRej = function Future$chainRej(f) {
if (!isFuture(this)) invalidContext('Future.chainRej', this);
if (!isFunction(f)) invalidArgument('Future.chainRej', 0, 'a function', f);
if (!isFuture(this)) error$invalidContext('Future.chainRej', this);
if (!isFunction(f)) error$invalidArgument('Future.chainRej', 0, 'a function', f);
return new FutureChainRej(this, f);

@@ -219,4 +256,4 @@ };

Future.prototype.mapRej = function Future$mapRej(f) {
if (!isFuture(this)) invalidContext('Future#mapRej', this);
if (!isFunction(f)) invalidArgument('Future#mapRej', 0, 'be a function', f);
if (!isFuture(this)) error$invalidContext('Future#mapRej', this);
if (!isFunction(f)) error$invalidArgument('Future#mapRej', 0, 'be a function', f);
return new FutureMapRej(this, f);

@@ -226,3 +263,3 @@ };

Future.prototype.swap = function Future$swap() {
if (!isFuture(this)) invalidContext('Future#swap', this);
if (!isFuture(this)) error$invalidContext('Future#swap', this);
return new FutureSwap(this);

@@ -232,4 +269,4 @@ };

Future.prototype.race = function Future$race(m) {
if (!isFuture(this)) invalidContext('Future#race', this);
if (!isFuture(m)) invalidArgument('Future#race', 0, 'be a Future', m);
if (!isFuture(this)) error$invalidContext('Future#race', this);
if (!isFuture(m)) error$invalidArgument('Future#race', 0, 'be a Future', m);
return new FutureRace(this, m);

@@ -239,4 +276,4 @@ };

Future.prototype.and = function Future$and(m) {
if (!isFuture(this)) invalidContext('Future#and', this);
if (!isFuture(m)) invalidArgument('Future#and', 0, 'be a Future', m);
if (!isFuture(this)) error$invalidContext('Future#and', this);
if (!isFuture(m)) error$invalidArgument('Future#and', 0, 'be a Future', m);
return new FutureAnd(this, m);

@@ -246,4 +283,4 @@ };

Future.prototype.or = function Future$or(m) {
if (!isFuture(this)) invalidContext('Future#or', this);
if (!isFuture(m)) invalidArgument('Future#or', 0, 'be a Future', m);
if (!isFuture(this)) error$invalidContext('Future#or', this);
if (!isFuture(m)) error$invalidArgument('Future#or', 0, 'be a Future', m);
return new FutureOr(this, m);

@@ -253,4 +290,4 @@ };

Future.prototype.both = function Future$both(m) {
if (!isFuture(this)) invalidContext('Future#both', this);
if (!isFuture(m)) invalidArgument('Future#both', 0, 'be a Future', m);
if (!isFuture(this)) error$invalidContext('Future#both', this);
if (!isFuture(m)) error$invalidArgument('Future#both', 0, 'be a Future', m);
return new FutureBoth(this, m);

@@ -260,5 +297,5 @@ };

Future.prototype.fold = function Future$fold(f, g) {
if (!isFuture(this)) invalidContext('Future#fold', this);
if (!isFunction(f)) invalidArgument('Future#fold', 0, 'be a function', f);
if (!isFunction(g)) invalidArgument('Future#fold', 1, 'be a function', g);
if (!isFuture(this)) error$invalidContext('Future#fold', this);
if (!isFunction(f)) error$invalidArgument('Future#fold', 0, 'be a function', f);
if (!isFunction(g)) error$invalidArgument('Future#fold', 1, 'be a function', g);
return new FutureFold(this, f, g);

@@ -268,5 +305,5 @@ };

Future.prototype.hook = function Future$hook(dispose, consume) {
if (!isFuture(this)) invalidContext('Future#hook', this);
if (!isFunction(dispose)) invalidArgument('Future#hook', 0, 'be a function', dispose);
if (!isFunction(consume)) invalidArgument('Future#hook', 1, 'be a function', consume);
if (!isFuture(this)) error$invalidContext('Future#hook', this);
if (!isFunction(dispose)) error$invalidArgument('Future#hook', 0, 'be a function', dispose);
if (!isFunction(consume)) error$invalidArgument('Future#hook', 1, 'be a function', consume);
return new FutureHook(this, dispose, consume);

@@ -276,4 +313,4 @@ };

Future.prototype.finally = function Future$finally(m) {
if (!isFuture(this)) invalidContext('Future#finally', this);
if (!isFuture(m)) invalidArgument('Future#finally', 0, 'be a Future', m);
if (!isFuture(this)) error$invalidContext('Future#finally', this);
if (!isFuture(m)) error$invalidArgument('Future#finally', 0, 'be a Future', m);
return new FutureFinally(this, m);

@@ -283,3 +320,3 @@ };

Future.prototype.cache = function Future$cache() {
if (!isFuture(this)) invalidContext('Future#cache', this);
if (!isFuture(this)) error$invalidContext('Future#cache', this);
return new CachedFuture(this);

@@ -289,5 +326,5 @@ };

Future.prototype.fork = function Future$fork(rej, res) {
if (!isFuture(this)) invalidContext('Future#fork', this);
if (!isFunction(rej)) invalidArgument('Future#fork', 0, 'be a function', rej);
if (!isFunction(res)) invalidArgument('Future#fork', 1, 'be a function', res);
if (!isFuture(this)) error$invalidContext('Future#fork', this);
if (!isFunction(rej)) error$invalidArgument('Future#fork', 0, 'be a function', rej);
if (!isFunction(res)) error$invalidArgument('Future#fork', 1, 'be a function', res);
return this._f(rej, res);

@@ -297,4 +334,4 @@ };

Future.prototype.value = function Future$value(f) {
if (!isFuture(this)) invalidContext('Future#value', this);
if (!isFunction(f)) invalidArgument('Future#value', 0, 'be a function', f);
if (!isFuture(this)) error$invalidContext('Future#value', this);
if (!isFunction(f)) error$invalidArgument('Future#value', 0, 'be a function', f);
return this._f(function Future$value$rej(e) {

@@ -306,3 +343,3 @@ throw new Error('Future#value was called on a rejected Future\n Actual: Future.reject(' + show(e) + ')');

Future.prototype.promise = function Future$promise() {
if (!isFuture(this)) invalidContext('Future#promise', this);
if (!isFuture(this)) error$invalidContext('Future#promise', this);
var _this = this;

@@ -320,3 +357,3 @@ return new Promise(function Future$promise$do(resolve, reject) {

function ap$mval(mval, mfunc) {
if (!Z.Apply.test(mfunc)) invalidArgument('Future.ap', 1, 'be an Apply', mfunc);
if (!Z.Apply.test(mfunc)) error$invalidArgument('Future.ap', 1, 'be an Apply', mfunc);
return Z.ap(mval, mfunc);

@@ -326,3 +363,3 @@ }

Future.ap = function ap(mval, mfunc) {
if (!Z.Apply.test(mval)) invalidArgument('Future.ap', 0, 'be an Apply', mval);
if (!Z.Apply.test(mval)) error$invalidArgument('Future.ap', 0, 'be an Apply', mval);
if (arguments.length === 1) return unaryPartial(ap$mval, mval);

@@ -333,3 +370,3 @@ return ap$mval(mval, mfunc);

function map$mapper(mapper, m) {
if (!Z.Functor.test(m)) invalidArgument('Future.map', 1, 'be a Functor', m);
if (!Z.Functor.test(m)) error$invalidArgument('Future.map', 1, 'be a Functor', m);
return Z.map(mapper, m);

@@ -339,3 +376,3 @@ }

Future.map = function map(mapper, m) {
if (!isFunction(mapper)) invalidArgument('Future.map', 0, 'be a Function', mapper);
if (!isFunction(mapper)) error$invalidArgument('Future.map', 0, 'be a Function', mapper);
if (arguments.length === 1) return unaryPartial(map$mapper, mapper);

@@ -346,3 +383,3 @@ return map$mapper(mapper, m);

function bimap$lmapper$rmapper(lmapper, rmapper, m) {
if (!Z.Bifunctor.test(m)) invalidArgument('Future.bimap', 2, 'be a Bifunctor', m);
if (!Z.Bifunctor.test(m)) error$invalidArgument('Future.bimap', 2, 'be a Bifunctor', m);
return Z.bimap(lmapper, rmapper, m);

@@ -352,3 +389,3 @@ }

function bimap$lmapper(lmapper, rmapper, m) {
if (!isFunction(rmapper)) invalidArgument('Future.bimap', 1, 'be a Function', rmapper);
if (!isFunction(rmapper)) error$invalidArgument('Future.bimap', 1, 'be a Function', rmapper);
if (arguments.length === 2) return binaryPartial(bimap$lmapper$rmapper, lmapper, rmapper);

@@ -359,5 +396,4 @@ return bimap$lmapper$rmapper(lmapper, rmapper, m);

Future.bimap = function bimap(lmapper, rmapper, m) {
if (!isFunction(lmapper)) invalidArgument('Future.bimap', 0, 'be a Function', lmapper);
if (!isFunction(lmapper)) error$invalidArgument('Future.bimap', 0, 'be a Function', lmapper);
if (arguments.length === 1) return unaryPartial(bimap$lmapper, lmapper);
if (arguments.length === 2) return bimap$lmapper(lmapper, rmapper);
return bimap$lmapper(lmapper, rmapper, m);

@@ -367,3 +403,3 @@ };

function chain$chainer(chainer, m) {
if (!Z.Chain.test(m)) invalidArgument('Future.chain', 1, 'be a Chain', m);
if (!Z.Chain.test(m)) error$invalidArgument('Future.chain', 1, 'be a Chain', m);
return Z.chain(chainer, m);

@@ -373,3 +409,3 @@ }

Future.chain = function chain(chainer, m) {
if (!isFunction(chainer)) invalidArgument('Future.chain', 0, 'be a Function', chainer);
if (!isFunction(chainer)) error$invalidArgument('Future.chain', 0, 'be a Function', chainer);
if (arguments.length === 1) return unaryPartial(chain$chainer, chainer);

@@ -380,3 +416,3 @@ return chain$chainer(chainer, m);

function and$left(left, right) {
if (!isFuture(right)) invalidArgument('Future.and', 1, 'be a Future', right);
if (!isFuture(right)) error$invalidArgument('Future.and', 1, 'be a Future', right);
return new FutureAnd(left, right);

@@ -386,3 +422,3 @@ }

Future.and = function and(left, right) {
if (!isFuture(left)) invalidArgument('Future.and', 0, 'be a Future', left);
if (!isFuture(left)) error$invalidArgument('Future.and', 0, 'be a Future', left);
if (arguments.length === 1) return unaryPartial(and$left, left);

@@ -393,3 +429,3 @@ return and$left(left, right);

function both$left(left, right) {
if (!isFuture(right)) invalidArgument('Future.both', 1, 'be a Future', right);
if (!isFuture(right)) error$invalidArgument('Future.both', 1, 'be a Future', right);
return new FutureBoth(left, right);

@@ -399,3 +435,3 @@ }

Future.both = function both(left, right) {
if (!isFuture(left)) invalidArgument('Future.both', 0, 'be a Future', left);
if (!isFuture(left)) error$invalidArgument('Future.both', 0, 'be a Future', left);
if (arguments.length === 1) return unaryPartial(both$left, left);

@@ -414,3 +450,3 @@ return both$left(left, right);

Future.after = function Future$after(n, x) {
if (!isPositiveInteger(n)) invalidArgument('Future.after', 0, 'be a positive integer', n);
if (!isPositiveInteger(n)) error$invalidArgument('Future.after', 0, 'be a positive integer', n);
if (arguments.length === 1) return unaryPartial(Future$after$n, n);

@@ -425,3 +461,3 @@ return Future$after$n(n, x);

Future.rejectAfter = function rejectAfter(time, reason) {
if (!isPositiveInteger(time)) invalidArgument('Future.rejectAfter', 0, 'be a positive integer', time);
if (!isPositiveInteger(time)) error$invalidArgument('Future.rejectAfter', 0, 'be a positive integer', time);
if (arguments.length === 1) return unaryPartial(rejectAfter$time, time);

@@ -446,3 +482,3 @@ return rejectAfter$time(time, reason);

Future.try = function Future$try(f) {
if (!isFunction(f)) invalidArgument('Future.try', 0, 'be a function', f);
if (!isFunction(f)) error$invalidArgument('Future.try', 0, 'be a function', f);
return new FutureTry(f);

@@ -453,3 +489,3 @@ };

if (arguments.length === 1) return unaryPartial(Future$encase, f);
if (!isFunction(f)) invalidArgument('Future.encase', 0, 'be a function', f);
if (!isFunction(f)) error$invalidArgument('Future.encase', 0, 'be a function', f);
return new FutureEncase(f, x);

@@ -465,4 +501,4 @@ };

default:
if (!isFunction(f)) invalidArgument('Future.encase2', 0, 'be a function', f);
if (!isBinary(f)) invalidArgument('Future.encase2', 0, 'take two arguments', f);
if (!isFunction(f)) error$invalidArgument('Future.encase2', 0, 'be a function', f);
if (!isBinary(f)) error$invalidArgument('Future.encase2', 0, 'take two arguments', f);
return new FutureEncase(f, x, y);

@@ -481,4 +517,4 @@ }

default:
if (!isFunction(f)) invalidArgument('Future.encase3', 0, 'be a function', f);
if (!isTernary(f)) invalidArgument('Future.encase3', 0, 'take three arguments', f);
if (!isFunction(f)) error$invalidArgument('Future.encase3', 0, 'be a function', f);
if (!isTernary(f)) error$invalidArgument('Future.encase3', 0, 'take three arguments', f);
return new FutureEncase(f, x, y, z);

@@ -490,3 +526,3 @@ }

if (arguments.length === 1) return unaryPartial(Future$fromPromise, f);
if (!isFunction(f)) invalidArgument('Future.fromPromise', 0, 'be a function', f);
if (!isFunction(f)) error$invalidArgument('Future.fromPromise', 0, 'be a function', f);
return new FutureFromPromise(f, x);

@@ -502,4 +538,4 @@ };

default:
if (!isFunction(f)) invalidArgument('Future.fromPromise2', 0, 'be a function', f);
if (!isBinary(f)) invalidArgument('Future.fromPromise2', 0, 'take two arguments', f);
if (!isFunction(f)) error$invalidArgument('Future.fromPromise2', 0, 'be a function', f);
if (!isBinary(f)) error$invalidArgument('Future.fromPromise2', 0, 'take two arguments', f);
return new FutureFromPromise(f, x, y);

@@ -518,4 +554,4 @@ }

default:
if (!isFunction(f)) invalidArgument('Future.fromPromise3', 0, 'be a function', f);
if (!isTernary(f)) invalidArgument('Future.fromPromise3', 0, 'take three arguments', f);
if (!isFunction(f)) error$invalidArgument('Future.fromPromise3', 0, 'be a function', f);
if (!isTernary(f)) error$invalidArgument('Future.fromPromise3', 0, 'take three arguments', f);
return new FutureFromPromise(f, x, y, z);

@@ -526,167 +562,33 @@ }

Future.node = function Future$node(f) {
if (!isFunction(f)) invalidArgument('Future.node', 0, 'be a function', f);
if (!isFunction(f)) error$invalidArgument('Future.node', 0, 'be a function', f);
return new FutureNode(f);
};
function parallel$i(i, ms) {
if (!Array.isArray(ms)) invalidArgument('Future.parallel', 1, 'be an array', ms);
Future.parallel = function Future$parallel(i, ms) {
if (arguments.length === 1) return unaryPartial(Future$parallel, i);
if (!isPositiveInteger(i)) error$invalidArgument('Future.parallel', 0, 'be a positive integer', i);
if (!Array.isArray(ms)) error$invalidArgument('Future.parallel', 1, 'be an array', ms);
return new FutureParallel(i, ms);
}
Future.parallel = function parallel(i, ms) {
if (!isPositiveInteger(i)) invalidArgument('Future.parallel', 0, 'be a positive integer', i);
if (arguments.length === 1) return unaryPartial(parallel$i, i);
return parallel$i(i, ms);
};
Future.do = function Future$do(f) {
if (!isFunction(f)) invalidArgument('Future.do', 0, 'be a function', f);
if (!isFunction(f)) error$invalidArgument('Future.do', 0, 'be a function', f);
return new FutureDo(f);
};
function chainRej$chainer(chainer, m) {
if (!isFuture(m)) invalidArgument('Future.chainRej', 1, 'be a Future', m);
return new FutureChainRej(chainer, m);
}
Future.chainRej = createUnaryDispatcher('chainRej');
Future.mapRej = createUnaryDispatcher('mapRej');
Future.swap = createNullaryDispatcher('swap');
Future.fork = createBinaryDispatcher('fork');
Future.race = createUnaryDispatcher('race');
Future.or = createUnaryDispatcher('or');
Future.fold = createBinaryDispatcher('fold');
Future.hook = createInvertedBinaryDispatcher('hook');
Future.finally = createUnaryDispatcher('finally');
Future.value = createUnaryDispatcher('value');
Future.promise = createNullaryDispatcher('promise');
Future.cache = createNullaryDispatcher('cache');
Future.extractLeft = createNullaryDispatcher('extractLeft');
Future.extractRight = createNullaryDispatcher('extractRight');
Future.chainRej = function chainRej(chainer, m) {
if (!isFunction(chainer)) invalidArgument('Future.chainRej', 0, 'be a Function', chainer);
if (arguments.length === 1) return unaryPartial(chainRej$chainer, chainer);
return chainRej$chainer(chainer, m);
};
function mapRej$mapper(mapper, m) {
if (!isFuture(m)) invalidArgument('Future.mapRej', 1, 'be a Future', m);
return new FutureMapRej(mapper, m);
}
Future.mapRej = function mapRej(mapper, m) {
if (!isFunction(mapper)) invalidArgument('Future.mapRej', 0, 'be a Function', mapper);
if (arguments.length === 1) return unaryPartial(mapRej$mapper, mapper);
return mapRej$mapper(mapper, m);
};
function race$left(left, right) {
if (!isFuture(right)) invalidArgument('Future.race', 1, 'be a Future', right);
return new FutureRace(left, right);
}
Future.race = function race(left, right) {
if (!isFuture(left)) invalidArgument('Future.race', 0, 'be a Future', left);
if (arguments.length === 1) return unaryPartial(race$left, left);
return race$left(left, right);
};
function or$right(right, left) {
if (!isFuture(left)) invalidArgument('Future.or', 1, 'be a Future', left);
return new FutureOr(left, right);
}
Future.or = function or(right, left) {
if (!isFuture(right)) invalidArgument('Future.or', 0, 'be a Future', right);
if (arguments.length === 1) return unaryPartial(or$right, right);
return or$right(right, left);
};
function finally$left(left, right) {
if (!isFuture(right)) invalidArgument('Future.finally', 1, 'be a Future', right);
return new FutureFinally(left, right);
}
Future.finally = function finally$(left, right) {
if (!isFuture(left)) invalidArgument('Future.finally', 0, 'be a Future', left);
if (arguments.length === 1) return unaryPartial(finally$left, left);
return finally$left(left, right);
};
function value$cont(cont, m) {
if (!isFuture(m)) invalidArgument('Future.value', 1, 'be a Future', m);
return m.value(cont);
}
Future.value = function value(cont, m) {
if (!isFunction(cont)) invalidArgument('Future.value', 0, 'be a Function', cont);
if (arguments.length === 1) return unaryPartial(value$cont, cont);
return value$cont(cont, m);
};
Future.swap = function swap(m) {
if (!isFuture(m)) invalidArgument('Future.swap', 0, 'be a Future', m);
return new FutureSwap(m);
};
Future.promise = function promise(m) {
if (!isFuture(m)) invalidArgument('Future.promise', 0, 'be a Future', m);
return m.promise();
};
Future.cache = function cache(m) {
if (!isFuture(m)) invalidArgument('Future.cache', 0, 'be a Future', m);
return new CachedFuture(m);
};
Future.extractLeft = function extractLeft(m) {
if (!isFuture(m)) invalidArgument('Future.extractLeft', 0, 'be a Future', m);
return m.extractLeft();
};
Future.extractRight = function extractRight(m) {
if (!isFuture(m)) invalidArgument('Future.extractRight', 0, 'be a Future', m);
return m.extractRight();
};
function fork$f$g(f, g, m) {
if (!isFuture(m)) invalidArgument('Future.fork', 2, 'be a Future', m);
return m._f(f, g);
}
function fork$f(f, g, m) {
if (!isFunction(g)) invalidArgument('Future.fork', 1, 'be a function', g);
if (arguments.length === 2) return binaryPartial(fork$f$g, f, g);
return fork$f$g(f, g, m);
}
Future.fork = function fork(f, g, m) {
if (!isFunction(f)) invalidArgument('Future.fork', 0, 'be a function', f);
if (arguments.length === 1) return unaryPartial(fork$f, f);
if (arguments.length === 2) return fork$f(f, g);
return fork$f(f, g, m);
};
function fold$f$g(f, g, m) {
if (!isFuture(m)) invalidArgument('Future.fold', 2, 'be a Future', m);
return new FutureFold(f, g, m);
}
function fold$f(f, g, m) {
if (!isFunction(g)) invalidArgument('Future.fold', 1, 'be a function', g);
if (arguments.length === 2) return binaryPartial(fold$f$g, f, g);
return fold$f$g(f, g, m);
}
Future.fold = function fold(f, g, m) {
if (!isFunction(f)) invalidArgument('Future.fold', 0, 'be a function', f);
if (arguments.length === 1) return unaryPartial(fold$f, f);
if (arguments.length === 2) return fold$f(f, g);
return fold$f(f, g, m);
};
function hook$acquire$cleanup(acquire, cleanup, consume) {
if (!isFunction(consume)) invalidArgument('Future.hook', 2, 'be a Future', consume);
return new FutureHook(acquire, cleanup, consume);
}
function hook$acquire(acquire, cleanup, consume) {
if (!isFunction(cleanup)) invalidArgument('Future.hook', 1, 'be a function', cleanup);
if (arguments.length === 2) return binaryPartial(hook$acquire$cleanup, acquire, cleanup);
return hook$acquire$cleanup(acquire, cleanup, consume);
}
Future.hook = function hook(acquire, cleanup, consume) {
if (!isFuture(acquire)) invalidArgument('Future.hook', 0, 'be a Future', acquire);
if (arguments.length === 1) return unaryPartial(hook$acquire, acquire);
if (arguments.length === 2) return hook$acquire(acquire, cleanup);
return hook$acquire(acquire, cleanup, consume);
};
//Utilities.

@@ -1101,3 +1003,3 @@ Future.util = {

function check$do$g(g) {
if (!isIterator(g)) invalidArgument('Future.do', 0, 'return an iterator, maybe you forgot the "*"', g);
if (!isIterator(g)) error$invalidArgument('Future.do', 0, 'return an iterator, maybe you forgot the "*"', g);
}

@@ -1104,0 +1006,0 @@

@@ -117,4 +117,41 @@ //// ____ _ _

//Creates a dispatcher for a nullary method.
function createNullaryDispatcher(method){
return function nullaryDispatch(m){
if(m && typeof m[method] === 'function') return m[method]();
return error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m);
};
}
//Creates a dispatcher for a unary method.
function createUnaryDispatcher(method){
return function unaryDispatch(a, m){
if(arguments.length === 1) return unaryPartial(unaryDispatch, a);
if(m && typeof m[method] === 'function') return m[method](a);
return error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m);
};
}
//Creates a dispatcher for a binary method.
function createBinaryDispatcher(method){
return function binaryDispatch(a, b, m){
if(arguments.length === 1) return unaryPartial(binaryDispatch, a);
if(arguments.length === 2) return binaryPartial(binaryDispatch, a, b);
if(m && typeof m[method] === 'function') return m[method](a, b);
return error$invalidArgument(`Future.${method}`, 2, `have a "${method}" method`, m);
};
}
//Creates a dispatcher for a binary method, but takes the object first rather than last.
function createInvertedBinaryDispatcher(method){
return function invertedBinaryDispatch(m, a, b){
if(arguments.length === 1) return unaryPartial(invertedBinaryDispatch, m);
if(arguments.length === 2) return binaryPartial(invertedBinaryDispatch, m, a);
if(m && typeof m[method] === 'function') return m[method](a, b);
return error$invalidArgument(`Future.${method}`, 0, `have a "${method}" method`, m);
};
}
//Creates an error about an invalid argument.
function invalidArgument(it, at, expected, actual){
function error$invalidArgument(it, at, expected, actual){
throw new TypeError(

@@ -126,3 +163,3 @@ `${it} expects its ${ordinal[at]} argument to ${expected}\n Actual: ${show(actual)}`

//Creates an error message about a method being called with an invalid context.
function invalidContext(it, actual){
function error$invalidContext(it, actual){
throw new TypeError(

@@ -139,3 +176,3 @@ `${it} was invoked outside the context of a Future. You might want to use`

function Future(f){
if(!isFunction(f)) invalidArgument('Future', 0, 'be a function', f);
if(!isFunction(f)) error$invalidArgument('Future', 0, 'be a function', f);
return new SafeFuture(f);

@@ -150,3 +187,3 @@ }

if(arguments.length === 1) return unaryPartial(Future$chainRec, f);
if(!isFunction(f)) invalidArgument('Future.chainRec', 0, 'be a function', f);
if(!isFunction(f)) error$invalidArgument('Future.chainRec', 0, 'be a function', f);
return new ChainRec(f, init);

@@ -162,4 +199,4 @@ }

Future.prototype.ap = function Future$ap(m){
if(!isFuture(this)) invalidContext('Future#ap', this);
if(!isFuture(m)) invalidArgument('Future#ap', 0, 'be a Future', m);
if(!isFuture(this)) error$invalidContext('Future#ap', this);
if(!isFuture(m)) error$invalidArgument('Future#ap', 0, 'be a Future', m);
return new FutureAp(this, m);

@@ -169,4 +206,4 @@ };

Future.prototype.map = function Future$map(f){
if(!isFuture(this)) invalidContext('Future#map', this);
if(!isFunction(f)) invalidArgument('Future#map', 0, 'be a function', f);
if(!isFuture(this)) error$invalidContext('Future#map', this);
if(!isFunction(f)) error$invalidArgument('Future#map', 0, 'be a function', f);
return new FutureMap(this, f);

@@ -176,5 +213,5 @@ };

Future.prototype.bimap = function Future$bimap(f, g){
if(!isFuture(this)) invalidContext('Future#bimap', this);
if(!isFunction(f)) invalidArgument('Future#bimap', 0, 'be a function', f);
if(!isFunction(g)) invalidArgument('Future#bimap', 1, 'be a function', g);
if(!isFuture(this)) error$invalidContext('Future#bimap', this);
if(!isFunction(f)) error$invalidArgument('Future#bimap', 0, 'be a function', f);
if(!isFunction(g)) error$invalidArgument('Future#bimap', 1, 'be a function', g);
return new FutureBimap(this, f, g);

@@ -184,4 +221,4 @@ };

Future.prototype.chain = function Future$chain(f){
if(!isFuture(this)) invalidContext('Future#chain', this);
if(!isFunction(f)) invalidArgument('Future#chain', 0, 'be a function', f);
if(!isFuture(this)) error$invalidContext('Future#chain', this);
if(!isFunction(f)) error$invalidArgument('Future#chain', 0, 'be a function', f);
return new FutureChain(this, f);

@@ -191,4 +228,4 @@ };

Future.prototype.chainRej = function Future$chainRej(f){
if(!isFuture(this)) invalidContext('Future.chainRej', this);
if(!isFunction(f)) invalidArgument('Future.chainRej', 0, 'a function', f);
if(!isFuture(this)) error$invalidContext('Future.chainRej', this);
if(!isFunction(f)) error$invalidArgument('Future.chainRej', 0, 'a function', f);
return new FutureChainRej(this, f);

@@ -198,4 +235,4 @@ };

Future.prototype.mapRej = function Future$mapRej(f){
if(!isFuture(this)) invalidContext('Future#mapRej', this);
if(!isFunction(f)) invalidArgument('Future#mapRej', 0, 'be a function', f);
if(!isFuture(this)) error$invalidContext('Future#mapRej', this);
if(!isFunction(f)) error$invalidArgument('Future#mapRej', 0, 'be a function', f);
return new FutureMapRej(this, f);

@@ -205,3 +242,3 @@ };

Future.prototype.swap = function Future$swap(){
if(!isFuture(this)) invalidContext('Future#swap', this);
if(!isFuture(this)) error$invalidContext('Future#swap', this);
return new FutureSwap(this);

@@ -211,4 +248,4 @@ };

Future.prototype.race = function Future$race(m){
if(!isFuture(this)) invalidContext('Future#race', this);
if(!isFuture(m)) invalidArgument('Future#race', 0, 'be a Future', m);
if(!isFuture(this)) error$invalidContext('Future#race', this);
if(!isFuture(m)) error$invalidArgument('Future#race', 0, 'be a Future', m);
return new FutureRace(this, m);

@@ -218,4 +255,4 @@ };

Future.prototype.and = function Future$and(m){
if(!isFuture(this)) invalidContext('Future#and', this);
if(!isFuture(m)) invalidArgument('Future#and', 0, 'be a Future', m);
if(!isFuture(this)) error$invalidContext('Future#and', this);
if(!isFuture(m)) error$invalidArgument('Future#and', 0, 'be a Future', m);
return new FutureAnd(this, m);

@@ -225,4 +262,4 @@ };

Future.prototype.or = function Future$or(m){
if(!isFuture(this)) invalidContext('Future#or', this);
if(!isFuture(m)) invalidArgument('Future#or', 0, 'be a Future', m);
if(!isFuture(this)) error$invalidContext('Future#or', this);
if(!isFuture(m)) error$invalidArgument('Future#or', 0, 'be a Future', m);
return new FutureOr(this, m);

@@ -232,4 +269,4 @@ };

Future.prototype.both = function Future$both(m){
if(!isFuture(this)) invalidContext('Future#both', this);
if(!isFuture(m)) invalidArgument('Future#both', 0, 'be a Future', m);
if(!isFuture(this)) error$invalidContext('Future#both', this);
if(!isFuture(m)) error$invalidArgument('Future#both', 0, 'be a Future', m);
return new FutureBoth(this, m);

@@ -239,5 +276,5 @@ };

Future.prototype.fold = function Future$fold(f, g){
if(!isFuture(this)) invalidContext('Future#fold', this);
if(!isFunction(f)) invalidArgument('Future#fold', 0, 'be a function', f);
if(!isFunction(g)) invalidArgument('Future#fold', 1, 'be a function', g);
if(!isFuture(this)) error$invalidContext('Future#fold', this);
if(!isFunction(f)) error$invalidArgument('Future#fold', 0, 'be a function', f);
if(!isFunction(g)) error$invalidArgument('Future#fold', 1, 'be a function', g);
return new FutureFold(this, f, g);

@@ -247,5 +284,5 @@ };

Future.prototype.hook = function Future$hook(dispose, consume){
if(!isFuture(this)) invalidContext('Future#hook', this);
if(!isFunction(dispose)) invalidArgument('Future#hook', 0, 'be a function', dispose);
if(!isFunction(consume)) invalidArgument('Future#hook', 1, 'be a function', consume);
if(!isFuture(this)) error$invalidContext('Future#hook', this);
if(!isFunction(dispose)) error$invalidArgument('Future#hook', 0, 'be a function', dispose);
if(!isFunction(consume)) error$invalidArgument('Future#hook', 1, 'be a function', consume);
return new FutureHook(this, dispose, consume);

@@ -255,4 +292,4 @@ };

Future.prototype.finally = function Future$finally(m){
if(!isFuture(this)) invalidContext('Future#finally', this);
if(!isFuture(m)) invalidArgument('Future#finally', 0, 'be a Future', m);
if(!isFuture(this)) error$invalidContext('Future#finally', this);
if(!isFuture(m)) error$invalidArgument('Future#finally', 0, 'be a Future', m);
return new FutureFinally(this, m);

@@ -262,3 +299,3 @@ };

Future.prototype.cache = function Future$cache(){
if(!isFuture(this)) invalidContext('Future#cache', this);
if(!isFuture(this)) error$invalidContext('Future#cache', this);
return new CachedFuture(this);

@@ -268,5 +305,5 @@ };

Future.prototype.fork = function Future$fork(rej, res){
if(!isFuture(this)) invalidContext('Future#fork', this);
if(!isFunction(rej)) invalidArgument('Future#fork', 0, 'be a function', rej);
if(!isFunction(res)) invalidArgument('Future#fork', 1, 'be a function', res);
if(!isFuture(this)) error$invalidContext('Future#fork', this);
if(!isFunction(rej)) error$invalidArgument('Future#fork', 0, 'be a function', rej);
if(!isFunction(res)) error$invalidArgument('Future#fork', 1, 'be a function', res);
return this._f(rej, res);

@@ -276,4 +313,4 @@ };

Future.prototype.value = function Future$value(f){
if(!isFuture(this)) invalidContext('Future#value', this);
if(!isFunction(f)) invalidArgument('Future#value', 0, 'be a function', f);
if(!isFuture(this)) error$invalidContext('Future#value', this);
if(!isFunction(f)) error$invalidArgument('Future#value', 0, 'be a function', f);
return this._f(function Future$value$rej(e){

@@ -287,3 +324,3 @@ throw new Error(

Future.prototype.promise = function Future$promise(){
if(!isFuture(this)) invalidContext('Future#promise', this);
if(!isFuture(this)) error$invalidContext('Future#promise', this);
const _this = this;

@@ -301,3 +338,3 @@ return new Promise(function Future$promise$do(resolve, reject){

function ap$mval(mval, mfunc){
if(!Z.Apply.test(mfunc)) invalidArgument('Future.ap', 1, 'be an Apply', mfunc);
if(!Z.Apply.test(mfunc)) error$invalidArgument('Future.ap', 1, 'be an Apply', mfunc);
return Z.ap(mval, mfunc);

@@ -307,3 +344,3 @@ }

Future.ap = function ap(mval, mfunc){
if(!Z.Apply.test(mval)) invalidArgument('Future.ap', 0, 'be an Apply', mval);
if(!Z.Apply.test(mval)) error$invalidArgument('Future.ap', 0, 'be an Apply', mval);
if(arguments.length === 1) return unaryPartial(ap$mval, mval);

@@ -314,3 +351,3 @@ return ap$mval(mval, mfunc);

function map$mapper(mapper, m){
if(!Z.Functor.test(m)) invalidArgument('Future.map', 1, 'be a Functor', m);
if(!Z.Functor.test(m)) error$invalidArgument('Future.map', 1, 'be a Functor', m);
return Z.map(mapper, m);

@@ -320,3 +357,3 @@ }

Future.map = function map(mapper, m){
if(!isFunction(mapper)) invalidArgument('Future.map', 0, 'be a Function', mapper);
if(!isFunction(mapper)) error$invalidArgument('Future.map', 0, 'be a Function', mapper);
if(arguments.length === 1) return unaryPartial(map$mapper, mapper);

@@ -327,3 +364,3 @@ return map$mapper(mapper, m);

function bimap$lmapper$rmapper(lmapper, rmapper, m){
if(!Z.Bifunctor.test(m)) invalidArgument('Future.bimap', 2, 'be a Bifunctor', m);
if(!Z.Bifunctor.test(m)) error$invalidArgument('Future.bimap', 2, 'be a Bifunctor', m);
return Z.bimap(lmapper, rmapper, m);

@@ -333,3 +370,3 @@ }

function bimap$lmapper(lmapper, rmapper, m){
if(!isFunction(rmapper)) invalidArgument('Future.bimap', 1, 'be a Function', rmapper);
if(!isFunction(rmapper)) error$invalidArgument('Future.bimap', 1, 'be a Function', rmapper);
if(arguments.length === 2) return binaryPartial(bimap$lmapper$rmapper, lmapper, rmapper);

@@ -340,5 +377,4 @@ return bimap$lmapper$rmapper(lmapper, rmapper, m);

Future.bimap = function bimap(lmapper, rmapper, m){
if(!isFunction(lmapper)) invalidArgument('Future.bimap', 0, 'be a Function', lmapper);
if(!isFunction(lmapper)) error$invalidArgument('Future.bimap', 0, 'be a Function', lmapper);
if(arguments.length === 1) return unaryPartial(bimap$lmapper, lmapper);
if(arguments.length === 2) return bimap$lmapper(lmapper, rmapper);
return bimap$lmapper(lmapper, rmapper, m);

@@ -348,3 +384,3 @@ };

function chain$chainer(chainer, m){
if(!Z.Chain.test(m)) invalidArgument('Future.chain', 1, 'be a Chain', m);
if(!Z.Chain.test(m)) error$invalidArgument('Future.chain', 1, 'be a Chain', m);
return Z.chain(chainer, m);

@@ -354,3 +390,3 @@ }

Future.chain = function chain(chainer, m){
if(!isFunction(chainer)) invalidArgument('Future.chain', 0, 'be a Function', chainer);
if(!isFunction(chainer)) error$invalidArgument('Future.chain', 0, 'be a Function', chainer);
if(arguments.length === 1) return unaryPartial(chain$chainer, chainer);

@@ -361,3 +397,3 @@ return chain$chainer(chainer, m);

function and$left(left, right){
if(!isFuture(right)) invalidArgument('Future.and', 1, 'be a Future', right);
if(!isFuture(right)) error$invalidArgument('Future.and', 1, 'be a Future', right);
return new FutureAnd(left, right);

@@ -367,3 +403,3 @@ }

Future.and = function and(left, right){
if(!isFuture(left)) invalidArgument('Future.and', 0, 'be a Future', left);
if(!isFuture(left)) error$invalidArgument('Future.and', 0, 'be a Future', left);
if(arguments.length === 1) return unaryPartial(and$left, left);

@@ -374,3 +410,3 @@ return and$left(left, right);

function both$left(left, right){
if(!isFuture(right)) invalidArgument('Future.both', 1, 'be a Future', right);
if(!isFuture(right)) error$invalidArgument('Future.both', 1, 'be a Future', right);
return new FutureBoth(left, right);

@@ -380,3 +416,3 @@ }

Future.both = function both(left, right){
if(!isFuture(left)) invalidArgument('Future.both', 0, 'be a Future', left);
if(!isFuture(left)) error$invalidArgument('Future.both', 0, 'be a Future', left);
if(arguments.length === 1) return unaryPartial(both$left, left);

@@ -395,3 +431,3 @@ return both$left(left, right);

Future.after = function Future$after(n, x){
if(!isPositiveInteger(n)) invalidArgument('Future.after', 0, 'be a positive integer', n);
if(!isPositiveInteger(n)) error$invalidArgument('Future.after', 0, 'be a positive integer', n);
if(arguments.length === 1) return unaryPartial(Future$after$n, n);

@@ -406,3 +442,3 @@ return Future$after$n(n, x);

Future.rejectAfter = function rejectAfter(time, reason){
if(!isPositiveInteger(time)) invalidArgument(
if(!isPositiveInteger(time)) error$invalidArgument(
'Future.rejectAfter', 0, 'be a positive integer', time

@@ -425,3 +461,3 @@ );

Future.try = function Future$try(f){
if(!isFunction(f)) invalidArgument('Future.try', 0, 'be a function', f);
if(!isFunction(f)) error$invalidArgument('Future.try', 0, 'be a function', f);
return new FutureTry(f);

@@ -432,3 +468,3 @@ };

if(arguments.length === 1) return unaryPartial(Future$encase, f);
if(!isFunction(f)) invalidArgument('Future.encase', 0, 'be a function', f);
if(!isFunction(f)) error$invalidArgument('Future.encase', 0, 'be a function', f);
return new FutureEncase(f, x);

@@ -442,4 +478,4 @@ };

default:
if(!isFunction(f)) invalidArgument('Future.encase2', 0, 'be a function', f);
if(!isBinary(f)) invalidArgument('Future.encase2', 0, 'take two arguments', f);
if(!isFunction(f)) error$invalidArgument('Future.encase2', 0, 'be a function', f);
if(!isBinary(f)) error$invalidArgument('Future.encase2', 0, 'take two arguments', f);
return new FutureEncase(f, x, y);

@@ -455,4 +491,4 @@ }

default:
if(!isFunction(f)) invalidArgument('Future.encase3', 0, 'be a function', f);
if(!isTernary(f)) invalidArgument('Future.encase3', 0, 'take three arguments', f);
if(!isFunction(f)) error$invalidArgument('Future.encase3', 0, 'be a function', f);
if(!isTernary(f)) error$invalidArgument('Future.encase3', 0, 'take three arguments', f);
return new FutureEncase(f, x, y, z);

@@ -464,3 +500,3 @@ }

if(arguments.length === 1) return unaryPartial(Future$fromPromise, f);
if(!isFunction(f)) invalidArgument('Future.fromPromise', 0, 'be a function', f);
if(!isFunction(f)) error$invalidArgument('Future.fromPromise', 0, 'be a function', f);
return new FutureFromPromise(f, x);

@@ -474,4 +510,4 @@ };

default:
if(!isFunction(f)) invalidArgument('Future.fromPromise2', 0, 'be a function', f);
if(!isBinary(f)) invalidArgument('Future.fromPromise2', 0, 'take two arguments', f);
if(!isFunction(f)) error$invalidArgument('Future.fromPromise2', 0, 'be a function', f);
if(!isBinary(f)) error$invalidArgument('Future.fromPromise2', 0, 'take two arguments', f);
return new FutureFromPromise(f, x, y);

@@ -488,5 +524,5 @@ }

if(!isFunction(f))
invalidArgument('Future.fromPromise3', 0, 'be a function', f);
error$invalidArgument('Future.fromPromise3', 0, 'be a function', f);
if(!isTernary(f))
invalidArgument('Future.fromPromise3', 0, 'take three arguments', f);
error$invalidArgument('Future.fromPromise3', 0, 'take three arguments', f);
return new FutureFromPromise(f, x, y, z);

@@ -497,167 +533,35 @@ }

Future.node = function Future$node(f){
if(!isFunction(f)) invalidArgument('Future.node', 0, 'be a function', f);
if(!isFunction(f)) error$invalidArgument('Future.node', 0, 'be a function', f);
return new FutureNode(f);
};
function parallel$i(i, ms){
if(!Array.isArray(ms)) invalidArgument('Future.parallel', 1, 'be an array', ms);
Future.parallel = function Future$parallel(i, ms){
if(arguments.length === 1) return unaryPartial(Future$parallel, i);
if(!isPositiveInteger(i))
error$invalidArgument('Future.parallel', 0, 'be a positive integer', i);
if(!Array.isArray(ms))
error$invalidArgument('Future.parallel', 1, 'be an array', ms);
return new FutureParallel(i, ms);
}
Future.parallel = function parallel(i, ms){
if(!isPositiveInteger(i)) invalidArgument('Future.parallel', 0, 'be a positive integer', i);
if(arguments.length === 1) return unaryPartial(parallel$i, i);
return parallel$i(i, ms);
};
Future.do = function Future$do(f){
if(!isFunction(f)) invalidArgument('Future.do', 0, 'be a function', f);
if(!isFunction(f)) error$invalidArgument('Future.do', 0, 'be a function', f);
return new FutureDo(f);
};
function chainRej$chainer(chainer, m){
if(!isFuture(m)) invalidArgument('Future.chainRej', 1, 'be a Future', m);
return new FutureChainRej(chainer, m);
}
Future.chainRej = createUnaryDispatcher('chainRej');
Future.mapRej = createUnaryDispatcher('mapRej');
Future.swap = createNullaryDispatcher('swap');
Future.fork = createBinaryDispatcher('fork');
Future.race = createUnaryDispatcher('race');
Future.or = createUnaryDispatcher('or');
Future.fold = createBinaryDispatcher('fold');
Future.hook = createInvertedBinaryDispatcher('hook');
Future.finally = createUnaryDispatcher('finally');
Future.value = createUnaryDispatcher('value');
Future.promise = createNullaryDispatcher('promise');
Future.cache = createNullaryDispatcher('cache');
Future.extractLeft = createNullaryDispatcher('extractLeft');
Future.extractRight = createNullaryDispatcher('extractRight');
Future.chainRej = function chainRej(chainer, m){
if(!isFunction(chainer)) invalidArgument('Future.chainRej', 0, 'be a Function', chainer);
if(arguments.length === 1) return unaryPartial(chainRej$chainer, chainer);
return chainRej$chainer(chainer, m);
};
function mapRej$mapper(mapper, m){
if(!isFuture(m)) invalidArgument('Future.mapRej', 1, 'be a Future', m);
return new FutureMapRej(mapper, m);
}
Future.mapRej = function mapRej(mapper, m){
if(!isFunction(mapper)) invalidArgument('Future.mapRej', 0, 'be a Function', mapper);
if(arguments.length === 1) return unaryPartial(mapRej$mapper, mapper);
return mapRej$mapper(mapper, m);
};
function race$left(left, right){
if(!isFuture(right)) invalidArgument('Future.race', 1, 'be a Future', right);
return new FutureRace(left, right);
}
Future.race = function race(left, right){
if(!isFuture(left)) invalidArgument('Future.race', 0, 'be a Future', left);
if(arguments.length === 1) return unaryPartial(race$left, left);
return race$left(left, right);
};
function or$right(right, left){
if(!isFuture(left)) invalidArgument('Future.or', 1, 'be a Future', left);
return new FutureOr(left, right);
}
Future.or = function or(right, left){
if(!isFuture(right)) invalidArgument('Future.or', 0, 'be a Future', right);
if(arguments.length === 1) return unaryPartial(or$right, right);
return or$right(right, left);
};
function finally$left(left, right){
if(!isFuture(right)) invalidArgument('Future.finally', 1, 'be a Future', right);
return new FutureFinally(left, right);
}
Future.finally = function finally$(left, right){
if(!isFuture(left)) invalidArgument('Future.finally', 0, 'be a Future', left);
if(arguments.length === 1) return unaryPartial(finally$left, left);
return finally$left(left, right);
};
function value$cont(cont, m){
if(!isFuture(m)) invalidArgument('Future.value', 1, 'be a Future', m);
return m.value(cont);
}
Future.value = function value(cont, m){
if(!isFunction(cont)) invalidArgument('Future.value', 0, 'be a Function', cont);
if(arguments.length === 1) return unaryPartial(value$cont, cont);
return value$cont(cont, m);
};
Future.swap = function swap(m){
if(!isFuture(m)) invalidArgument('Future.swap', 0, 'be a Future', m);
return new FutureSwap(m);
};
Future.promise = function promise(m){
if(!isFuture(m)) invalidArgument('Future.promise', 0, 'be a Future', m);
return m.promise();
};
Future.cache = function cache(m){
if(!isFuture(m)) invalidArgument('Future.cache', 0, 'be a Future', m);
return new CachedFuture(m);
};
Future.extractLeft = function extractLeft(m){
if(!isFuture(m)) invalidArgument('Future.extractLeft', 0, 'be a Future', m);
return m.extractLeft();
};
Future.extractRight = function extractRight(m){
if(!isFuture(m)) invalidArgument('Future.extractRight', 0, 'be a Future', m);
return m.extractRight();
};
function fork$f$g(f, g, m){
if(!isFuture(m)) invalidArgument('Future.fork', 2, 'be a Future', m);
return m._f(f, g);
}
function fork$f(f, g, m){
if(!isFunction(g)) invalidArgument('Future.fork', 1, 'be a function', g);
if(arguments.length === 2) return binaryPartial(fork$f$g, f, g);
return fork$f$g(f, g, m);
}
Future.fork = function fork(f, g, m){
if(!isFunction(f)) invalidArgument('Future.fork', 0, 'be a function', f);
if(arguments.length === 1) return unaryPartial(fork$f, f);
if(arguments.length === 2) return fork$f(f, g);
return fork$f(f, g, m);
};
function fold$f$g(f, g, m){
if(!isFuture(m)) invalidArgument('Future.fold', 2, 'be a Future', m);
return new FutureFold(f, g, m);
}
function fold$f(f, g, m){
if(!isFunction(g)) invalidArgument('Future.fold', 1, 'be a function', g);
if(arguments.length === 2) return binaryPartial(fold$f$g, f, g);
return fold$f$g(f, g, m);
}
Future.fold = function fold(f, g, m){
if(!isFunction(f)) invalidArgument('Future.fold', 0, 'be a function', f);
if(arguments.length === 1) return unaryPartial(fold$f, f);
if(arguments.length === 2) return fold$f(f, g);
return fold$f(f, g, m);
};
function hook$acquire$cleanup(acquire, cleanup, consume){
if(!isFunction(consume)) invalidArgument('Future.hook', 2, 'be a Future', consume);
return new FutureHook(acquire, cleanup, consume);
}
function hook$acquire(acquire, cleanup, consume){
if(!isFunction(cleanup)) invalidArgument('Future.hook', 1, 'be a function', cleanup);
if(arguments.length === 2) return binaryPartial(hook$acquire$cleanup, acquire, cleanup);
return hook$acquire$cleanup(acquire, cleanup, consume);
}
Future.hook = function hook(acquire, cleanup, consume){
if(!isFuture(acquire)) invalidArgument('Future.hook', 0, 'be a Future', acquire);
if(arguments.length === 1) return unaryPartial(hook$acquire, acquire);
if(arguments.length === 2) return hook$acquire(acquire, cleanup);
return hook$acquire(acquire, cleanup, consume);
};
//Utilities.

@@ -1074,3 +978,3 @@ Future.util = {

function check$do$g(g){
if(!isIterator(g)) invalidArgument(
if(!isIterator(g)) error$invalidArgument(
'Future.do', 0, 'return an iterator, maybe you forgot the "*"', g

@@ -1077,0 +981,0 @@ );

{
"name": "fluture",
"version": "4.3.3",
"version": "4.3.4",
"description": "FantasyLand compliant (monadic) alternative to Promises",

@@ -5,0 +5,0 @@ "main": "fluture.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc