+31
-12
@@ -35,4 +35,8 @@ /* | ||
| function isPromise(maybePromise) { | ||
| return maybePromise && typeof maybePromise.then === "function"; | ||
| var setImmediate = this.setImmediate || function (next) { | ||
| setTimeout(next, 0); | ||
| }; | ||
| function isPromise(p) { | ||
| return p && (typeof p === "object" || typeof p === "function") && typeof p.then === "function"; | ||
| } | ||
@@ -272,12 +276,18 @@ | ||
| SuperGroup.prototype.then = function (onSuccess, onError) { | ||
| SuperGroup.prototype.then = function (onFulfilled, onRejected) { | ||
| var defer = ff.defer(); | ||
| this.onSuccess(function () { | ||
| try { | ||
| if (typeof onSuccess !== "function") { | ||
| if (typeof onFulfilled !== "function") { | ||
| defer.apply(this, slice.call(arguments)); | ||
| } else { | ||
| var value = onSuccess.apply(this, slice.call(arguments)); | ||
| var value = onFulfilled.apply(undefined, slice.call(arguments)); | ||
| if (isPromise(value)) { | ||
| value.then(defer, defer.fail); | ||
| if (value === defer) { | ||
| throw new TypeError("promise and x refer to the same object"); | ||
| } else { | ||
| value.then(defer, defer.fail); | ||
| } | ||
| } else { | ||
@@ -291,10 +301,16 @@ defer(value); | ||
| }); | ||
| this.onError(function () { | ||
| try { | ||
| if (typeof onError !== "function") { | ||
| if (typeof onRejected !== "function") { | ||
| defer.fail.apply(this, slice.call(arguments)); | ||
| } else { | ||
| var value = onError.apply(this, slice.call(arguments)); | ||
| var value = onRejected.apply(undefined, slice.call(arguments)); | ||
| if (isPromise(value)) { | ||
| value.then(defer, defer.fail); | ||
| if (value === defer) { | ||
| throw new TypeError("promise and x refer to the same object"); | ||
| } else { | ||
| value.then(defer, defer.fail); | ||
| } | ||
| } else { | ||
@@ -308,2 +324,3 @@ defer(value); | ||
| }); | ||
| return defer; | ||
@@ -378,5 +395,5 @@ } | ||
| // console (in the browser) | ||
| setTimeout(function () { | ||
| setImmediate(function () { | ||
| handler && handler.apply(this.context || this, args); | ||
| }.bind(this), 0); | ||
| }.bind(this)); | ||
| } | ||
@@ -430,3 +447,5 @@ | ||
| // begin executing steps next time we yield to event loop | ||
| setTimeout(function(){ superGroup._execNextStep(); }, 0); | ||
| setImmediate(function () { | ||
| superGroup._execNextStep(); | ||
| }); | ||
@@ -433,0 +452,0 @@ return f; |
+18
-15
| { | ||
| "name": "ff", | ||
| "version": "0.2.0", | ||
| "description": "Concise, Powerful Asynchronous Flow Control in JavaScript", | ||
| "engine": [ "node >=0.2.0" ], | ||
| "author": "Marcus Cavanaugh <m@mcav.com>", | ||
| "version": "0.2.1", | ||
| "license": "MIT", | ||
| "description": "Concise, Powerful Asynchronous Flow Control in JavaScript.", | ||
| "keywords": ["async", "flow control"], | ||
| "homepage": "https://github.com/gameclosure/ff", | ||
| "bugs": "https://github.com/gameclosure/ff/issues", | ||
| "author": "Marcus Cavanaugh <m@mcav.com> (http://mcav.com)", | ||
| "contributors": [ | ||
| "Michael Henretty <michael.henretty@gmail.com>", | ||
| "Teddy Cross <tkazec@gmail.com>" | ||
| "Teddy Cross <teddy@tkaz.ec> (http://tkaz.ec)" | ||
| ], | ||
| "repository": { | ||
| "type" : "git", | ||
| "url" : "http://github.com/gameclosure/ff.git" | ||
| "main": "lib/ff", | ||
| "repository": "git://github.com/gameclosure/ff", | ||
| "scripts": { | ||
| "test": "mocha -R spec && promises-aplus-tests test/promise-adapter.js" | ||
| }, | ||
| "devDependencies": { | ||
| "chai": "*", | ||
| "mocha": "*", | ||
| "promises-aplus-tests": "*" | ||
| "chai": "~1.9.1", | ||
| "mocha": "~1.21.4", | ||
| "promises-aplus-tests": "~1.3.2" | ||
| }, | ||
| "scripts": { | ||
| "test": "mocha -R spec -t 5000 -s 1000 && promises-aplus-tests test/promise-adapter.js" | ||
| }, | ||
| "main": "lib/ff" | ||
| "engines": { | ||
| "node": ">=0.6.0" | ||
| } | ||
| } |
+1
-1
@@ -1,2 +0,2 @@ | ||
| # <img src="http://f.cl.ly/items/3K113g321o0n0W0Y0Z33/Fast%20Forward%20Icon%20in%2032x32%20px.png" width=25 height=25> ff: Concise, Powerful Asynchronous JavaScript Flow Control [](https://travis-ci.org/gameclosure/ff) | ||
| # <img src="http://f.cl.ly/items/3K113g321o0n0W0Y0Z33/Fast%20Forward%20Icon%20in%2032x32%20px.png" width="25" height="25"> ff: Concise, Powerful Asynchronous JavaScript Flow Control [](https://www.npmjs.org/package/ff) [](https://travis-ci.org/gameclosure/ff) | ||
@@ -3,0 +3,0 @@ ***ff* simplifies the most common use cases for series, parallel, and |
+15
-22
@@ -0,24 +1,17 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Mocha Tests</title> | ||
| <link rel="stylesheet" href="../node_modules/mocha/mocha.css" /> | ||
| </head> | ||
| <body> | ||
| <div id="mocha"></div> | ||
| <script src="../lib/ff.js"></script> | ||
| <script src="../node_modules/chai/chai.js"></script> | ||
| <script src="../node_modules/mocha/mocha.js"></script> | ||
| <script> | ||
| mocha.setup({ | ||
| ui: 'bdd', | ||
| timeout: 5000 | ||
| }); | ||
| debugger; | ||
| </script> | ||
| <script src="./index.js"></script> | ||
| <script> | ||
| mocha.run(); | ||
| </script> | ||
| </body> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Mocha Tests</title> | ||
| <link rel="stylesheet" href="../node_modules/mocha/mocha.css"> | ||
| </head> | ||
| <body> | ||
| <div id="mocha"></div> | ||
| <script src="../lib/ff.js"></script> | ||
| <script src="../node_modules/chai/chai.js"></script> | ||
| <script src="../node_modules/mocha/mocha.js"></script> | ||
| <script>mocha.setup("bdd")</script> | ||
| <script src="index.js"></script> | ||
| <script>mocha.run()</script> | ||
| </body> | ||
| </html> |
+12
-25
@@ -1,28 +0,15 @@ | ||
| (function () { | ||
| if (typeof module !== "undefined") { | ||
| var ff = require("../lib/ff"); | ||
| } | ||
| var ff = require("../lib/ff"); | ||
| var adapter = { | ||
| pending: function () { | ||
| var f = ff.defer(); | ||
| return { | ||
| promise: f, | ||
| fulfill: function (value) { | ||
| f(value); | ||
| }, | ||
| reject: function (reason) { | ||
| f.fail(reason); | ||
| } | ||
| } | ||
| module.exports.pending = function () { | ||
| var f = ff.defer(); | ||
| return { | ||
| promise: f, | ||
| fulfill: function (value) { | ||
| f(value); | ||
| }, | ||
| reject: function (reason) { | ||
| f.fail(reason); | ||
| } | ||
| }; | ||
| if (typeof module !== 'undefined') { | ||
| module.exports = adapter; | ||
| } else if (typeof exports !== 'undefined') { | ||
| exports = adapter; // jsio | ||
| } else { | ||
| this.adapter = adapter; | ||
| } | ||
| }()); | ||
| }; |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
35835
0.92%1
-50%3
50%