-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking: Remove timing methods & switch to now-and-later for series/…
…parallel
- Loading branch information
Showing
10 changed files
with
73 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
'use strict'; | ||
|
||
var asyncDone = require('async-done'); | ||
|
||
var createSeries = require('./lib/createSeries'); | ||
var createParallel = require('./lib/createParallel'); | ||
|
||
module.exports = { | ||
series: createSeries(asyncDone), | ||
parallel: createParallel(asyncDone) | ||
series: require('./lib/series'), | ||
parallel: require('./lib/parallel') | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
var asyncDone = require('async-done'); | ||
var nowAndLater = require('now-and-later'); | ||
|
||
var verifyArguments = require('./verifyArguments'); | ||
|
||
function buildParallel(){ | ||
var args = verifyArguments(arguments); | ||
|
||
var extensions = {}; | ||
if(typeof _.last(args) !== 'function'){ | ||
extensions = _.last(args); | ||
} | ||
|
||
function parallel(done){ | ||
nowAndLater.parallel(args, asyncDone, extensions, done); | ||
} | ||
|
||
return parallel; | ||
} | ||
|
||
module.exports = buildParallel; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
var asyncDone = require('async-done'); | ||
var nowAndLater = require('now-and-later'); | ||
|
||
var verifyArguments = require('./verifyArguments'); | ||
|
||
function buildSeries(){ | ||
var args = verifyArguments(arguments); | ||
|
||
var extensions = {}; | ||
if(typeof _.last(args) !== 'function'){ | ||
extensions = _.last(args); | ||
} | ||
|
||
function series(done){ | ||
nowAndLater.series(args, asyncDone, extensions, done); | ||
} | ||
|
||
return series; | ||
} | ||
|
||
module.exports = buildSeries; |
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,13 +1,25 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
|
||
module.exports = function(args){ | ||
var _ = require('lodash'); | ||
|
||
function verifyArguments(args){ | ||
args = _.flatten(args); | ||
|
||
assert(args.length > 0, 'A set of functions to combine is mandatory'); | ||
assert.ok(args.length, 'A set of functions to combine is required'); | ||
|
||
args.forEach(function(arg, argIdx){ | ||
assert.equal(typeof arg, 'function', | ||
'Only functions can be combined, got ' + typeof arg + ' for argument ' + argIdx); | ||
_.forEach(args, function(arg, argIdx){ | ||
var isFunction = _.isFunction(arg); | ||
if(isFunction){ | ||
return; | ||
} | ||
|
||
var msg = 'Only functions can be combined, got ' + typeof arg + ' for argument ' + argIdx; | ||
assert.ok(isFunction, msg); | ||
}); | ||
|
||
return args; | ||
}; | ||
} | ||
|
||
module.exports = verifyArguments; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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