pnpm 6.22.1 → 6.23.2

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 (113) hide show
  1. package/dist/node_modules/ansi-regex/index.js +8 -2
  2. package/dist/node_modules/ansi-regex/license +4 -16
  3. package/dist/node_modules/ansi-regex/package.json +53 -62
  4. package/dist/node_modules/aproba/index.js +33 -33
  5. package/dist/node_modules/aproba/package.json +5 -4
  6. package/dist/node_modules/are-we-there-yet/{index.js → lib/index.js} +0 -0
  7. package/dist/node_modules/are-we-there-yet/{tracker-base.js → lib/tracker-base.js} +0 -0
  8. package/dist/node_modules/are-we-there-yet/{tracker-group.js → lib/tracker-group.js} +14 -5
  9. package/dist/node_modules/are-we-there-yet/{tracker-stream.js → lib/tracker-stream.js} +0 -0
  10. package/dist/node_modules/are-we-there-yet/{tracker.js → lib/tracker.js} +3 -1
  11. package/dist/node_modules/are-we-there-yet/package.json +35 -17
  12. package/dist/node_modules/{npmlog → color-support}/LICENSE +0 -0
  13. package/dist/node_modules/color-support/bin.js +3 -0
  14. package/dist/node_modules/color-support/browser.js +14 -0
  15. package/dist/node_modules/color-support/index.js +134 -0
  16. package/dist/node_modules/color-support/package.json +36 -0
  17. package/dist/node_modules/gauge/{base-theme.js → lib/base-theme.js} +7 -3
  18. package/dist/node_modules/gauge/lib/demo.js +45 -0
  19. package/dist/node_modules/gauge/{error.js → lib/error.js} +0 -0
  20. package/dist/node_modules/gauge/lib/has-color.js +4 -0
  21. package/dist/node_modules/gauge/{index.js → lib/index.js} +90 -33
  22. package/dist/node_modules/gauge/{plumbing.js → lib/plumbing.js} +3 -1
  23. package/dist/node_modules/gauge/{process.js → lib/process.js} +0 -0
  24. package/dist/node_modules/gauge/{progress-bar.js → lib/progress-bar.js} +12 -6
  25. package/dist/node_modules/gauge/{render-template.js → lib/render-template.js} +69 -28
  26. package/dist/node_modules/gauge/{set-immediate.js → lib/set-immediate.js} +0 -0
  27. package/dist/node_modules/gauge/{set-interval.js → lib/set-interval.js} +0 -0
  28. package/dist/node_modules/gauge/{spin.js → lib/spin.js} +0 -0
  29. package/dist/node_modules/gauge/{template-item.js → lib/template-item.js} +21 -7
  30. package/dist/node_modules/gauge/{theme-set.js → lib/theme-set.js} +31 -24
  31. package/dist/node_modules/gauge/lib/themes.js +56 -0
  32. package/dist/node_modules/gauge/{wide-truncate.js → lib/wide-truncate.js} +9 -3
  33. package/dist/node_modules/gauge/package.json +39 -40
  34. package/dist/node_modules/is-fullwidth-code-point/index.js +40 -36
  35. package/dist/node_modules/is-fullwidth-code-point/license +4 -16
  36. package/dist/node_modules/is-fullwidth-code-point/package.json +40 -43
  37. package/dist/node_modules/node-gyp/package.json +2 -2
  38. package/dist/node_modules/npmlog/{log.js → lib/log.js} +148 -54
  39. package/dist/node_modules/npmlog/package.json +30 -12
  40. package/dist/node_modules/readable-stream/errors-browser.js +127 -0
  41. package/dist/node_modules/readable-stream/errors.js +116 -0
  42. package/dist/node_modules/readable-stream/experimentalWarning.js +17 -0
  43. package/dist/node_modules/readable-stream/lib/_stream_duplex.js +52 -44
  44. package/dist/node_modules/readable-stream/lib/_stream_passthrough.js +1 -9
  45. package/dist/node_modules/readable-stream/lib/_stream_readable.js +446 -341
  46. package/dist/node_modules/readable-stream/lib/_stream_transform.js +29 -42
  47. package/dist/node_modules/readable-stream/lib/_stream_writable.js +200 -190
  48. package/dist/node_modules/readable-stream/lib/internal/streams/async_iterator.js +207 -0
  49. package/dist/node_modules/readable-stream/lib/internal/streams/buffer_list.js +210 -0
  50. package/dist/node_modules/readable-stream/lib/internal/streams/destroy.js +48 -17
  51. package/dist/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +104 -0
  52. package/dist/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  53. package/dist/node_modules/readable-stream/lib/internal/streams/from.js +64 -0
  54. package/dist/node_modules/readable-stream/lib/internal/streams/pipeline.js +97 -0
  55. package/dist/node_modules/readable-stream/lib/internal/streams/state.js +27 -0
  56. package/dist/node_modules/readable-stream/package.json +35 -19
  57. package/dist/node_modules/readable-stream/readable-browser.js +2 -0
  58. package/dist/node_modules/readable-stream/readable.js +5 -8
  59. package/dist/node_modules/safe-buffer/index.js +3 -0
  60. package/dist/node_modules/safe-buffer/package.json +18 -4
  61. package/dist/node_modules/signal-exit/index.js +30 -8
  62. package/dist/node_modules/signal-exit/package.json +7 -5
  63. package/dist/node_modules/socks-proxy-agent/package.json +2 -2
  64. package/dist/node_modules/string-width/index.js +29 -19
  65. package/dist/node_modules/string-width/license +4 -16
  66. package/dist/node_modules/string-width/package.json +54 -54
  67. package/dist/node_modules/string_decoder/package.json +5 -2
  68. package/dist/node_modules/strip-ansi/index.js +2 -4
  69. package/dist/node_modules/strip-ansi/license +4 -16
  70. package/dist/node_modules/strip-ansi/package.json +52 -55
  71. package/dist/pnpm.cjs +746 -667
  72. package/package.json +18 -18
  73. package/dist/node_modules/are-we-there-yet/LICENSE +0 -5
  74. package/dist/node_modules/code-point-at/index.js +0 -32
  75. package/dist/node_modules/code-point-at/license +0 -21
  76. package/dist/node_modules/code-point-at/package.json +0 -38
  77. package/dist/node_modules/core-util-is/LICENSE +0 -19
  78. package/dist/node_modules/core-util-is/lib/util.js +0 -107
  79. package/dist/node_modules/core-util-is/package.json +0 -38
  80. package/dist/node_modules/gauge/LICENSE +0 -13
  81. package/dist/node_modules/gauge/has-color.js +0 -12
  82. package/dist/node_modules/gauge/themes.js +0 -54
  83. package/dist/node_modules/isarray/component.json +0 -19
  84. package/dist/node_modules/isarray/index.js +0 -5
  85. package/dist/node_modules/isarray/package.json +0 -45
  86. package/dist/node_modules/isarray/test.js +0 -20
  87. package/dist/node_modules/number-is-nan/index.js +0 -4
  88. package/dist/node_modules/number-is-nan/license +0 -21
  89. package/dist/node_modules/number-is-nan/package.json +0 -35
  90. package/dist/node_modules/object-assign/index.js +0 -90
  91. package/dist/node_modules/object-assign/license +0 -21
  92. package/dist/node_modules/object-assign/package.json +0 -42
  93. package/dist/node_modules/process-nextick-args/index.js +0 -45
  94. package/dist/node_modules/process-nextick-args/package.json +0 -25
  95. package/dist/node_modules/readable-stream/duplex-browser.js +0 -1
  96. package/dist/node_modules/readable-stream/duplex.js +0 -1
  97. package/dist/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
  98. package/dist/node_modules/readable-stream/passthrough.js +0 -1
  99. package/dist/node_modules/readable-stream/transform.js +0 -1
  100. package/dist/node_modules/readable-stream/writable-browser.js +0 -1
  101. package/dist/node_modules/readable-stream/writable.js +0 -8
  102. package/dist/node_modules/wide-align/node_modules/ansi-regex/index.js +0 -10
  103. package/dist/node_modules/wide-align/node_modules/ansi-regex/license +0 -9
  104. package/dist/node_modules/wide-align/node_modules/ansi-regex/package.json +0 -55
  105. package/dist/node_modules/wide-align/node_modules/is-fullwidth-code-point/index.js +0 -50
  106. package/dist/node_modules/wide-align/node_modules/is-fullwidth-code-point/license +0 -9
  107. package/dist/node_modules/wide-align/node_modules/is-fullwidth-code-point/package.json +0 -42
  108. package/dist/node_modules/wide-align/node_modules/string-width/index.js +0 -47
  109. package/dist/node_modules/wide-align/node_modules/string-width/license +0 -9
  110. package/dist/node_modules/wide-align/node_modules/string-width/package.json +0 -56
  111. package/dist/node_modules/wide-align/node_modules/strip-ansi/index.js +0 -4
  112. package/dist/node_modules/wide-align/node_modules/strip-ansi/license +0 -9
  113. package/dist/node_modules/wide-align/node_modules/strip-ansi/package.json +0 -54
