Skip to content

Commit

Permalink
squash: groupIndent -> kgroupIndent
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Aug 22, 2017
1 parent c1d5bcc commit 667be1a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const util = require('util');
const kCounts = Symbol('counts');

// Track amount of indentation required via `console.group()`.
const groupIndent = Symbol('groupIndent');
const kGroupIndent = Symbol('groupIndent');

function Console(stdout, stderr, ignoreErrors = true) {
if (!(this instanceof Console)) {
Expand Down Expand Up @@ -60,15 +60,14 @@ function Console(stdout, stderr, ignoreErrors = true) {
Object.defineProperty(this, '_stderrErrorHandler', prop);

this[kCounts] = new Map();
this[kGroupIndent] = '';

// bind the prototype functions to this Console instance
var keys = Object.keys(Console.prototype);
for (var v = 0; v < keys.length; v++) {
var k = keys[v];
this[k] = this[k].bind(this);
}

this[groupIndent] = '';
}

// Make a function that can serve as the callback passed to `stream.write()`.
Expand Down Expand Up @@ -116,7 +115,7 @@ function write(ignoreErrors, stream, string, errorhandler) {
Console.prototype.log = function log(...args) {
write(this._ignoreErrors,
this._stdout,
`${this[groupIndent]}${util.format.apply(null, args)}\n`,
`${this[kGroupIndent]}${util.format.apply(null, args)}\n`,
this._stdoutErrorHandler);
};

Expand All @@ -127,7 +126,7 @@ Console.prototype.info = Console.prototype.log;
Console.prototype.warn = function warn(...args) {
write(this._ignoreErrors,
this._stderr,
`${this[groupIndent]}${util.format.apply(null, args)}\n`,
`${this[kGroupIndent]}${util.format.apply(null, args)}\n`,
this._stderrErrorHandler);
};

Expand All @@ -139,7 +138,7 @@ Console.prototype.dir = function dir(object, options) {
options = Object.assign({ customInspect: false }, options);
write(this._ignoreErrors,
this._stdout,
`${this[groupIndent]}${util.inspect(object, options)}\n`,
`${this[kGroupIndent]}${util.inspect(object, options)}\n`,
this._stdoutErrorHandler);
};

Expand Down Expand Up @@ -223,13 +222,14 @@ Console.prototype.group = function group(...data) {
if (data.length > 0) {
this.log(...data);
}
this[groupIndent] += ' ';
this[kGroupIndent] += ' ';
};

Console.prototype.groupCollapsed = Console.prototype.group;

Console.prototype.groupEnd = function groupEnd() {
this[groupIndent] = this[groupIndent].slice(0, this[groupIndent].length - 2);
this[kGroupIndent] =
this[kGroupIndent].slice(0, this[kGroupIndent].length - 2);
};

module.exports = new Console(process.stdout, process.stderr);
Expand Down

0 comments on commit 667be1a

Please sign in to comment.