util: improve function signature of util._extend

The function signature of `util._extend` is not intuitive and the
documentation doesn't specify the necessary second parameter. This
patch changes the parameter names in the code and the function params
in doc.

PR-URL: https://github.com/nodejs/node/pull/8187
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
Sakthipriyan Vairamani 2016-08-20 08:23:28 +05:30
parent 02ed21aa5c
commit b3e7ac2605
No known key found for this signature in database
GPG Key ID: 800C90E774692D78
2 changed files with 7 additions and 7 deletions

View File

@ -812,7 +812,7 @@ deprecated: v0.11.3
Deprecated predecessor of `console.log`.
### util.\_extend(obj)
### util.\_extend(target, source)
<!-- YAML
added: v0.7.5
deprecated: v6.0.0

View File

@ -983,16 +983,16 @@ exports.inherits = function(ctor, superCtor) {
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
};
exports._extend = function(origin, add) {
// Don't do anything if add isn't an object
if (add === null || typeof add !== 'object') return origin;
exports._extend = function(target, source) {
// Don't do anything if source isn't an object
if (source === null || typeof source !== 'object') return target;
var keys = Object.keys(add);
var keys = Object.keys(source);
var i = keys.length;
while (i--) {
origin[keys[i]] = add[keys[i]];
target[keys[i]] = source[keys[i]];
}
return origin;
return target;
};
function hasOwnProperty(obj, prop) {