Sorry, the diff of this file is not supported yet
+16
| A="$1" | ||
| echo '{ | ||
| "name": "'"$A"'", | ||
| "version": "2.0.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "author": "", | ||
| "license": "ISC" | ||
| }' > package.json | ||
| npm publish | ||
+5
-24
| { | ||
| "name": "serially", | ||
| "version": "1.1.0", | ||
| "description": "Compose async functions into one function that runs all serially", | ||
| "version": "2.0.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "node test" | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "devDependencies": { | ||
| "prova": "*", | ||
| "measure-time": "0.0.1" | ||
| }, | ||
| "keywords": [ | ||
| "serial", | ||
| "series", | ||
| "async", | ||
| "flow", | ||
| "flow control", | ||
| "serially" | ||
| ], | ||
| "repository": { | ||
| "url": "git@github.com:azer/serially.git", | ||
| "type": "git" | ||
| }, | ||
| "author": "azer", | ||
| "license": "BSD", | ||
| "dependencies": { | ||
| "serial-loop": "0.0.0" | ||
| } | ||
| "author": "", | ||
| "license": "ISC" | ||
| } |
Sorry, the diff of this file is not supported yet
-62
| var loop = require("serial-loop"); | ||
| module.exports = serially; | ||
| function serially (options) { | ||
| options || (options = {}); | ||
| var fns = []; | ||
| var self = { | ||
| then: then, | ||
| run: then, | ||
| done: call, | ||
| end: call | ||
| }; | ||
| return self; | ||
| function then (alias, fn, params) { | ||
| if (typeof alias != 'string') { | ||
| params = fn; | ||
| fn = alias; | ||
| alias = fn && fn.name; | ||
| } | ||
| if (typeof fn == 'undefined') { | ||
| throw new Error('serially: Undefined function given'); | ||
| } | ||
| fns.push({ alias: alias, fn: fn, params: params }); | ||
| return self; | ||
| } | ||
| function call (callback) { | ||
| var results = {}; | ||
| var len = fns.length; | ||
| (function next (i, error) { | ||
| if (error) return callback(error, results); | ||
| if (i >= len) return callback(undefined, results); | ||
| var params = fns[i].params; | ||
| if (!params) { | ||
| params = []; | ||
| } else { | ||
| params = params.slice(); | ||
| } | ||
| params.push(function (error) { | ||
| if (error) return next(i + 1, error); | ||
| results[fns[i].alias] = Array.prototype.slice.call(arguments, 1); | ||
| next(i+1); | ||
| }); | ||
| fns[i].fn.apply(options.context, params); | ||
| }(0)); | ||
| } | ||
| } |
| var time = require("measure-time"); | ||
| var serially = require("./"); | ||
| time('basic', function (end) { | ||
| serially() | ||
| .then(quux) | ||
| .then(corge) | ||
| .then(span) | ||
| .done(end); | ||
| }); | ||
| time('with parameters and aliases', function (end) { | ||
| serially() | ||
| .then(foo, ['hello', 'world', '!']) | ||
| .then('bar-alias', bar, [1, 2, 3]) | ||
| .then(qux, [4, 5, 6]) | ||
| .done(end); | ||
| }); | ||
| function foo (pa, ra, ms, callback) { | ||
| setImmediate(function () { | ||
| callback(undefined, pa + '\n' + ra + '\n' + ms); | ||
| }); | ||
| } | ||
| function bar (pa, ra, ms, callback) { | ||
| setImmediate(function () { | ||
| callback(undefined, pa + ra + ms); | ||
| }); | ||
| } | ||
| function qux (pa, ra, ms, callback) { | ||
| setImmediate(function () { | ||
| callback(undefined, pa * ra * ms); | ||
| }); | ||
| } | ||
| function quux (callback) { | ||
| setImmediate(function () { | ||
| callback(); | ||
| }); | ||
| } | ||
| function corge (callback) { | ||
| setImmediate(function () { | ||
| callback(); | ||
| }); | ||
| } | ||
| function span (callback) { | ||
| setImmediate(function () { | ||
| callback(); | ||
| }); | ||
| } |
-37
| ## serially | ||
| Compose async functions into one function that runs all serially | ||
| See also: [parallelly](http://github.com/azer/parallelly) | ||
| ## Install | ||
| ```bash | ||
| $ npm install serially | ||
| ``` | ||
| ## Usage | ||
| ```js | ||
| var serially = require('serially') | ||
| var http = require('http') | ||
| var fs = require('fs') | ||
| serially() | ||
| .then(foo, ['a', 'b', 'c']) | ||
| .then(bar, [1, 2, 3]) | ||
| .then('qux alias', qux, [4, 5, 6]) | ||
| .done(function (error, results) { | ||
| if (error) throw error | ||
| console.log('done') | ||
| console.log(results) | ||
| // => { foo: [...], bar: [...], qux alias: [...] } | ||
| }) | ||
| function foo (pa, ra, ms, callback) {} | ||
| function bar (pa, ra, ms, callback) {} | ||
| function qux (pa, ra, ms, callback) {} | ||
| ``` | ||
| See `test.js` for more info. |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
3636
3.95%0
-100%0
-100%3
-40%0
-100%3
50%2
100%2
100%0
-100%1
Infinity%2
Infinity%- Removed
- Removed