Comparing version 4.2.0 to 4.3.0
204
fluture.js
@@ -15,5 +15,3 @@ //// ____ _ _ | ||
module.exports = f(require('inspect-f'), require('sanctuary-type-classes')); | ||
} | ||
else{ | ||
}else{ | ||
global.Fluture = f(global.inspectf, global.sanctuaryTypeClasses); | ||
@@ -70,3 +68,3 @@ } | ||
function isPositiveInteger(n){ | ||
return n === Infinity || (typeof n === 'number' && n > 0 && n % 1 === 0 && n === n); | ||
return n === Infinity || (typeof n === 'number' && n > 0 && n % 1 === 0); | ||
} | ||
@@ -124,3 +122,3 @@ | ||
if(m && typeof m[method] === 'function') return m[method](); | ||
error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m); | ||
return error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m); | ||
}; | ||
@@ -134,3 +132,3 @@ } | ||
if(m && typeof m[method] === 'function') return m[method](a); | ||
error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m); | ||
return error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m); | ||
}; | ||
@@ -145,3 +143,3 @@ } | ||
if(m && typeof m[method] === 'function') return m[method](a, b); | ||
error$invalidArgument(`Future.${method}`, 2, `have a "${method}" method`, m); | ||
return error$invalidArgument(`Future.${method}`, 2, `have a "${method}" method`, m); | ||
}; | ||
@@ -156,3 +154,3 @@ } | ||
if(m && typeof m[method] === 'function') return m[method](a, b); | ||
error$invalidArgument(`Future.${method}`, 0, `have a "${method}" method`, m); | ||
return error$invalidArgument(`Future.${method}`, 0, `have a "${method}" method`, m); | ||
}; | ||
@@ -173,3 +171,3 @@ } | ||
+ ` a dispatcher instead\n Called on: ${show(actual)}` | ||
) | ||
); | ||
} | ||
@@ -198,4 +196,4 @@ | ||
Future.prototype._f = null; | ||
Future.prototype.extractLeft = function Future$extractLeft(){ return []; } | ||
Future.prototype.extractRight = function Future$extractRight(){ return []; } | ||
Future.prototype.extractLeft = function Future$extractLeft(){ return [] }; | ||
Future.prototype.extractRight = function Future$extractRight(){ return [] }; | ||
Future.prototype.of = Future$of; | ||
@@ -338,3 +336,3 @@ | ||
return ap$mval(mval, mfunc); | ||
} | ||
}; | ||
@@ -350,3 +348,3 @@ function map$mapper(mapper, m){ | ||
return map$mapper(mapper, m); | ||
} | ||
}; | ||
@@ -368,3 +366,3 @@ function bimap$lmapper$rmapper(lmapper, rmapper, m){ | ||
return bimap$lmapper(lmapper, rmapper, m); | ||
} | ||
}; | ||
@@ -380,3 +378,3 @@ function chain$chainer(chainer, m){ | ||
return chain$chainer(chainer, m); | ||
} | ||
}; | ||
@@ -392,3 +390,3 @@ function and$left(left, right){ | ||
return and$left(left, right); | ||
} | ||
}; | ||
@@ -404,3 +402,3 @@ function both$left(left, right){ | ||
return both$left(left, right); | ||
} | ||
}; | ||
@@ -431,3 +429,3 @@ Future.reject = function Future$reject(x){ | ||
return rejectAfter$time(time, reason); | ||
} | ||
}; | ||
@@ -476,3 +474,3 @@ Future.cast = function Future$cast(m){ | ||
return new FutureFromForkable(f); | ||
} | ||
}; | ||
@@ -502,4 +500,6 @@ Future.fromPromise = function Future$fromPromise(f, x){ | ||
default: | ||
if(!isFunction(f)) error$invalidArgument('Future.fromPromise3', 0, 'be a function', f); | ||
if(!isTernary(f)) error$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); | ||
@@ -516,4 +516,6 @@ } | ||
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); | ||
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); | ||
@@ -607,7 +609,7 @@ }; | ||
}; | ||
} | ||
}; | ||
SafeFuture.prototype.toString = function SafeFuture$toString(){ | ||
return `Future(${showf(this._computation)})`; | ||
} | ||
}; | ||
@@ -661,3 +663,3 @@ //---------- | ||
timing = Synchronous; | ||
state = it; | ||
state = it; //eslint-disable-line | ||
}else{ | ||
@@ -680,7 +682,7 @@ Future$chainRec$recur(it); | ||
return function Future$chainRec$cancel(){ cancel() }; | ||
} | ||
}; | ||
ChainRec.prototype.toString = function ChainRec$toString(){ | ||
return `Future.chainRec(${showf(this._iterate)}, ${show(this._init)})`; | ||
} | ||
}; | ||
@@ -720,7 +722,7 @@ //---------- | ||
return this._state === Rejected ? [this._value] : []; | ||
} | ||
}; | ||
CachedFuture.prototype.extractRight = function CachedFuture$extractRight(){ | ||
return this._state === Resolved ? [this._value] : []; | ||
} | ||
}; | ||
@@ -738,3 +740,3 @@ CachedFuture.prototype._addToQueue = function CachedFuture$addToQueue(rej, res){ | ||
}; | ||
} | ||
}; | ||
@@ -754,3 +756,3 @@ CachedFuture.prototype._drainQueue = function CachedFuture$drainQueue(){ | ||
this._queued = 0; | ||
} | ||
}; | ||
@@ -762,3 +764,3 @@ CachedFuture.prototype.reject = function CachedFuture$reject(reason){ | ||
this._drainQueue(); | ||
} | ||
}; | ||
@@ -770,3 +772,3 @@ CachedFuture.prototype.resolve = function CachedFuture$resolve(value){ | ||
this._drainQueue(); | ||
} | ||
}; | ||
@@ -781,3 +783,3 @@ CachedFuture.prototype.run = function CachedFuture$run(){ | ||
); | ||
} | ||
}; | ||
@@ -792,7 +794,7 @@ CachedFuture.prototype.reset = function CachedFuture$reset(){ | ||
this._state = Cold; | ||
} | ||
}; | ||
CachedFuture.prototype.getState = function CachedFuture$getState(){ | ||
return CachedFuture.STATE[this._state]; | ||
} | ||
}; | ||
@@ -809,3 +811,3 @@ CachedFuture.prototype._f = function CachedFuture$fork(rej, res){ | ||
return cancel; | ||
} | ||
}; | ||
@@ -817,7 +819,7 @@ CachedFuture.prototype.inspect = function CachedFuture$inspect(){ | ||
return `CachedFuture({ ${repr} })`; | ||
} | ||
}; | ||
CachedFuture.prototype.toString = function CachedFuture$toString(){ | ||
return `${this._pure.toString()}.cache()`; | ||
} | ||
}; | ||
@@ -834,3 +836,3 @@ //---------- | ||
return [this._value]; | ||
} | ||
}; | ||
@@ -840,7 +842,7 @@ FutureOf.prototype._f = function FutureOf$fork(rej, res){ | ||
return noop; | ||
} | ||
}; | ||
FutureOf.prototype.toString = function FutureOf$toString(){ | ||
return `Future.of(${show(this._value)})`; | ||
} | ||
}; | ||
@@ -857,3 +859,3 @@ //---------- | ||
return [this._reason]; | ||
} | ||
}; | ||
@@ -863,7 +865,7 @@ FutureReject.prototype._f = function FutureReject$fork(rej){ | ||
return noop; | ||
} | ||
}; | ||
FutureReject.prototype.toString = function FutureReject$toString(){ | ||
return `Future.reject(${show(this._reason)})`; | ||
} | ||
}; | ||
@@ -887,7 +889,7 @@ //---------- | ||
return function FutureNode$fork$cancel(){ open = false }; | ||
} | ||
}; | ||
FutureNode.prototype.toString = function FutureNode$toString(){ | ||
return `Future.node(${showf(this._computation)})`; | ||
} | ||
}; | ||
@@ -905,3 +907,3 @@ //---------- | ||
return [this._value]; | ||
} | ||
}; | ||
@@ -911,7 +913,7 @@ FutureAfter.prototype._f = function FutureAfter$fork(rej, res){ | ||
return function FutureAfter$fork$cancel(){ clearTimeout(id) }; | ||
} | ||
}; | ||
FutureAfter.prototype.toString = function FutureAfter$toString(){ | ||
return `Future.after(${show(this._time)}, ${show(this._value)})`; | ||
} | ||
}; | ||
@@ -929,3 +931,3 @@ //---------- | ||
return [this._reason]; | ||
} | ||
}; | ||
@@ -935,7 +937,7 @@ FutureRejectAfter.prototype._f = function FutureRejectAfter$fork(rej){ | ||
return function FutureRejectAfter$fork$cancel(){ clearTimeout(id) }; | ||
} | ||
}; | ||
FutureRejectAfter.prototype.toString = function FutureRejectAfter$toString(){ | ||
return `Future.rejectAfter(${show(this._time)}, ${show(this._reason)})`; | ||
} | ||
}; | ||
@@ -981,10 +983,10 @@ //---------- | ||
}); | ||
} | ||
}; | ||
for(let n = 0; n < _this._max; n++) run(_this._futures[n], n, n); | ||
return cancelAll; | ||
} | ||
}; | ||
FutureParallel.prototype.toString = function FutureParallel$toString(){ | ||
return `Future.parallel(${show(this._max)}, [${this._futures.map(show).join(', ')}])`; | ||
} | ||
}; | ||
@@ -1027,7 +1029,7 @@ //---------- | ||
return recurser._f(rej, res); | ||
} | ||
}; | ||
FutureDo.prototype.toString = function FutureDo$toString(){ | ||
return `Future.do(${showf(this._generator)})`; | ||
} | ||
}; | ||
@@ -1055,7 +1057,7 @@ //---------- | ||
}); | ||
} | ||
}; | ||
FutureFromForkable.prototype.toString = function FutureFromForkable$toString(){ | ||
return `Future.fromForkable(${show(this._forkable)})`; | ||
} | ||
}; | ||
@@ -1075,7 +1077,7 @@ //---------- | ||
return noop; | ||
} | ||
}; | ||
FutureTry.prototype.toString = function FutureTry$toString(){ | ||
return `Future.try(${show(this._fn)})`; | ||
} | ||
}; | ||
@@ -1112,3 +1114,3 @@ //---------- | ||
} | ||
} | ||
}; | ||
@@ -1121,3 +1123,3 @@ FutureEncase.prototype = Object.create(Future.prototype); | ||
return `Future.${name}(${show(this._fn)}, ${args})`; | ||
} | ||
}; | ||
@@ -1164,3 +1166,3 @@ //---------- | ||
} | ||
} | ||
}; | ||
@@ -1173,3 +1175,3 @@ FutureFromPromise.prototype = Object.create(Future.prototype); | ||
return `Future.${name}(${show(this._fn)}, ${args})`; | ||
} | ||
}; | ||
@@ -1201,7 +1203,7 @@ //---------- | ||
return cancel || (cancel = r, function FutureChain$fork$cancel(){ cancel() }); | ||
} | ||
}; | ||
FutureChain.prototype.toString = function FutureChain$toString(){ | ||
return `${this._parent.toString()}.chain(${showf(this._chainer)})`; | ||
} | ||
}; | ||
@@ -1233,7 +1235,7 @@ //---------- | ||
return cancel || (cancel = r, function FutureChainRej$fork$cancel(){ cancel() }); | ||
} | ||
}; | ||
FutureChainRej.prototype.toString = function FutureChainRej$toString(){ | ||
return `${this._parent.toString()}.chainRej(${showf(this._chainer)})`; | ||
} | ||
}; | ||
@@ -1254,7 +1256,7 @@ //---------- | ||
}); | ||
} | ||
}; | ||
FutureMap.prototype.toString = function FutureMap$toString(){ | ||
return `${this._parent.toString()}.map(${showf(this._mapper)})`; | ||
} | ||
}; | ||
@@ -1275,7 +1277,7 @@ //---------- | ||
}, res); | ||
} | ||
}; | ||
FutureMapRej.prototype.toString = function FutureMapRej$toString(){ | ||
return `${this._parent.toString()}.mapRej(${showf(this._mapper)})`; | ||
} | ||
}; | ||
@@ -1299,7 +1301,7 @@ //---------- | ||
}); | ||
} | ||
}; | ||
FutureBimap.prototype.toString = function FutureBimap$toString(){ | ||
return `${this._parent.toString()}.bimap(${showf(this._lmapper)}, ${showf(this._rmapper)})`; | ||
} | ||
}; | ||
@@ -1333,7 +1335,7 @@ //---------- | ||
return cancel || (cancel = r, function FutureAp$fork$cancel(){ cancel() }); | ||
} | ||
}; | ||
FutureAp.prototype.toString = function FutureAp$toString(){ | ||
return `${this._mval.toString()}.ap(${this._mfunc.toString()})`; | ||
} | ||
}; | ||
@@ -1350,7 +1352,7 @@ //---------- | ||
return this._parent._f(res, rej); | ||
} | ||
}; | ||
FutureSwap.prototype.toString = function FutureSwap$toString(){ | ||
return `${this._parent.toString()}.swap()`; | ||
} | ||
}; | ||
@@ -1369,12 +1371,12 @@ //---------- | ||
const cancel = function FutureRace$fork$cancel(){ cancelled = true; lcancel(); rcancel() }; | ||
const reject = function FutureRace$fork$rej(x){ cancel(); rej(x) } | ||
const resolve = function FutureRace$fork$res(x){ cancel(); res(x) } | ||
const reject = function FutureRace$fork$rej(x){ cancel(); rej(x) }; | ||
const resolve = function FutureRace$fork$res(x){ cancel(); res(x) }; | ||
lcancel = this._left._f(reject, resolve); | ||
cancelled || (rcancel = this._right._f(reject, resolve)); | ||
return cancel; | ||
} | ||
}; | ||
FutureRace.prototype.toString = function FutureRace$toString(){ | ||
return `${this._left.toString()}.race(${this._right.toString()})`; | ||
} | ||
}; | ||
@@ -1393,3 +1395,3 @@ //---------- | ||
lcancel = this._left._f( | ||
e => (rejected = true, rcancel(), rej(e)), | ||
e => {rejected = true; rcancel(); rej(e)}, | ||
_ => rejected ? rej(val) : resolved ? res(val) : (resolved = true) | ||
@@ -1402,7 +1404,7 @@ ); | ||
return function FutureAnd$fork$cancel(){ lcancel(); rcancel() }; | ||
} | ||
}; | ||
FutureAnd.prototype.toString = function FutureAnd$toString(){ | ||
return `${this._left.toString()}.and(${this._right.toString()})`; | ||
} | ||
}; | ||
@@ -1422,3 +1424,3 @@ //---------- | ||
_ => rejected ? rej(err) : resolved ? res(val) : (rejected = true), | ||
x => (resolved = true, rcancel(), res(x)) | ||
x => {resolved = true; rcancel(); res(x)} | ||
); | ||
@@ -1430,7 +1432,7 @@ resolved || (rcancel = this._right._f( | ||
return function FutureOr$fork$cancel(){ lcancel(); rcancel() }; | ||
} | ||
}; | ||
FutureOr.prototype.toString = function FutureOr$toString(){ | ||
return `${this._left.toString()}.or(${this._right.toString()})`; | ||
} | ||
}; | ||
@@ -1464,7 +1466,7 @@ //---------- | ||
return function FutureBoth$fork$cancel(){ lcancel(); rcancel() }; | ||
} | ||
}; | ||
FutureBoth.prototype.toString = function FutureBoth$toString(){ | ||
return `${this._left.toString()}.both(${this._right.toString()})`; | ||
} | ||
}; | ||
@@ -1488,7 +1490,7 @@ //---------- | ||
}); | ||
} | ||
}; | ||
FutureFold.prototype.toString = function FutureFold$toString(){ | ||
return `${this._parent.toString()}.fold(${showf(this._lfold)}, ${showf(this._rfold)})`; | ||
} | ||
}; | ||
@@ -1528,3 +1530,3 @@ //---------- | ||
return cancel; | ||
} | ||
}; | ||
const consumption = _this._consume(resource); | ||
@@ -1540,11 +1542,11 @@ check$hook$g(consumption, _this._consume, resource); | ||
cancelConsume(); | ||
} | ||
}; | ||
}); | ||
cancel = cancel || cancelAcquire; | ||
return function FutureHook$fork$cancel(){ cancel() }; | ||
} | ||
}; | ||
FutureHook.prototype.toString = function FutureHook$toString(){ | ||
return `${this._acquire.toString()}.hook(${showf(this._dispose)}, ${showf(this._consume)})`; | ||
} | ||
}; | ||
@@ -1569,7 +1571,7 @@ //---------- | ||
return cancel || (cancel = r, function FutureFinally$fork$cancel(){ cancel() }); | ||
} | ||
}; | ||
FutureFinally.prototype.toString = function FutureFinally$toString(){ | ||
return `${this._left.toString()}.finally(${this._right.toString()})`; | ||
} | ||
}; | ||
@@ -1576,0 +1578,0 @@ Future.classes = { |
{ | ||
"name": "fluture", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "FantasyLand compliant (monadic) alternative to Promises", | ||
"main": "fluture.js", | ||
"files": [ | ||
"es5.js" | ||
], | ||
"repository": "https://github.com/Avaq/fluture.git", | ||
"scripts": { | ||
"check-security": "nsp check", | ||
"build": "babel fluture.js -o es5.js", | ||
"clean": "rimraf npm-debug.log coverage", | ||
"lint": "eslint fluture.js test", | ||
"post-merge": "npm install && npm dedupe && npm run check-security && npm outdated --long", | ||
"pre-push": "npm run lint && npm run test:unit", | ||
"release": "xyz --edit --repo git@github.com:Avaq/Fluture.git --tag 'X.Y.Z' --increment", | ||
"setup": "npm run post-merge && cp scripts/hooks/* .git/hooks && git config push.followTags true", | ||
"lint:fix": "eslint --fix fluture.js test", | ||
"lint:readme": "remark --no-stdout --frail -u remark-validate-links README.md", | ||
"postcheckout": "npm install", | ||
"postmerge": "npm install", | ||
"precommit": "npm run lint && npm run lint:readme && npm run test:unit", | ||
"prepublish": "npm run build", | ||
"release": "npm outdated --long && xyz --edit --repo git@github.com:Avaq/Fluture.git --tag 'X.Y.Z' --increment", | ||
"toc": "node scripts/toc.js", | ||
@@ -19,5 +25,5 @@ "test": "npm run test:all && codecov", | ||
"test:mem": "node scripts/test-mem", | ||
"test:all": "npm run lint && npm run test:unit && npm run test:coverage", | ||
"test:unit": "node ./node_modules/.bin/_mocha --ui bdd --reporter list --check-leaks --full-trace test/**.test.js", | ||
"test:coverage": "npm run clean && node node_modules/.bin/istanbul cover --report html ./node_modules/.bin/_mocha -- --ui bdd --reporter dot --bail test/**.test.js" | ||
"test:all": "npm run lint && npm run lint:readme && npm run test:unit && npm run test:coverage", | ||
"test:unit": "_mocha --ui bdd --reporter list --check-leaks --full-trace test/**.test.js", | ||
"test:coverage": "npm run clean && istanbul cover --report html _mocha -- --ui bdd --reporter dot --bail test/**.test.js" | ||
}, | ||
@@ -33,5 +39,2 @@ "author": "Aldwin Vlasblom <aldwin.vlasblom@gmail.com> (https://github.com/Avaq)", | ||
}, | ||
"files": [ | ||
"fluture.js" | ||
], | ||
"keywords": [ | ||
@@ -57,6 +60,8 @@ "algebraic", | ||
"dependencies": { | ||
"inspect-f": "^1.1.0", | ||
"inspect-f": "^1.2.0", | ||
"sanctuary-type-classes": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.18.0", | ||
"babel-preset-latest": "^6.16.0", | ||
"benchmark": "^2.1.0", | ||
@@ -67,4 +72,6 @@ "chai": "^3.4.0", | ||
"eslint": "^3.0.1", | ||
"eslint-config-warp": "^1.2.0", | ||
"fantasy-land": "^2.0.0", | ||
"fun-task": "^1.5.1", | ||
"husky": "^0.12.0", | ||
"istanbul": "^0.4.2", | ||
@@ -76,6 +83,5 @@ "jsverify": "^0.7.1", | ||
"mocha": "^3.0.2", | ||
"nsp": "^2.2.0", | ||
"pacta": "^0.9.0", | ||
"ramda": "^0.22.1", | ||
"ramda-fantasy": "^0.7.0", | ||
"remark-cli": "^2.1.0", | ||
"remark-validate-links": "^5.0.0", | ||
"rimraf": "^2.4.3", | ||
@@ -82,0 +88,0 @@ "sanctuary": "^0.11.1", |
# Fluture | ||
[![Chat](https://badges.gitter.im/Avaq/Fluture.svg)](https://gitter.im/Avaq/Fluture) | ||
[![NPM Version](https://badge.fury.io/js/fluture.svg)](https://www.npmjs.com/package/fluture) | ||
@@ -34,3 +35,3 @@ [![Dependencies](https://david-dm.org/avaq/fluture.svg)](https://david-dm.org/avaq/fluture) | ||
> `npm install --save fluture` <sup>Requires a node 4.0.0 compatible environment</sup> | ||
> `npm install --save fluture` | ||
@@ -51,2 +52,4 @@ ```js | ||
For front-end applications and node <v4, please use `require('fluture/es5')`. | ||
## Table of contents | ||
@@ -66,3 +69,3 @@ | ||
* [encase](#encase) | ||
* [fromForkable](#fromForkable) | ||
* [fromForkable](#fromforkable) | ||
* [fromPromise](#frompromise) | ||
@@ -69,0 +72,0 @@ * [node](#node) |
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
135175
6
2624
964
23
Updatedinspect-f@^1.2.0