bare-console
Advanced tools
Comparing version 5.0.0 to 5.1.0
33
index.js
@@ -1,2 +0,2 @@ | ||
const inspect = require('bare-inspect') | ||
const { formatWithOptions } = require('bare-format') | ||
const hrtime = require('bare-hrtime') | ||
@@ -14,2 +14,3 @@ | ||
this.log = this.log.bind(this) | ||
this.warn = this.warn.bind(this) | ||
this.error = this.error.bind(this) | ||
@@ -23,7 +24,11 @@ this.time = this.time.bind(this) | ||
log (...args) { | ||
this._stdout.write(formatArgs(args, { colors: this._colors }) + '\n') | ||
this._stdout.write(formatWithOptions({ colors: this._colors }, ...args) + '\n') | ||
} | ||
warn (...args) { | ||
this._stderr.write(formatWithOptions({ colors: this._colors }, ...args) + '\n') | ||
} | ||
error (...args) { | ||
this._stderr.write(formatArgs(args, { colors: this._colors }) + '\n') | ||
this._stderr.write(formatWithOptions({ colors: this._colors }, ...args) + '\n') | ||
} | ||
@@ -57,4 +62,8 @@ | ||
trace (...args) { | ||
const err = { name: 'Trace', message: formatArgs(args, { colors: this._colors }) } | ||
Error.captureStackTrace(err, this.trace) | ||
const err = { name: 'Trace', message: formatWithOptions({ colors: this._colors }, ...args) } | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(err, this.trace) | ||
} | ||
this.error(err.stack) | ||
@@ -67,15 +76,1 @@ } | ||
} | ||
function formatArgs (args, opts) { | ||
let out = '' | ||
let first = true | ||
for (const arg of args) { | ||
if (first) first = false | ||
else out += ' ' | ||
out += typeof arg === 'string' ? arg : inspect(arg, opts) | ||
} | ||
return out | ||
} |
{ | ||
"name": "bare-console", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Simple debugging console for JavaScript", | ||
@@ -24,4 +24,4 @@ "main": "index.js", | ||
"bare-events": "^2.2.0", | ||
"bare-hrtime": "^2.0.0", | ||
"bare-inspect": "^3.0.0" | ||
"bare-format": "^1.0.0", | ||
"bare-hrtime": "^2.0.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
14428
56
+ Addedbare-format@^1.0.0
+ Addedbare-format@1.0.1(transitive)
- Removedbare-inspect@^3.0.0