From 78ddd9bc8058137df5f9e38bb83606d126f07765 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Sun, 14 Feb 2016 15:32:33 +0800 Subject: [PATCH] console: apply null as `this` for util.format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Util.format is just a stateless function. Apply current console as `this` is unnecessary. PR-URL: https://github.com/nodejs/node/pull/5222 Reviewed-By: James M Snell Reviewed-By: Roman Reiss Reviewed-By: Michaƫl Zasso --- lib/console.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/console.js b/lib/console.js index f9032e24a0..5628c93007 100644 --- a/lib/console.js +++ b/lib/console.js @@ -33,7 +33,7 @@ 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'); }; @@ -41,7 +41,7 @@ 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'); }; @@ -75,7 +75,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); }; @@ -84,7 +84,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)); } };