Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change API to use the EventEmitter style
- Loading branch information
Showing
9 changed files
with
245 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
|
||
var each = require('each'); | ||
|
||
// With an `end_callback` in `parallel` mode: | ||
|
||
each([ | ||
{id: 1}, | ||
{id: 2}, | ||
{id: 3} | ||
], true, function(id, next) { | ||
each( [{id: 1}, {id: 2}, {id: 3}], true ) | ||
.on('data', function(next, id) { | ||
console.log('id: ', id); | ||
setTimeout(next, 500); | ||
}, function(err){ | ||
if(err){ | ||
console.log(err.message); | ||
err.errors.forEach(function(error){ | ||
console.log(' '+error.message); | ||
}); | ||
}else{ | ||
console.log('Done'); | ||
} | ||
}) | ||
.on('error', function(err, errors){ | ||
console.log(err.message); | ||
errors.forEach(function(error){ | ||
console.log(' '+error.message); | ||
}); | ||
}) | ||
.on('end', function(){ | ||
console.log('Done'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
|
||
var each = require('each'); | ||
|
||
// Without an `end_callback` in `chained` mode: | ||
|
||
each([ | ||
{id: 1}, | ||
{id: 2}, | ||
{id: 3} | ||
], function(id, next) { | ||
if(next instanceof Error) return console.log(err.message); | ||
if(!next) return console.log('Done'); | ||
each( [{id: 1}, {id: 2}, {id: 3}] ) | ||
.on('data', function(next, id) { | ||
console.log('id: ', id); | ||
setTimeout(next, 500); | ||
}) | ||
.on('error', function(err) { | ||
console.log(err.message); | ||
}) | ||
.on('end', function() { | ||
console.log('Done'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
|
||
var each = require('each'); | ||
|
||
// With an `end_callback` in `parallel` mode: | ||
|
||
each({ | ||
id_1: 1, | ||
id_2: 2, | ||
id_3: 3 | ||
}, true, function(key, value, next) { | ||
each( {id_1: 1, id_2: 2, id_3: 3}, true ) | ||
.on('data', function(next, key, value) { | ||
console.log('key: ', key); | ||
console.log('value: ', value); | ||
setTimeout(next, 500); | ||
}, function(err){ | ||
if(err){ | ||
console.log(err.message); | ||
err.errors.forEach(function(error){ | ||
console.log(' '+error.message); | ||
}); | ||
}else{ | ||
console.log('Done'); | ||
} | ||
}) | ||
.on('error', function(err, errors){ | ||
console.log(err.message); | ||
errors.forEach(function(error){ | ||
console.log(' '+error.message); | ||
}); | ||
}) | ||
.on('end', function(){ | ||
console.log('Done'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
|
||
var each = require('each'); | ||
|
||
// Without an `end_callback` in `chained` mode: | ||
|
||
each({ | ||
id_1: 1, | ||
id_2: 2, | ||
id_3: 3 | ||
}, function(key, value, next) { | ||
if(next instanceof Error) return console.log(err.message); | ||
if(!next) return console.log('Done'); | ||
each( {id_1: 1, id_2: 2, id_3: 3} ) | ||
.on('data', function(next, key, value) { | ||
console.log('key: ', key); | ||
console.log('value: ', value); | ||
setTimeout(next, 500); | ||
}) | ||
.on('error', function(err) { | ||
console.log(err.message); | ||
}) | ||
.on('end', function() { | ||
console.log('Done'); | ||
}); |
Oops, something went wrong.