@@ -0,0 +1,45 @@
1
+ var Gauge = require('./')
2
+ var gaugeDefault = require('./themes.js')
3
+ var onExit = require('signal-exit')
4
+
5
+ var activeGauge
6
+
7
+ onExit(function () {
8
+ activeGauge.disable()
9
+ })
10
+
11
+ var themes = gaugeDefault.getThemeNames()
12
+
13
+ nextBar()
14
+ function nextBar () {
15
+ var themeName = themes.shift()
16
+
17
+ console.log('Demoing output for ' + themeName)
18
+
19
+ var gt = new Gauge(process.stderr, {
20
+ updateInterval: 50,
21
+ theme: themeName,
22
+ cleanupOnExit: false,
23
+ })
24
+ activeGauge = gt
25
+
26
+ var progress = 0
27
+
28
+ var cnt = 0
29
+ var pulse = setInterval(function () {
30
+ gt.pulse('this is a thing that happened ' + (++cnt))
31
+ }, 110)
32
+ var prog = setInterval(function () {
33
+ progress += 0.04
34
+ gt.show(themeName + ':' + Math.round(progress * 1000), progress)
35
+ if (progress >= 1) {
36
+ clearInterval(prog)
37
+ clearInterval(pulse)
38
+ gt.disable()
39
+ if (themes.length) {
40
+ nextBar()
41
+ }
42
+ }
43
+ }, 100)
44
+ gt.show()
45
+ }
@@ -0,0 +1,4 @@
1
+ 'use strict'
2
+ var colorSupport = require('color-support')
3
+
4
+ module.exports = colorSupport().hasBasic
@@ -32,7 +32,7 @@ function Gauge (arg1, arg2) {
32
32
  this._status = {
33
33
  spun: 0,
34
34
  section: '',
35
- subsection: ''
35
+ subsection: '',
36
36
  }
37
37
  this._paused = false // are we paused for back pressure?
38
38
  this._disabled = true // are all progress bar updates disabled?
@@ -50,10 +50,10 @@ function Gauge (arg1, arg2) {
50
50
  this._theme = options.theme
51
51
  var theme = this._computeTheme(options.theme)
52
52
  var template = options.template || [
53
- {type: 'progressbar', length: 20},
54
- {type: 'activityIndicator', kerning: 1, length: 1},
55
- {type: 'section', kerning: 1, default: ''},
56
- {type: 'subsection', kerning: 1, default: ''}
53
+ { type: 'progressbar', length: 20 },
54
+ { type: 'activityIndicator', kerning: 1, length: 1 },
55
+ { type: 'section', kerning: 1, default: '' },
56
+ { type: 'subsection', kerning: 1, default: '' },
57
57
  ]
58
58
  this.setWriteTo(writeTo, options.tty)
59
59
  var PlumbingClass = options.Plumbing || Plumbing
@@ -79,17 +79,28 @@ Gauge.prototype.isEnabled = function () {
79
79
 
80
80
  Gauge.prototype.setTemplate = function (template) {
81
81
  this._gauge.setTemplate(template)
82
- if (this._showing) this._requestRedraw()
82
+ if (this._showing) {
83
+ this._requestRedraw()
84
+ }
83
85
  }
84
86
 
85
87
  Gauge.prototype._computeTheme = function (theme) {
86
- if (!theme) theme = {}
88
+ if (!theme) {
89
+ theme = {}
90
+ }
87
91
  if (typeof theme === 'string') {
88
92
  theme = this._themes.getTheme(theme)
89
- } else if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)) {
93
+ } else if (
94
+ theme &&
95
+ (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)
96
+ ) {
90
97
  var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode
91
98
  var useColor = theme.hasColor == null ? hasColor : theme.hasColor
92
- theme = this._themes.getDefault({hasUnicode: useUnicode, hasColor: useColor, platform: theme.platform})
99
+ theme = this._themes.getDefault({
100
+ hasUnicode: useUnicode,
101
+ hasColor: useColor,
102
+ platform: theme.platform,
103
+ })
93
104
  }
94
105
  return theme
95
106
  }
@@ -101,13 +112,17 @@ Gauge.prototype.setThemeset = function (themes) {
101
112
 
102
113
  Gauge.prototype.setTheme = function (theme) {
103
114
  this._gauge.setTheme(this._computeTheme(theme))
104
- if (this._showing) this._requestRedraw()
115
+ if (this._showing) {
116
+ this._requestRedraw()
117
+ }
105
118
  this._theme = theme
106
119
  }
107
120
 
108
121
  Gauge.prototype._requestRedraw = function () {
109
122
  this._needsRedraw = true
110
- if (!this._fixedFramerate) this._doRedraw()
123
+ if (!this._fixedFramerate) {
124
+ this._doRedraw()
125
+ }
111
126
  }
112
127
 
113
128
  Gauge.prototype.getWidth = function () {
@@ -116,25 +131,39 @@ Gauge.prototype.getWidth = function () {
116
131
 
117
132
  Gauge.prototype.setWriteTo = function (writeTo, tty) {
118
133
  var enabled = !this._disabled
119
- if (enabled) this.disable()
134
+ if (enabled) {
135
+ this.disable()
136
+ }
120
137
  this._writeTo = writeTo
121
138
  this._tty = tty ||
122
139
  (writeTo === process.stderr && process.stdout.isTTY && process.stdout) ||
123
140
  (writeTo.isTTY && writeTo) ||
124
141
  this._tty
125
- if (this._gauge) this._gauge.setWidth(this.getWidth())
126
- if (enabled) this.enable()
142
+ if (this._gauge) {
143
+ this._gauge.setWidth(this.getWidth())
144
+ }
145
+ if (enabled) {
146
+ this.enable()
147
+ }
127
148
  }
128
149
 
129
150
  Gauge.prototype.enable = function () {
130
- if (!this._disabled) return
151
+ if (!this._disabled) {
152
+ return
153
+ }
131
154
  this._disabled = false
132
- if (this._tty) this._enableEvents()
133
- if (this._showing) this.show()
155
+ if (this._tty) {
156
+ this._enableEvents()
157
+ }
158
+ if (this._showing) {
159
+ this.show()
160
+ }
134
161
  }
135
162
 
136
163
  Gauge.prototype.disable = function () {
137
- if (this._disabled) return
164
+ if (this._disabled) {
165
+ return
166
+ }
138
167
  if (this._showing) {
139
168
  this._lastUpdateAt = null
140
169
  this._showing = false
@@ -142,7 +171,9 @@ Gauge.prototype.disable = function () {
142
171
  this._showing = true
143
172
  }
144
173
  this._disabled = true
145
- if (this._tty) this._disableEvents()
174
+ if (this._tty) {
175
+ this._disableEvents()
176
+ }
146
177
  }
147
178
 
148
179
  Gauge.prototype._enableEvents = function () {
@@ -152,19 +183,29 @@ Gauge.prototype._enableEvents = function () {
152
183
  this._tty.on('resize', this._$$handleSizeChange)
153
184
  if (this._fixedFramerate) {
154
185
  this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval)
155
- if (this.redrawTracker.unref) this.redrawTracker.unref()
186
+ if (this.redrawTracker.unref) {
187
+ this.redrawTracker.unref()
188
+ }
156
189
  }
157
190
  }
158
191
 
159
192
  Gauge.prototype._disableEvents = function () {
160
193
  this._tty.removeListener('resize', this._$$handleSizeChange)
161
- if (this._fixedFramerate) clearInterval(this.redrawTracker)
162
- if (this._removeOnExit) this._removeOnExit()
194
+ if (this._fixedFramerate) {
195
+ clearInterval(this.redrawTracker)
196
+ }
197
+ if (this._removeOnExit) {
198
+ this._removeOnExit()
199
+ }
163
200
  }
164
201
 
165
202
  Gauge.prototype.hide = function (cb) {
166
- if (this._disabled) return cb && process.nextTick(cb)
167
- if (!this._showing) return cb && process.nextTick(cb)
203
+ if (this._disabled) {
204
+ return cb && process.nextTick(cb)
205
+ }
206
+ if (!this._showing) {
207
+ return cb && process.nextTick(cb)
208
+ }
168
209
  this._showing = false
169
210
  this._doRedraw()
170
211
  cb && setImmediate(cb)
@@ -181,16 +222,24 @@ Gauge.prototype.show = function (section, completed) {
181
222
  this._status[key] = section[key]
182
223
  }
183
224
  }
184
- if (completed != null) this._status.completed = completed
185
- if (this._disabled) return
225
+ if (completed != null) {
226
+ this._status.completed = completed
227
+ }
228
+ if (this._disabled) {
229
+ return
230
+ }
186
231
  this._requestRedraw()
187
232
  }
188
233
 
189
234
  Gauge.prototype.pulse = function (subsection) {
190
235
  this._status.subsection = subsection || ''
191
- this._status.spun ++
192
- if (this._disabled) return
193
- if (!this._showing) return
236
+ this._status.spun++
237
+ if (this._disabled) {
238
+ return
239
+ }
240
+ if (!this._showing) {
241
+ return
242
+ }
194
243
  this._requestRedraw()
195
244
  }
196
245
 
@@ -200,10 +249,14 @@ Gauge.prototype._handleSizeChange = function () {
200
249
  }
201
250
 
202
251
  Gauge.prototype._doRedraw = function () {
203
- if (this._disabled || this._paused) return
252
+ if (this._disabled || this._paused) {
253
+ return
254
+ }
204
255
  if (!this._fixedFramerate) {
205
256
  var now = Date.now()
206
- if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) return
257
+ if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) {
258
+ return
259
+ }
207
260
  this._lastUpdateAt = now
208
261
  }
209
262
  if (!this._showing && this._onScreen) {
@@ -214,7 +267,9 @@ Gauge.prototype._doRedraw = function () {
214
267
  }
215
268
  return this._writeTo.write(result)
216
269
  }
217
- if (!this._showing && !this._onScreen) return
270
+ if (!this._showing && !this._onScreen) {
271
+ return
272
+ }
218
273
  if (this._showing && !this._onScreen) {
219
274
  this._onScreen = true
220
275
  this._needsRedraw = true
@@ -222,7 +277,9 @@ Gauge.prototype._doRedraw = function () {
222
277
  this._writeTo.write(this._gauge.hideCursor())
223
278
  }
224
279
  }
225
- if (!this._needsRedraw) return
280
+ if (!this._needsRedraw) {
281
+ return
282
+ }
226
283
  if (!this._writeTo.write(this._gauge.show(this._status))) {
227
284
  this._paused = true
228
285
  this._writeTo.on('drain', callWith(this, function () {
@@ -4,7 +4,9 @@ var renderTemplate = require('./render-template.js')
4
4
  var validate = require('aproba')
5
5
 
6
6
  var Plumbing = module.exports = function (theme, template, width) {
7
- if (!width) width = 80
7
+ if (!width) {
8
+ width = 80
9
+ }
8
10
  validate('OAN', [theme, template, width])
9
11
  this.showing = false
10
12
  this.theme = theme
@@ -6,14 +6,20 @@ var stringWidth = require('string-width')
6
6
 
7
7
  module.exports = function (theme, width, completed) {
8
8
  validate('ONN', [theme, width, completed])
9
- if (completed < 0) completed = 0
10
- if (completed > 1) completed = 1
11
- if (width <= 0) return ''
9
+ if (completed < 0) {
10
+ completed = 0
11
+ }
12
+ if (completed > 1) {
13
+ completed = 1
14
+ }
15
+ if (width <= 0) {
16
+ return ''
17
+ }
12
18
  var sofar = Math.round(width * completed)
13
19
  var rest = width - sofar
14
20
  var template = [
15
- {type: 'complete', value: repeat(theme.complete, sofar), length: sofar},
16
- {type: 'remaining', value: repeat(theme.remaining, rest), length: rest}
21
+ { type: 'complete', value: repeat(theme.complete, sofar), length: sofar },
22
+ { type: 'remaining', value: repeat(theme.remaining, rest), length: rest },
17
23
  ]
18
24
  return renderTemplate(width, template, theme)
19
25
  }
@@ -27,7 +33,7 @@ function repeat (string, width) {
27
33
  result += string
28
34
  }
29
35
  n = Math.floor(n / 2)
30
- /*eslint no-self-assign: 0*/
36
+ /* eslint no-self-assign: 0 */
31
37
  string += string
32
38
  } while (n && stringWidth(result) < width)
33
39
 
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
  var align = require('wide-align')
3
3
  var validate = require('aproba')
4
- var objectAssign = require('object-assign')
5
4
  var wideTruncate = require('./wide-truncate')
6
5
  var error = require('./error')
7
6
  var TemplateItem = require('./template-item')
@@ -29,18 +28,20 @@ function postType (item) {
29
28
  }
30
29
 
31
30
  function hasPreOrPost (item, values) {
32
- if (!item.type) return
31
+ if (!item.type) {
32
+ return
33
+ }
33
34
  return values[preType(item)] || values[postType(item)]
34
35
  }
35
36
 
36
37
  function generatePreAndPost (baseItem, parentValues) {
37
- var item = objectAssign({}, baseItem)
38
+ var item = Object.assign({}, baseItem)
38
39
  var values = Object.create(parentValues)
39
40
  var template = []
40
41
  var pre = preType(item)
41
42
  var post = postType(item)
42
43
  if (values[pre]) {
43
- template.push({value: values[pre]})
44
+ template.push({ value: values[pre] })
44
45
  values[pre] = null
45
46
  }
46
47
  item.minLength = null
@@ -49,7 +50,7 @@ function generatePreAndPost (baseItem, parentValues) {
49
50
  template.push(item)
50
51
  values[item.type] = values[item.type]
51
52
  if (values[post]) {
52
- template.push({value: values[post]})
53
+ template.push({ value: values[post] })
53
54
  values[post] = null
54
55
  }
55
56
  return function ($1, $2, length) {
@@ -72,49 +73,73 @@ function prepareItems (width, template, values) {
72
73
  cloned.value = values[type]
73
74
  }
74
75
  }
75
- if (cloned.value == null || cloned.value === '') return null
76
+ if (cloned.value == null || cloned.value === '') {
77
+ return null
78
+ }
76
79
  cloned.index = index
77
80
  cloned.first = index === 0
78
81
  cloned.last = index === arr.length - 1
79
- if (hasPreOrPost(cloned, values)) cloned.value = generatePreAndPost(cloned, values)
82
+ if (hasPreOrPost(cloned, values)) {
83
+ cloned.value = generatePreAndPost(cloned, values)
84
+ }
80
85
  return cloned
81
86
  }
82
87
 
83
- var output = template.map(cloneAndObjectify).filter(function (item) { return item != null })
88
+ var output = template.map(cloneAndObjectify).filter(function (item) {
89
+ return item != null
90
+ })
84
91
 
85
- var outputLength = 0
86
92
  var remainingSpace = width
87
93
  var variableCount = output.length
88
94
 
89
95
  function consumeSpace (length) {
90
- if (length > remainingSpace) length = remainingSpace
91
- outputLength += length
96
+ if (length > remainingSpace) {
97
+ length = remainingSpace
98
+ }
92
99
  remainingSpace -= length
93
100
  }
94
101
 
95
102
  function finishSizing (item, length) {
96
- if (item.finished) throw new error.Internal('Tried to finish template item that was already finished')
97
- if (length === Infinity) throw new error.Internal('Length of template item cannot be infinity')
98
- if (length != null) item.length = length
103
+ if (item.finished) {
104
+ throw new error.Internal('Tried to finish template item that was already finished')
105
+ }
106
+ if (length === Infinity) {
107
+ throw new error.Internal('Length of template item cannot be infinity')
108
+ }
109
+ if (length != null) {
110
+ item.length = length
111
+ }
99
112
  item.minLength = null
100
113
  item.maxLength = null
101
114
  --variableCount
102
115
  item.finished = true
103
- if (item.length == null) item.length = item.getBaseLength()
104
- if (item.length == null) throw new error.Internal('Finished template items must have a length')
116
+ if (item.length == null) {
117
+ item.length = item.getBaseLength()
118
+ }
119
+ if (item.length == null) {
120
+ throw new error.Internal('Finished template items must have a length')
121
+ }
105
122
  consumeSpace(item.getLength())
106
123
  }
107
124
 
108
125
  output.forEach(function (item) {
109
- if (!item.kerning) return
126
+ if (!item.kerning) {
127
+ return
128
+ }
110
129
  var prevPadRight = item.first ? 0 : output[item.index - 1].padRight
111
- if (!item.first && prevPadRight < item.kerning) item.padLeft = item.kerning - prevPadRight
112
- if (!item.last) item.padRight = item.kerning
130
+ if (!item.first && prevPadRight < item.kerning) {
131
+ item.padLeft = item.kerning - prevPadRight
132
+ }
133
+ if (!item.last) {
134
+ item.padRight = item.kerning
135
+ }
113
136
  })
114
137
 
115
138
  // Finish any that have a fixed (literal or intuited) length
116
139
  output.forEach(function (item) {
117
- if (item.getBaseLength() == null) return
140
+ if (item.getBaseLength() == null) {
141
+ return
142
+ }
118
143
  finishSizing(item)
119
144
  })
120
145
 
@@ -125,34 +150,48 @@ function prepareItems (width, template, values) {
125
150
  resizing = false
126
151
  hunkSize = Math.round(remainingSpace / variableCount)
127
152
  output.forEach(function (item) {
128
- if (item.finished) return
129
- if (!item.maxLength) return
153
+ if (item.finished) {
154
+ return
155
+ }
156
+ if (!item.maxLength) {
157
+ return
158
+ }
130
159
  if (item.getMaxLength() < hunkSize) {
131
160
  finishSizing(item, item.maxLength)
132
161
  resizing = true
133
162
  }
134
163
  })
135
164
  } while (resizing && resized++ < output.length)
136
- if (resizing) throw new error.Internal('Resize loop iterated too many times while determining maxLength')
165
+ if (resizing) {
166
+ throw new error.Internal('Resize loop iterated too many times while determining maxLength')
167
+ }
137
168
 
138
169
  resized = 0
139
170
  do {
140
171
  resizing = false
141
172
  hunkSize = Math.round(remainingSpace / variableCount)
142
173
  output.forEach(function (item) {
143
- if (item.finished) return
144
- if (!item.minLength) return
174
+ if (item.finished) {
175
+ return
176
+ }
177
+ if (!item.minLength) {
178
+ return
179
+ }
145
180
  if (item.getMinLength() >= hunkSize) {
146
181
  finishSizing(item, item.minLength)
147
182
  resizing = true
148
183
  }
149
184
  })
150
185
  } while (resizing && resized++ < output.length)
151
- if (resizing) throw new error.Internal('Resize loop iterated too many times while determining minLength')
186
+ if (resizing) {
187
+ throw new error.Internal('Resize loop iterated too many times while determining minLength')
188
+ }
152
189
 
153
190
  hunkSize = Math.round(remainingSpace / variableCount)
154
191
  output.forEach(function (item) {
155
- if (item.finished) return
192
+ if (item.finished) {
193
+ return
194
+ }
156
195
  finishSizing(item, hunkSize)
157
196
  })
158
197
 
@@ -171,7 +210,9 @@ function renderFunction (item, values, length) {
171
210
  function renderValue (item, values) {
172
211
  var length = item.getBaseLength()
173
212
  var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value
174
- if (value == null || value === '') return ''
213
+ if (value == null || value === '') {
214
+ return ''
215
+ }
175
216
  var alignWith = align[item.align] || align.left
176
217
  var leftPadding = item.padLeft ? align.left('', item.padLeft) : ''
177
218
  var rightPadding = item.padRight ? align.right('', item.padRight) : ''
File without changes
@@ -4,7 +4,9 @@ var stringWidth = require('string-width')
4
4
  module.exports = TemplateItem
5
5
 
6
6
  function isPercent (num) {
7
- if (typeof num !== 'string') return false
7
+ if (typeof num !== 'string') {
8
+ return false
9
+ }
8
10
  return num.slice(-1) === '%'
9
11
  }
10
12
 
@@ -30,7 +32,9 @@ function TemplateItem (values, outputLength) {
30
32
  if (typeof values === 'string') {
31
33
  this.value = values
32
34
  } else {
33
- for (var prop in values) this[prop] = values[prop]
35
+ for (var prop in values) {
36
+ this[prop] = values[prop]
37
+ }
34
38
  }
35
39
  // Realize percents
36
40
  if (isPercent(this.length)) {
@@ -49,7 +53,12 @@ TemplateItem.prototype = {}
49
53
 
50
54
  TemplateItem.prototype.getBaseLength = function () {
51
55
  var length = this.length
52
- if (length == null && typeof this.value === 'string' && this.maxLength == null && this.minLength == null) {
56
+ if (
57
+ length == null &&
58
+ typeof this.value === 'string' &&
59
+ this.maxLength == null &&
60
+ this.minLength == null
61
+ ) {
53
62
  length = stringWidth(this.value)
54
63
  }
55
64
  return length
@@ -57,17 +66,22 @@ TemplateItem.prototype.getBaseLength = function () {
57
66
 
58
67
  TemplateItem.prototype.getLength = function () {
59
68
  var length = this.getBaseLength()
60
- if (length == null) return null
69
+ if (length == null) {
70
+ return null
71
+ }
61
72
  return length + this.padLeft + this.padRight
62
73
  }
63
74
 
64
75
  TemplateItem.prototype.getMaxLength = function () {
65
- if (this.maxLength == null) return null
76
+ if (this.maxLength == null) {
77
+ return null
78
+ }
66
79
  return this.maxLength + this.padLeft + this.padRight
67
80
  }
68
81
 
69
82
  TemplateItem.prototype.getMinLength = function () {
70
- if (this.minLength == null) return null
83
+ if (this.minLength == null) {
84
+ return null
85
+ }
71
86
  return this.minLength + this.padLeft + this.padRight
72
87
  }
73
-