Skip to content

Commit df93d60

Browse files
JacksonTianrvagg
authored andcommitted
console: apply null as this for util.format
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>
1 parent c48290d commit df93d60

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/console.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ function Console(stdout, stderr) {
3333
}
3434

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

3939

4040
Console.prototype.info = Console.prototype.log;
4141

4242

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

4747

@@ -76,7 +76,7 @@ Console.prototype.trace = function trace() {
7676
// exposed.
7777
var err = new Error();
7878
err.name = 'Trace';
79-
err.message = util.format.apply(this, arguments);
79+
err.message = util.format.apply(null, arguments);
8080
Error.captureStackTrace(err, trace);
8181
this.error(err.stack);
8282
};
@@ -85,7 +85,7 @@ Console.prototype.trace = function trace() {
8585
Console.prototype.assert = function(expression) {
8686
if (!expression) {
8787
var arr = Array.prototype.slice.call(arguments, 1);
88-
require('assert').ok(false, util.format.apply(this, arr));
88+
require('assert').ok(false, util.format.apply(null, arr));
8989
}
9090
};
9191

0 commit comments

Comments
 (0)