bare-console 5.0.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +14 -19
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { formatWithOptions } = require('bare-format')
|
|
2
2
|
const hrtime = require('bare-hrtime')
|
|
3
3
|
|
|
4
4
|
module.exports = class Console {
|
|
@@ -11,6 +11,7 @@ module.exports = class Console {
|
|
|
11
11
|
|
|
12
12
|
if (opts.bind) {
|
|
13
13
|
this.log = this.log.bind(this)
|
|
14
|
+
this.warn = this.warn.bind(this)
|
|
14
15
|
this.error = this.error.bind(this)
|
|
15
16
|
this.time = this.time.bind(this)
|
|
16
17
|
this.timeEnd = this.timeEnd.bind(this)
|
|
@@ -19,11 +20,15 @@ module.exports = class Console {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
log (...args) {
|
|
22
|
-
this._stdout.write(
|
|
23
|
+
this._stdout.write(formatWithOptions({ colors: this._colors }, ...args) + '\n')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
warn (...args) {
|
|
27
|
+
this._stderr.write(formatWithOptions({ colors: this._colors }, ...args) + '\n')
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
error (...args) {
|
|
26
|
-
this._stderr.write(
|
|
31
|
+
this._stderr.write(formatWithOptions({ colors: this._colors }, ...args) + '\n')
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
time (label = 'default') {
|
|
@@ -52,8 +57,12 @@ module.exports = class Console {
|
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
trace (...args) {
|
|
55
|
-
const err = { name: 'Trace', message:
|
|
56
|
-
|
|
60
|
+
const err = { name: 'Trace', message: formatWithOptions({ colors: this._colors }, ...args) }
|
|
61
|
+
|
|
62
|
+
if (Error.captureStackTrace) {
|
|
63
|
+
Error.captureStackTrace(err, this.trace)
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
this.error(err.stack)
|
|
58
67
|
}
|
|
59
68
|
}
|
|
@@ -61,17 +70,3 @@ module.exports = class Console {
|
|
|
61
70
|
function adaptStream (stream) {
|
|
62
71
|
return typeof stream === 'function' ? { write: stream } : stream
|
|
63
72
|
}
|
|
64
|
-
|
|
65
|
-
function formatArgs (args, opts) {
|
|
66
|
-
let out = ''
|
|
67
|
-
let first = true
|
|
68
|
-
|
|
69
|
-
for (const arg of args) {
|
|
70
|
-
if (first) first = false
|
|
71
|
-
else out += ' '
|
|
72
|
-
|
|
73
|
-
out += typeof arg === 'string' ? arg : inspect(arg, opts)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return out
|
|
77
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-console",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "Simple debugging console for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"homepage": "https://github.com/holepunchto/bare-console#readme",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"bare-events": "^2.2.0",
|
|
24
|
-
"bare-
|
|
25
|
-
"bare-
|
|
24
|
+
"bare-format": "^1.0.0",
|
|
25
|
+
"bare-hrtime": "^2.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"bare-stream": "^
|
|
28
|
+
"bare-stream": "^2.0.0",
|
|
29
29
|
"brittle": "^3.1.1",
|
|
30
30
|
"standard": "^17.0.0"
|
|
31
31
|
}
|