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
Optimized waterfall, parallel, et al. #1395
Changes from all 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,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); | ||
}; | ||
} |
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.
nit:
...callArgs