Skip to content

Commit

Permalink
console: apply null as this for util.format
Browse files Browse the repository at this point in the history
Util.format is just a stateless function. Apply current console
as `this` is unnecessary.

PR-URL: #5222
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
  • Loading branch information
JacksonTian authored and rvagg committed Feb 21, 2016
1 parent c48290d commit df93d60
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ function Console(stdout, stderr) {
}

Console.prototype.log = function() {
this._stdout.write(util.format.apply(this, arguments) + '\n');
this._stdout.write(util.format.apply(null, arguments) + '\n');
};


Console.prototype.info = Console.prototype.log;


Console.prototype.warn = function() {
this._stderr.write(util.format.apply(this, arguments) + '\n');
this._stderr.write(util.format.apply(null, arguments) + '\n');
};


Expand Down Expand Up @@ -76,7 +76,7 @@ Console.prototype.trace = function trace() {
// exposed.
var err = new Error();
err.name = 'Trace';
err.message = util.format.apply(this, arguments);
err.message = util.format.apply(null, arguments);
Error.captureStackTrace(err, trace);
this.error(err.stack);
};
Expand All @@ -85,7 +85,7 @@ Console.prototype.trace = function trace() {
Console.prototype.assert = function(expression) {
if (!expression) {
var arr = Array.prototype.slice.call(arguments, 1);
require('assert').ok(false, util.format.apply(this, arr));
require('assert').ok(false, util.format.apply(null, arr));
}
};

Expand Down

0 comments on commit df93d60

Please sign in to comment.