Comparing version 1.0.1 to 1.0.2
@@ -8,3 +8,3 @@ 'use strict'; | ||
function parallel(tasks, fn) { | ||
var errors = [], counter = 0, limit = Object.keys(tasks).length; | ||
var errors = [], counter = 0, limit = Object.keys(tasks).length, results = {}; | ||
if (limit === 0) { | ||
@@ -19,6 +19,6 @@ fn({}, []); | ||
} | ||
tasks[key] = out; | ||
results[key] = out; | ||
counter++; | ||
if(counter >= limit) { | ||
fn(tasks, errors); | ||
fn(results, errors); | ||
} | ||
@@ -25,0 +25,0 @@ } |
{ | ||
"name": "datamodel", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [], |
@@ -109,3 +109,14 @@ # Datamodel | ||
## Example 3 : Combine a datamodel and a route with Express | ||
```javascript | ||
var app = require('express'); | ||
app.route('/resource/:param1/:param2').all(require('./obj.js')); | ||
``` | ||
# API Documentation | ||
@@ -112,0 +123,0 @@ |
@@ -212,5 +212,23 @@ /* global describe, it */ | ||
); | ||
it('12 - declare', function (done) { | ||
var m = datamodel() | ||
.declare('a', function(input, fill) { | ||
fill('(a)'); | ||
}); | ||
m.apply(function(err, res1) { | ||
assert.equal(res1.a, '(a)'); | ||
m.apply(function(err, res2) { | ||
assert.equal(res2.a, '(a)'); | ||
done(); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
/* */ | ||
} | ||
) |
16499
422
137