Skip to content

Commit

Permalink
src: be more intelligent about use of "arguments"
Browse files Browse the repository at this point in the history
Use 'use strict' when there are named arguments and the arguments object
is passed to apply(). Also pass named arguments to call() when the named
argument is modified by the function.

Suggested in
nodejs/node-v0.x-archive#8302 (comment)

Confirmed in
nodejs/node-v0.x-archive#8302 (comment)

Signed-off-by: Trevor Norris <[email protected]>
  • Loading branch information
trevnorris committed Sep 3, 2014
1 parent 73631bb commit 9b8837b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ function setupChannel(target, channel) {
var obj = handleConversion[message.type];

// convert TCP object to native handle object
handle = handleConversion[message.type].send.apply(target, arguments);
handle =
handleConversion[message.type].send.call(target, message, handle);

// If handle was sent twice, or it is impossible to get native handle
// out of it - just send a text without the handle.
Expand Down
2 changes: 2 additions & 0 deletions lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@ function sendHelper(proc, message, handle, cb) {
// to the callback but intercepts and redirects ACK messages.
function internal(worker, cb) {
return function(message, handle) {
'use strict';

if (message.cmd !== 'NODE_CLUSTER') return;
var fn = cb;
if (!util.isUndefined(message.ack)) {
Expand Down
3 changes: 2 additions & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,10 @@ Socket.prototype.__defineGetter__('localPort', function() {


Socket.prototype.write = function(chunk, encoding, cb) {
'use strict';
if (!util.isString(chunk) && !util.isBuffer(chunk))
throw new TypeError('invalid data');
return stream.Duplex.prototype.write.call(this, chunk, encoding, cb);
return stream.Duplex.prototype.write.apply(this, arguments);
};


Expand Down

0 comments on commit 9b8837b

Please sign in to comment.