New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

run-auto

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

run-auto - npm Package Compare versions

Comparing version

to
2.0.0

12

index.js

@@ -90,3 +90,7 @@ var dezalgo = require('dezalgo')

if (ready()) {
task[task.length - 1](taskcb, results)
if (requires.length === 0) {
task[task.length - 1](taskcb)
} else {
task[task.length - 1](results, taskcb)
}
} else {

@@ -96,3 +100,7 @@ var listener = function () {

removeListener(listener)
task[task.length - 1](taskcb, results)
if (requires.length === 0) {
task[task.length - 1](taskcb)
} else {
task[task.length - 1](results, taskcb)
}
}

@@ -99,0 +107,0 @@ }

4

package.json
{
"name": "run-auto",
"description": "Determine the best order for running async functions, and run them",
"version": "1.1.3",
"version": "2.0.0",
"author": {

@@ -17,3 +17,3 @@ "name": "Feross Aboukhadijeh",

"devDependencies": {
"standard": "^4.3.2",
"standard": "^7.0.0",
"tape": "^4.0.0",

@@ -20,0 +20,0 @@ "zuul": "^3.1.0"

# run-auto [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]
[travis-image]: https://img.shields.io/travis/feross/run-auto.svg?style=flat
[travis-image]: https://img.shields.io/travis/feross/run-auto/master.svg
[travis-url]: https://travis-ci.org/feross/run-auto
[npm-image]: https://img.shields.io/npm/v/run-auto.svg?style=flat
[npm-image]: https://img.shields.io/npm/v/run-auto.svg
[npm-url]: https://npmjs.org/package/run-auto
[downloads-image]: https://img.shields.io/npm/dm/run-auto.svg?style=flat
[downloads-image]: https://img.shields.io/npm/dm/run-auto.svg
[downloads-url]: https://npmjs.org/package/run-auto

@@ -28,21 +28,16 @@

If any of the functions pass an error to their callback, it will not complete (so any
other functions depending on it will not run), and the main `callback` is immediately
called with the error. Functions also receive an object containing the results of
functions which have completed so far.
If any of the functions pass an error to their callback, the `auto` sequence will
stop. Further tasks will not execute (so any other functions depending on it will
not run), and the main `callback` is immediately called with the error.
For a complicated series of async tasks, using `auto` makes adding new tasks much easier
(and the code more readable).
Functions also receive an object containing the results of functions which have
completed so far as the first argument, if they have dependencies. If a task
function has no dependencies, it will only be passed a callback.
##### arguments
- `tasks` - An object. Each of its properties is either a function or an array of
requirements, with the function itself the last item in the array. The object's key of a property serves as the name of the task defined by that property, i.e. can be used when specifying requirements for other tasks. The function receives two arguments:
(1) a `callback(err, result)` which must be called when finished, passing an `error`
(which can be `null`) and the result of the function's execution, and (2) a `results`
object, containing the results of the previously executed functions.
- `callback(err, results)` - An optional callback which is called when all the tasks have
been completed. It receives the `err` argument if any tasks pass an error to their
callback. Results are always returned; however, if an error occurs, no further tasks will
be performed, and the results object will only contain partial results.
- `tasks` - An object. Each of its properties is either a function or an array of requirements, with the function itself the last item in the array. The object's key of a property serves as the name of the task defined by that property, i.e. can be used when specifying requirements for other tasks. The function receives one or two arguments:
- a `results` object, containing the results of the previously executed functions, only passed if the task has any dependencies, **Argument order changed in 2.0**
- a `callback(err, result)` function, which must be called when finished, passing an `error` (which can be `null`) and the result of the function's execution. **Argument order changed in 2.0**
- `callback(err, results)` - An optional callback which is called when all the tasks have been completed. It receives the `err` argument if any `tasks` pass an error to their callback. Results are always returned; however, if an error occurs, no further `tasks` will be performed, and the results object will only contain partial results.

@@ -66,3 +61,3 @@ ##### example

},
writeFile: ['getData', 'makeFolder', function (callback, results) {
writeFile: ['getData', 'makeFolder', function (results, callback) {
console.log('in writeFile', JSON.stringify(results))

@@ -73,3 +68,3 @@ // once there is some data and the directory exists,

}],
emailLink: ['writeFile', function (callback, results) {
emailLink: ['writeFile', function (results, callback) {
console.log('in emailLink', JSON.stringify(results))

@@ -76,0 +71,0 @@ // once the file is written let's email a link to it...

@@ -8,3 +8,3 @@ var auto = require('../')

var tasks = {
task1: ['task2', function (cb) {
task1: ['task2', function (results, cb) {
setTimeout(function () {

@@ -21,11 +21,11 @@ callOrder.push('task1')

},
task3: ['task2', function (cb) {
task3: ['task2', function (results, cb) {
callOrder.push('task3')
cb(null, 'res3')
}],
task4: ['task1', 'task2', function (cb) {
task4: ['task1', 'task2', function (results, cb) {
callOrder.push('task4')
cb(null, 'res4')
}],
task5: ['task2', function (cb) {
task5: ['task2', function (results, cb) {
setTimeout(function () {

@@ -36,3 +36,3 @@ callOrder.push('task5')

}],
task6: ['task2', function (cb) {
task6: ['task2', function (results, cb) {
callOrder.push('task6')

@@ -39,0 +39,0 @@ cb(null, 'res6')

@@ -12,3 +12,3 @@ var auto = require('../')

},
b: ['a', function (cb) {
b: ['a', function (results, cb) {
t.fail('cb 2 should not get called')

@@ -28,6 +28,6 @@ }]

},
task2: ['task1', function (cb) {
task2: ['task1', function (results, cb) {
cb(new Error('testerror'), 'result2')
}],
task3: ['task2', function (cb) {
task3: ['task2', function (results, cb) {
t.fail('task3 should not be called')

@@ -34,0 +34,0 @@ }]

Sorry, the diff of this file is not supported yet