Permalink
Browse files

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: #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>
  • Loading branch information...
thefourtheye authored and Fishrock123 committed Aug 20, 2016
1 parent 0f977f9 commit d67ece2f688f6a350afedc72dd615fdc6e163f60
Showing with 7 additions and 7 deletions.
  1. +1 −1 doc/api/util.md
  2. +6 −6 lib/util.js
View
@@ -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
@@ -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) {

0 comments on commit d67ece2

Please sign in to comment.