Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Small API change to next.parallel

  • Loading branch information...
commit b64237651c4a5c62489871bd15e945a45b64afb5 1 parent 136164e
@tim-smart authored
Showing with 13 additions and 13 deletions.
  1. +6 −6 README.md
  2. +2 −2 lib/parallel/index.js
  3. +2 −2 package.json
  4. +3 −3 test.js
View
12 README.md
@@ -87,12 +87,12 @@ Also some usage of `Sequence`:
// The extra args gets suffixed onto the arguments
sys.puts('The size of this example is: ' + buffer.length);
- // next.parallel() is a function you need to call
- // to return a callback that enables you to do
- // multiple tasks at once. It should only be used in cases
- // where the expected arguments are: error, result
- fs.readdir(__dirname, next.parallel());
- fs.readdir(path.join(__dirname, 'lib'), next.parallel());
+ // next.parallel is a variable you can pass which
+ // enables you to do multiple tasks at once.
+ // It should only be used in cases where the expected
+ // arguments passed to the callback are: error, result
+ fs.readdir(__dirname, next.parallel);
+ fs.readdir(path.join(__dirname, 'lib'), next.parallel);
}
]);
View
4 lib/parallel/index.js
@@ -97,7 +97,7 @@ Sequence.prototype.run = function run(callback) {
var counter = 0,
results = [],
error = null;
- next.parallel = function parallel() {
+ next.__defineGetter__('parallel', function parallel() {
var i = counter++;
results[i] = null;
return function () {
@@ -113,7 +113,7 @@ Sequence.prototype.run = function run(callback) {
counter = 0; results = []; error = null;
}
};
- };
+ });
if (tasks.length > 0) {
tasks.shift()(next);
View
4 package.json
@@ -1,8 +1,8 @@
{
"name": "parallel",
"description": "Create tasks in node.js that run in parallel, or sequences that run tasks one after another.",
- "version": "0.1.0",
- "author": "Tim-Smart",
+ "version": "0.1.1",
+ "author": "Tim Smart",
"repository": {
"type": "git",
"url": "http://github.com/Tim-Smart/node-parallel.git"
View
6 test.js
@@ -33,9 +33,9 @@ var seq = new parallel.Sequence(
},
function (next, text) {
sys.puts(text);
- process.nextTick(next.parallel());
- process.nextTick(next.parallel());
- process.nextTick(next.parallel());
+ process.nextTick(next.parallel);
+ process.nextTick(next.parallel);
+ process.nextTick(next.parallel);
},
function (next, err, results) {
sys.puts('sequence-3');
Please sign in to comment.
Something went wrong with that request. Please try again.