-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1395 from caolan/waterfall-optimization
Optimized waterfall, parallel, et al.
- Loading branch information
Showing
26 changed files
with
281 additions
and
265 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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
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
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,24 @@ | ||
import arrayEach from 'lodash/_arrayEach'; | ||
import rest from './rest'; | ||
import slice from './slice'; | ||
import wrapAsync from './wrapAsync'; | ||
|
||
export default function consoleFunc(name) { | ||
return rest(function (fn, args) { | ||
wrapAsync(fn).apply(null, args.concat(rest(function (err, args) { | ||
return function (fn/*, ...args*/) { | ||
var args = slice(arguments, 1); | ||
args.push(function (err/*, ...args*/) { | ||
var args = slice(arguments, 1); | ||
if (typeof console === 'object') { | ||
if (err) { | ||
if (console.error) { | ||
console.error(err); | ||
} | ||
} | ||
else if (console[name]) { | ||
} else if (console[name]) { | ||
arrayEach(args, function (x) { | ||
console[name](x); | ||
}); | ||
} | ||
} | ||
}))); | ||
}); | ||
}) | ||
wrapAsync(fn).apply(null, args); | ||
}; | ||
} |
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,8 +1,9 @@ | ||
import rest from './rest'; | ||
import slice from './slice'; | ||
|
||
export default function (fn) { | ||
return rest(function (args/*..., callback*/) { | ||
return function (/*...args, callback*/) { | ||
var args = slice(arguments); | ||
var callback = args.pop(); | ||
fn.call(this, args, callback); | ||
}); | ||
}; | ||
} |
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 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function slice(arrayLike, start) { | ||
start = start|0; | ||
var newLen = Math.max(arrayLike.length - start, 0); | ||
var newArr = Array(newLen); | ||
for(var idx = 0; idx < newLen; idx++) { | ||
newArr[idx] = arrayLike[start + idx]; | ||
} | ||
return newArr; | ||
} |
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
Oops, something went wrong.