Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	component.json
  • Loading branch information
stephenmathieson committed Feb 24, 2015
2 parents 287d54c + 147e011 commit ce3b3c6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
5 changes: 4 additions & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"scripts": [
"index.js"
],
"license": "MIT"
"license": "MIT",
"development": {
"component/assert": "*"
}
}
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ module.exports = function parallel(fns, context, callback) {
var finished = false
var results = new Array(pending)

fns.forEach(context ? function (fn, i) {

for (var i = 0, l = fns.length; i < l; i++) {
var fn = fns[i]
fn.call(context, maybeDone(i))
} : function (fn, i) {
fn(maybeDone(i))
})
}

function maybeDone(i) {
return function (err, result) {
Expand Down
11 changes: 11 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<meta charset='utf8'>
<title>array-parallel tests</title>
</head>
<body>
<script src='build/build.js'></script>
<script src='test.js'></script>
</body>
</html>
10 changes: 7 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var assert = require('assert')
var parallel = require('./')
try {
var parallel = require('array-parallel')
} catch (e) {
var parallel = require('./')
}

var a, b, c
parallel([
Expand Down Expand Up @@ -57,6 +61,6 @@ parallel([function (done) {
done()
}])

process.nextTick(function () {
setTimeout(function () {
assert.equal(f, true)
})
})

0 comments on commit ce3b3c6

Please sign in to comment.