src: be more intelligent about use of "arguments"

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
https://github.com/joyent/node/pull/8302#issuecomment-54331801

Confirmed in
https://github.com/joyent/node/pull/8302#issuecomment-54364818

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
Trevor Norris 2014-09-03 14:24:50 -07:00
parent 73631bbcc8
commit 9b8837b355
3 changed files with 6 additions and 2 deletions

View File

@ -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.

View File

@ -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)) {

View File

@ -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);
};