Skip to content

Commit

Permalink
index: fix _extend usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Feb 14, 2014
1 parent 2c51723 commit 95019e9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function inspect(obj, opts) {
ctx.showHidden = opts;
} else if (opts) {
// got an "options" object
exports._extend(ctx, opts);
_extend(ctx, opts);
}
// set default options
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
Expand Down Expand Up @@ -152,7 +152,7 @@ function formatValue(ctx, value, recurseTimes) {
value &&
isFunction(value.inspect) &&
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
value.inspect !== inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
var ret = value.inspect(recurseTimes, ctx);
Expand Down Expand Up @@ -352,3 +352,15 @@ function reduceToSingleString(output, base, braces) {

return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}

function _extend(origin, add) {
// Don't do anything if add isn't an object
if (!add || !isObject(add)) return origin;

var keys = objectKeys(add);
var i = keys.length;
while (i--) {
origin[keys[i]] = add[keys[i]];
}
return origin;
}

0 comments on commit 95019e9

Please sign in to comment.