-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Optimized waterfall, parallel, et al. #1395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
cc06eac
4014466
2857bc7
2ae3492
67e76ea
fddea47
a6bd3a0
9b0f9eb
dddb9f5
53019a8
b8a051b
6ef3a91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import rest from './internal/rest'; | ||
import slice from './internal/slice'; | ||
|
||
/** | ||
* Creates a continuation function with some arguments already applied. | ||
|
@@ -12,10 +12,11 @@ import rest from './internal/rest'; | |
* @memberOf module:Utils | ||
* @method | ||
* @category Util | ||
* @param {Function} function - The function you want to eventually apply all | ||
* @param {Function} fn - The function you want to eventually apply all | ||
* arguments to. Invokes with (arguments...). | ||
* @param {...*} arguments... - Any number of arguments to automatically apply | ||
* when the continuation is called. | ||
* @returns {Function} the partially-applied function | ||
* @example | ||
* | ||
* // using apply | ||
|
@@ -44,8 +45,10 @@ import rest from './internal/rest'; | |
* two | ||
* three | ||
*/ | ||
export default rest(function(fn, args) { | ||
return rest(function(callArgs) { | ||
export default function(fn/*, args*/) { | ||
var args = slice(arguments, 1); | ||
return function(/*callArgs*/) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
var callArgs = slice(arguments); | ||
return fn.apply(null, args.concat(callArgs)); | ||
}); | ||
}); | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
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); | ||
wrapAsync(fn).apply(null, args.concat(function (err/*, ...args*/) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
var args = slice(arguments, 1); | ||
if (typeof console === 'object') { | ||
if (err) { | ||
if (console.error) { | ||
|
@@ -17,6 +19,6 @@ export default function consoleFunc(name) { | |
}); | ||
} | ||
} | ||
}))); | ||
}); | ||
})); | ||
}; | ||
} |
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: pop can be avoided, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm gonna leave as-is. The streamlined version of slice doesn't support the 3rd There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good |
||
fn.call(this, args, callback); | ||
}); | ||
}; | ||
} |
This file was deleted.
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/, ...args/