-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
refactor: foregroundChild arguments normalization #25
Conversation
6c0acb9
to
ac478ce
Compare
The CI failure seems to be an Appveyor issue (issue in their |
This also fixes a bug: #30 (comment) |
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.
Just nitpicks.
index.js
Outdated
var lastFgArg = fgArgs[fgArgs.length - 1]; | ||
if (typeof lastFgArg === "function") { | ||
cb = lastFgArg; | ||
processArgsEnd--; |
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.
Prefer use of -= 1
instead for explicitness.
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.
Should I push force the update or use an extra commit to address this?
} else if (!Array.isArray(args)) { | ||
args = [].slice.call(arguments, 1, arrayIndex) | ||
} | ||
return {program: program, args: args, cb: cb}; |
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.
Since we're doing ES6, this could just be:
return { program, args, cb };
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.
Well, no ES6 for the moment. But yeah, I used object short hand originally.
I'll send a follow-up PR to move to ES6.
* ``` | ||
*/ | ||
module.exports = function (/* program, args, cb */) { | ||
var fgArgs = normalizeFgArgs([].slice.call(arguments, 0)); |
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.
Why not just Array.from(arguments)
?
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.
This is what was used originally. I plan to move to ES6 later anyway, where it'll simply become function(...fgArgs)
.
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.
Ok...
4b2371c
to
244e8e1
Compare
# Why `foregroundChild` has a complex signature. Using a dedicated function for arguments normalization would improve clarity. # What Document the signature of `foregroundChild`, move arguments normalization to a separate function, small simplification to the normalization.
244e8e1
to
afc1466
Compare
@demurgos this seems reasonable to me, do we have tests already for each function signature? |
Why
foregroundChild
has a complex signature. Using a dedicated function for arguments normalization would improve clarity.What
Document the signature of
foregroundChild
, move arguments normalization to a separate function, small simplification to the normalization.