bare-console 3.1.0 → 3.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 +20 -30
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -18,31 +18,11 @@ module.exports = class Console {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
log (...args) {
|
|
21
|
-
|
|
22
|
-
let first = true
|
|
23
|
-
|
|
24
|
-
for (const arg of args) {
|
|
25
|
-
if (first) first = false
|
|
26
|
-
else out += ' '
|
|
27
|
-
|
|
28
|
-
out += typeof arg === 'string' ? arg : inspect(arg, { colors: this._colors })
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this._stdout.write(out + '\n')
|
|
21
|
+
this._stdout.write(formatArgs(args) + '\n')
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
error (...args) {
|
|
35
|
-
|
|
36
|
-
let first = true
|
|
37
|
-
|
|
38
|
-
for (const arg of args) {
|
|
39
|
-
if (first) first = false
|
|
40
|
-
else out += ' '
|
|
41
|
-
|
|
42
|
-
out += typeof arg === 'string' ? arg : inspect(arg, { colors: this._colors })
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this._stderr.write(out + '\n')
|
|
25
|
+
this._stderr.write(formatArgs(args) + '\n')
|
|
46
26
|
}
|
|
47
27
|
|
|
48
28
|
time (label = 'default') {
|
|
@@ -70,17 +50,27 @@ module.exports = class Console {
|
|
|
70
50
|
else this.log(label + ': ' + ms.toFixed(3) + 'ms')
|
|
71
51
|
}
|
|
72
52
|
|
|
73
|
-
trace (...
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const second = stack.indexOf('\n', first + 1)
|
|
78
|
-
const start = second > -1 ? second : 0
|
|
79
|
-
|
|
80
|
-
this.error('Trace: ' + messages.join(' ') + stack.slice(start))
|
|
53
|
+
trace (...args) {
|
|
54
|
+
const err = { name: 'Trace', message: formatArgs(args) }
|
|
55
|
+
Error.captureStackTrace(err, this.trace)
|
|
56
|
+
this.error(err.stack)
|
|
81
57
|
}
|
|
82
58
|
}
|
|
83
59
|
|
|
84
60
|
function adaptStream (stream) {
|
|
85
61
|
return typeof stream === 'function' ? { write: stream } : stream
|
|
86
62
|
}
|
|
63
|
+
|
|
64
|
+
function formatArgs (args) {
|
|
65
|
+
let out = ''
|
|
66
|
+
let first = true
|
|
67
|
+
|
|
68
|
+
for (const arg of args) {
|
|
69
|
+
if (first) first = false
|
|
70
|
+
else out += ' '
|
|
71
|
+
|
|
72
|
+
out += typeof arg === 'string' ? arg : inspect(arg, { colors: this._colors })
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return out
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-console",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Simple debugging console for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/holepunchto/bare-console#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"bare-inspect": "^1.
|
|
23
|
+
"bare-inspect": "^1.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"brittle": "^3.1.1",
|