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 0.6.2 to 0.6.3-beta.1

75

fluture.js

@@ -43,5 +43,5 @@ /*global define FantasyLand inspectf*/

////////////////////
// Error handling //
////////////////////
///////////////
// Utilities //
///////////////

@@ -74,4 +74,26 @@ //A small string representing a value, but not containing the whole value.

const showf = f => inspectf(2, f).replace(/^/gm, ' ').trim();
const padf = (sf, s) => s.replace(/^/gm, sf).trim();
const showf = f => padf(' ', inspectf(2, f));
const fid = f => f.name ? f.name : /*istanbul ignore next*/ '<anonymous>';
//Partially apply a function with a single argument.
function unaryPartial(f, a){
const g = function partial(b, c){ return arguments.length > 1 ? f(a, b, c) : f(a, b) };
g.toString = () => `${inspectf(2, f)}.bind(null, ${show(a)})`;
g.inspect = () => `[Function: unaryPartial$${fid(f)}]`;
return g;
}
//Partially apply a function with two arguments.
function binaryPartial(f, a, b){
const g = function partial(c){ return f(a, b, c) };
g.toString = () => `${inspectf(2, f)}.bind(null, ${show(a)}, ${show(b)})`;
g.inspect = () => `[Function: binaryPartial$${fid(f)}]`;
return g;
}
////////////
// Errors //
////////////
function error$invalidArgument(it, at, expected, actual){

@@ -409,6 +431,9 @@ throw new TypeError(

function createNullaryDispatcher(method){
return function dispatch(m){
const f = function nullaryDispatch(m){
if(m && typeof m[method] === 'function') return m[method]();
error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m);
};
f.toString = () => `function dispatch$${method}(m){ m.${method}() }`;
f.inspect = () => `[Function: dispatch$${method}]`;
return f;
}

@@ -418,17 +443,35 @@

function createUnaryDispatcher(method){
return function dispatch(a, m){
if(arguments.length === 1) return m => dispatch(a, m);
const f = function unaryDispatch(a, m){
if(arguments.length === 1) return unaryPartial(f, a);
if(m && typeof m[method] === 'function') return m[method](a);
error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m);
};
f.toString = () => `function dispatch$${method}(a, m){ m.${method}(a) }`;
f.inspect = () => `[Function: dispatch$${method}]`;
return f;
}
//Creates a dispatcher for a unary method, but takes the object first rather than last.
function createInvertedUnaryDispatcher(method){
const f = function invertedUnaryDispatch(m, a){
if(arguments.length === 1) return unaryPartial(f, m);
if(m && typeof m[method] === 'function') return m[method](a);
error$invalidArgument(`Future.${method}`, 1, `have a "${method}" method`, m);
};
f.toString = () => `function dispatch$${method}(m, a){ m.${method}(a) }`;
f.inspect = () => `[Function: dispatch$${method}]`;
return f;
}
//Creates a dispatcher for a binary method.
function createBinaryDispatcher(method){
return function dispatch(a, b, m){
if(arguments.length === 1) return (b, m) => m ? dispatch(a, b, m) : dispatch(a, b);
if(arguments.length === 2) return m => dispatch(a, b, m);
const f = function binaryDispatch(a, b, m){
if(arguments.length === 1) return unaryPartial(f, a);
if(arguments.length === 2) return binaryPartial(f, a, b);
if(m && typeof m[method] === 'function') return m[method](a, b);
error$invalidArgument(`Future.${method}`, 2, `have a "${method}" method`, m);
};
f.toString = () => `function dispatch$${method}(a, b, m){ m.${method}(a, b) }`;
f.inspect = () => `[Function: dispatch$${method}]`;
return f;
}

@@ -446,7 +489,3 @@

//ap :: Apply m => m (a -> b) -> m a -> m b
Future.ap = function dispatch$ap(m, a){
if(arguments.length === 1) return a => dispatch$ap(m, a);
if(m && typeof m.ap === 'function') return m.ap(a);
error$invalidArgument('Future.ap', 0, 'have a "ap" method', m);
};
Future.ap = createInvertedUnaryDispatcher('ap');

@@ -491,3 +530,3 @@ //fork :: (a -> Void) -> (b -> Void) -> Future a b -> Void

Future.after = function Future$after(n, x){
if(arguments.length === 1) return x => Future$after(n, x);
if(arguments.length === 1) return unaryPartial(Future.after, n);
check$after(n);

@@ -511,3 +550,3 @@ return new FutureClass(function Future$after$fork(rej, res){

Future.encase = function Future$encase(f, x){
if(arguments.length === 1) return x => Future$encase(f, x);
if(arguments.length === 1) return unaryPartial(Future.encase, f);
check$encase(f);

@@ -542,3 +581,3 @@ return new FutureClass(function Future$encase$fork(rej, res){

Future.parallel = function Future$parallel(i, ms){
if(arguments.length === 1) return ms => Future$parallel(i, ms);
if(arguments.length === 1) return unaryPartial(Future.parallel, i);
check$parallel(i, ms);

@@ -545,0 +584,0 @@ const l = ms.length;

{
"name": "fluture",
"version": "0.6.2",
"version": "0.6.3-beta.1",
"description": "A mathematically correct alternative to Promises for asynchronous control flow",

@@ -15,5 +15,6 @@ "main": "fluture.js",

"setup": "npm run post-merge && cp scripts/hooks/* .git/hooks && git config push.followTags true",
"test": "npm run check-version && npm run clean && npm run lint && npm run test:unit",
"test": "npm run check-version && npm run clean && npm run lint && npm run test:unit && npm run test:coverage",
"test:opt": "node --allow-natives-syntax --trace-opt --trace-deopt --trace-inlining scripts/test-opt",
"test:unit": "node --harmony-destructuring node_modules/.bin/istanbul cover --report html ./node_modules/.bin/_mocha -- --ui bdd --reporter spec --check-leaks --full-trace && codecov"
"test:unit": "node --harmony-destructuring ./node_modules/.bin/_mocha --ui bdd --reporter spec --check-leaks --full-trace",
"test:coverage": "node --harmony-destructuring node_modules/.bin/istanbul cover --report html ./node_modules/.bin/_mocha -- --ui bdd --reporter dot --bail --check-leaks && codecov"
},

@@ -29,3 +30,5 @@ "author": "Aldwin Vlasblom <aldwin.vlasblom@gmail.com> (https://github.com/Avaq)",

},
"files": ["fluture.js"],
"files": [
"fluture.js"
],
"keywords": [

@@ -50,3 +53,3 @@ "async",

"fantasy-land": "^0.2.1",
"inspect-f": "^1.0.0"
"inspect-f": "^1.1.0"
},

@@ -53,0 +56,0 @@ "devDependencies": {

@@ -62,11 +62,16 @@ # Fluture

## Motivation
## Motivation and Features
Existing implementations of Future are a pain to debug. This library was made in
an effort to provide **great error messages** when something goes wrong. The
library also comes bundled with many **async control utilities**. To prevent
these features from coming at the cost of performance, Fluture was optimized to
operate at **high performance**. For an overview of differences between Fluture
and other Future implementations, look at [this wiki article][15].
an effort to provide **great error messages** when something goes wrong. Other
features include:
* Plenty of async control utilites like
[Future.parallel](#parallel--positiveinteger---future-a-b---future-a-b) and
[Future#race](#race--future-a-b--future-a-b---future-a-b).
* High performance.
To learn more about the differences between Fluture and other Future
implementations, take a look at [this wiki page][15].
## Documentation

@@ -73,0 +78,0 @@

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