bare-console 3.1.1 → 4.0.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.
Files changed (2) hide show
  1. package/index.js +8 -7
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const inspect = require('bare-inspect')
2
+ const hrtime = require('bare-hrtime')
2
3
 
3
4
  module.exports = class Console {
4
5
  constructor (opts = {}) {
@@ -18,11 +19,11 @@ module.exports = class Console {
18
19
  }
19
20
 
20
21
  log (...args) {
21
- this._stdout.write(formatArgs(args) + '\n')
22
+ this._stdout.write(formatArgs(args, { colors: this._colors }) + '\n')
22
23
  }
23
24
 
24
25
  error (...args) {
25
- this._stderr.write(formatArgs(args) + '\n')
26
+ this._stderr.write(formatArgs(args, { colors: this._colors }) + '\n')
26
27
  }
27
28
 
28
29
  time (label = 'default') {
@@ -31,7 +32,7 @@ module.exports = class Console {
31
32
  return
32
33
  }
33
34
 
34
- this._timers.set(label, process.hrtime())
35
+ this._timers.set(label, hrtime())
35
36
  }
36
37
 
37
38
  timeEnd (label = 'default') {
@@ -42,7 +43,7 @@ module.exports = class Console {
42
43
  return
43
44
  }
44
45
 
45
- const d = process.hrtime(started)
46
+ const d = hrtime(started)
46
47
  const ms = d[0] * 1e3 + d[1] / 1e6
47
48
  this._timers.delete(label)
48
49
 
@@ -51,7 +52,7 @@ module.exports = class Console {
51
52
  }
52
53
 
53
54
  trace (...args) {
54
- const err = { name: 'Trace', message: formatArgs(args) }
55
+ const err = { name: 'Trace', message: formatArgs(args, { colors: this._colors }) }
55
56
  Error.captureStackTrace(err, this.trace)
56
57
  this.error(err.stack)
57
58
  }
@@ -61,7 +62,7 @@ function adaptStream (stream) {
61
62
  return typeof stream === 'function' ? { write: stream } : stream
62
63
  }
63
64
 
64
- function formatArgs (args) {
65
+ function formatArgs (args, opts) {
65
66
  let out = ''
66
67
  let first = true
67
68
 
@@ -69,7 +70,7 @@ function formatArgs (args) {
69
70
  if (first) first = false
70
71
  else out += ' '
71
72
 
72
- out += typeof arg === 'string' ? arg : inspect(arg, { colors: this._colors })
73
+ out += typeof arg === 'string' ? arg : inspect(arg, opts)
73
74
  }
74
75
 
75
76
  return out
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-console",
3
- "version": "3.1.1",
3
+ "version": "4.0.1",
4
4
  "description": "Simple debugging console for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/holepunchto/bare-console.git"
14
+ "url": "git+https://github.com/holepunchto/bare-console.git"
15
15
  },
16
16
  "author": "Holepunch",
17
17
  "license": "Apache-2.0",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "homepage": "https://github.com/holepunchto/bare-console#readme",
22
22
  "dependencies": {
23
+ "bare-hrtime": "^2.0.0",
23
24
  "bare-inspect": "^1.1.0"
24
25
  },
25
26
  "devDependencies": {