Initial commit
This commit is contained in:
13
node_modules/gauge/LICENSE
generated
vendored
Normal file
13
node_modules/gauge/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright (c) 2014, Rebecca Turner <me@re-becca.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
14
node_modules/gauge/base-theme.js
generated
vendored
Normal file
14
node_modules/gauge/base-theme.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict'
|
||||
var spin = require('./spin.js')
|
||||
var progressBar = require('./progress-bar.js')
|
||||
|
||||
module.exports = {
|
||||
activityIndicator: function (values, theme, width) {
|
||||
if (values.spun == null) return
|
||||
return spin(theme, values.spun)
|
||||
},
|
||||
progressbar: function (values, theme, width) {
|
||||
if (values.completed == null) return
|
||||
return progressBar(theme, width, values.completed)
|
||||
}
|
||||
}
|
||||
24
node_modules/gauge/error.js
generated
vendored
Normal file
24
node_modules/gauge/error.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
var util = require('util')
|
||||
|
||||
var User = exports.User = function User (msg) {
|
||||
var err = new Error(msg)
|
||||
Error.captureStackTrace(err, User)
|
||||
err.code = 'EGAUGE'
|
||||
return err
|
||||
}
|
||||
|
||||
exports.MissingTemplateValue = function MissingTemplateValue (item, values) {
|
||||
var err = new User(util.format('Missing template value "%s"', item.type))
|
||||
Error.captureStackTrace(err, MissingTemplateValue)
|
||||
err.template = item
|
||||
err.values = values
|
||||
return err
|
||||
}
|
||||
|
||||
exports.Internal = function Internal (msg) {
|
||||
var err = new Error(msg)
|
||||
Error.captureStackTrace(err, Internal)
|
||||
err.code = 'EGAUGEINTERNAL'
|
||||
return err
|
||||
}
|
||||
12
node_modules/gauge/has-color.js
generated
vendored
Normal file
12
node_modules/gauge/has-color.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = isWin32() || isColorTerm()
|
||||
|
||||
function isWin32 () {
|
||||
return process.platform === 'win32'
|
||||
}
|
||||
|
||||
function isColorTerm () {
|
||||
var termHasColor = /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i
|
||||
return !!process.env.COLORTERM || termHasColor.test(process.env.TERM)
|
||||
}
|
||||
233
node_modules/gauge/index.js
generated
vendored
Normal file
233
node_modules/gauge/index.js
generated
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
'use strict'
|
||||
var Plumbing = require('./plumbing.js')
|
||||
var hasUnicode = require('has-unicode')
|
||||
var hasColor = require('./has-color.js')
|
||||
var onExit = require('signal-exit')
|
||||
var defaultThemes = require('./themes')
|
||||
var setInterval = require('./set-interval.js')
|
||||
var process = require('./process.js')
|
||||
var setImmediate = require('./set-immediate')
|
||||
|
||||
module.exports = Gauge
|
||||
|
||||
function callWith (obj, method) {
|
||||
return function () {
|
||||
return method.call(obj)
|
||||
}
|
||||
}
|
||||
|
||||
function Gauge (arg1, arg2) {
|
||||
var options, writeTo
|
||||
if (arg1 && arg1.write) {
|
||||
writeTo = arg1
|
||||
options = arg2 || {}
|
||||
} else if (arg2 && arg2.write) {
|
||||
writeTo = arg2
|
||||
options = arg1 || {}
|
||||
} else {
|
||||
writeTo = process.stderr
|
||||
options = arg1 || arg2 || {}
|
||||
}
|
||||
|
||||
this._status = {
|
||||
spun: 0,
|
||||
section: '',
|
||||
subsection: ''
|
||||
}
|
||||
this._paused = false // are we paused for back pressure?
|
||||
this._disabled = true // are all progress bar updates disabled?
|
||||
this._showing = false // do we WANT the progress bar on screen
|
||||
this._onScreen = false // IS the progress bar on screen
|
||||
this._needsRedraw = false // should we print something at next tick?
|
||||
this._hideCursor = options.hideCursor == null ? true : options.hideCursor
|
||||
this._fixedFramerate = options.fixedFramerate == null
|
||||
? !(/^v0\.8\./.test(process.version))
|
||||
: options.fixedFramerate
|
||||
this._lastUpdateAt = null
|
||||
this._updateInterval = options.updateInterval == null ? 50 : options.updateInterval
|
||||
|
||||
this._themes = options.themes || defaultThemes
|
||||
this._theme = options.theme
|
||||
var theme = this._computeTheme(options.theme)
|
||||
var template = options.template || [
|
||||
{type: 'progressbar', length: 20},
|
||||
{type: 'activityIndicator', kerning: 1, length: 1},
|
||||
{type: 'section', kerning: 1, default: ''},
|
||||
{type: 'subsection', kerning: 1, default: ''}
|
||||
]
|
||||
this.setWriteTo(writeTo, options.tty)
|
||||
var PlumbingClass = options.Plumbing || Plumbing
|
||||
this._gauge = new PlumbingClass(theme, template, this.getWidth())
|
||||
|
||||
this._$$doRedraw = callWith(this, this._doRedraw)
|
||||
this._$$handleSizeChange = callWith(this, this._handleSizeChange)
|
||||
|
||||
this._cleanupOnExit = options.cleanupOnExit == null || options.cleanupOnExit
|
||||
this._removeOnExit = null
|
||||
|
||||
if (options.enabled || (options.enabled == null && this._tty && this._tty.isTTY)) {
|
||||
this.enable()
|
||||
} else {
|
||||
this.disable()
|
||||
}
|
||||
}
|
||||
Gauge.prototype = {}
|
||||
|
||||
Gauge.prototype.isEnabled = function () {
|
||||
return !this._disabled
|
||||
}
|
||||
|
||||
Gauge.prototype.setTemplate = function (template) {
|
||||
this._gauge.setTemplate(template)
|
||||
if (this._showing) this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype._computeTheme = function (theme) {
|
||||
if (!theme) theme = {}
|
||||
if (typeof theme === 'string') {
|
||||
theme = this._themes.getTheme(theme)
|
||||
} else if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)) {
|
||||
var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode
|
||||
var useColor = theme.hasColor == null ? hasColor : theme.hasColor
|
||||
theme = this._themes.getDefault({hasUnicode: useUnicode, hasColor: useColor, platform: theme.platform})
|
||||
}
|
||||
return theme
|
||||
}
|
||||
|
||||
Gauge.prototype.setThemeset = function (themes) {
|
||||
this._themes = themes
|
||||
this.setTheme(this._theme)
|
||||
}
|
||||
|
||||
Gauge.prototype.setTheme = function (theme) {
|
||||
this._gauge.setTheme(this._computeTheme(theme))
|
||||
if (this._showing) this._requestRedraw()
|
||||
this._theme = theme
|
||||
}
|
||||
|
||||
Gauge.prototype._requestRedraw = function () {
|
||||
this._needsRedraw = true
|
||||
if (!this._fixedFramerate) this._doRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype.getWidth = function () {
|
||||
return ((this._tty && this._tty.columns) || 80) - 1
|
||||
}
|
||||
|
||||
Gauge.prototype.setWriteTo = function (writeTo, tty) {
|
||||
var enabled = !this._disabled
|
||||
if (enabled) this.disable()
|
||||
this._writeTo = writeTo
|
||||
this._tty = tty ||
|
||||
(writeTo === process.stderr && process.stdout.isTTY && process.stdout) ||
|
||||
(writeTo.isTTY && writeTo) ||
|
||||
this._tty
|
||||
if (this._gauge) this._gauge.setWidth(this.getWidth())
|
||||
if (enabled) this.enable()
|
||||
}
|
||||
|
||||
Gauge.prototype.enable = function () {
|
||||
if (!this._disabled) return
|
||||
this._disabled = false
|
||||
if (this._tty) this._enableEvents()
|
||||
if (this._showing) this.show()
|
||||
}
|
||||
|
||||
Gauge.prototype.disable = function () {
|
||||
if (this._disabled) return
|
||||
if (this._showing) {
|
||||
this._lastUpdateAt = null
|
||||
this._showing = false
|
||||
this._doRedraw()
|
||||
this._showing = true
|
||||
}
|
||||
this._disabled = true
|
||||
if (this._tty) this._disableEvents()
|
||||
}
|
||||
|
||||
Gauge.prototype._enableEvents = function () {
|
||||
if (this._cleanupOnExit) {
|
||||
this._removeOnExit = onExit(callWith(this, this.disable))
|
||||
}
|
||||
this._tty.on('resize', this._$$handleSizeChange)
|
||||
if (this._fixedFramerate) {
|
||||
this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval)
|
||||
if (this.redrawTracker.unref) this.redrawTracker.unref()
|
||||
}
|
||||
}
|
||||
|
||||
Gauge.prototype._disableEvents = function () {
|
||||
this._tty.removeListener('resize', this._$$handleSizeChange)
|
||||
if (this._fixedFramerate) clearInterval(this.redrawTracker)
|
||||
if (this._removeOnExit) this._removeOnExit()
|
||||
}
|
||||
|
||||
Gauge.prototype.hide = function (cb) {
|
||||
if (this._disabled) return cb && process.nextTick(cb)
|
||||
if (!this._showing) return cb && process.nextTick(cb)
|
||||
this._showing = false
|
||||
this._doRedraw()
|
||||
cb && setImmediate(cb)
|
||||
}
|
||||
|
||||
Gauge.prototype.show = function (section, completed) {
|
||||
this._showing = true
|
||||
if (typeof section === 'string') {
|
||||
this._status.section = section
|
||||
} else if (typeof section === 'object') {
|
||||
var sectionKeys = Object.keys(section)
|
||||
for (var ii = 0; ii < sectionKeys.length; ++ii) {
|
||||
var key = sectionKeys[ii]
|
||||
this._status[key] = section[key]
|
||||
}
|
||||
}
|
||||
if (completed != null) this._status.completed = completed
|
||||
if (this._disabled) return
|
||||
this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype.pulse = function (subsection) {
|
||||
this._status.subsection = subsection || ''
|
||||
this._status.spun ++
|
||||
if (this._disabled) return
|
||||
if (!this._showing) return
|
||||
this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype._handleSizeChange = function () {
|
||||
this._gauge.setWidth(this._tty.columns - 1)
|
||||
this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype._doRedraw = function () {
|
||||
if (this._disabled || this._paused) return
|
||||
if (!this._fixedFramerate) {
|
||||
var now = Date.now()
|
||||
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) return
|
||||
this._lastUpdateAt = now
|
||||
}
|
||||
if (!this._showing && this._onScreen) {
|
||||
this._onScreen = false
|
||||
var result = this._gauge.hide()
|
||||
if (this._hideCursor) {
|
||||
result += this._gauge.showCursor()
|
||||
}
|
||||
return this._writeTo.write(result)
|
||||
}
|
||||
if (!this._showing && !this._onScreen) return
|
||||
if (this._showing && !this._onScreen) {
|
||||
this._onScreen = true
|
||||
this._needsRedraw = true
|
||||
if (this._hideCursor) {
|
||||
this._writeTo.write(this._gauge.hideCursor())
|
||||
}
|
||||
}
|
||||
if (!this._needsRedraw) return
|
||||
if (!this._writeTo.write(this._gauge.show(this._status))) {
|
||||
this._paused = true
|
||||
this._writeTo.on('drain', callWith(this, function () {
|
||||
this._paused = false
|
||||
this._doRedraw()
|
||||
}))
|
||||
}
|
||||
}
|
||||
46
node_modules/gauge/node_modules/is-fullwidth-code-point/index.js
generated
vendored
Normal file
46
node_modules/gauge/node_modules/is-fullwidth-code-point/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
var numberIsNan = require('number-is-nan');
|
||||
|
||||
module.exports = function (x) {
|
||||
if (numberIsNan(x)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369
|
||||
|
||||
// code points are derived from:
|
||||
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
|
||||
if (x >= 0x1100 && (
|
||||
x <= 0x115f || // Hangul Jamo
|
||||
0x2329 === x || // LEFT-POINTING ANGLE BRACKET
|
||||
0x232a === x || // RIGHT-POINTING ANGLE BRACKET
|
||||
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
||||
(0x2e80 <= x && x <= 0x3247 && x !== 0x303f) ||
|
||||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
||||
0x3250 <= x && x <= 0x4dbf ||
|
||||
// CJK Unified Ideographs .. Yi Radicals
|
||||
0x4e00 <= x && x <= 0xa4c6 ||
|
||||
// Hangul Jamo Extended-A
|
||||
0xa960 <= x && x <= 0xa97c ||
|
||||
// Hangul Syllables
|
||||
0xac00 <= x && x <= 0xd7a3 ||
|
||||
// CJK Compatibility Ideographs
|
||||
0xf900 <= x && x <= 0xfaff ||
|
||||
// Vertical Forms
|
||||
0xfe10 <= x && x <= 0xfe19 ||
|
||||
// CJK Compatibility Forms .. Small Form Variants
|
||||
0xfe30 <= x && x <= 0xfe6b ||
|
||||
// Halfwidth and Fullwidth Forms
|
||||
0xff01 <= x && x <= 0xff60 ||
|
||||
0xffe0 <= x && x <= 0xffe6 ||
|
||||
// Kana Supplement
|
||||
0x1b000 <= x && x <= 0x1b001 ||
|
||||
// Enclosed Ideographic Supplement
|
||||
0x1f200 <= x && x <= 0x1f251 ||
|
||||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
||||
0x20000 <= x && x <= 0x3fffd)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
21
node_modules/gauge/node_modules/is-fullwidth-code-point/license
generated
vendored
Normal file
21
node_modules/gauge/node_modules/is-fullwidth-code-point/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
25
node_modules/gauge/node_modules/is-fullwidth-code-point/package.json
generated
vendored
Normal file
25
node_modules/gauge/node_modules/is-fullwidth-code-point/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "is-fullwidth-code-point",
|
||||
"version": "1.0.0",
|
||||
"description": "Check if the character represented by a given Unicode code point is fullwidth",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-fullwidth-code-point",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "0.0.4",
|
||||
"code-point-at": "^1.0.0"
|
||||
}
|
||||
}
|
||||
37
node_modules/gauge/node_modules/string-width/index.js
generated
vendored
Normal file
37
node_modules/gauge/node_modules/string-width/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
var stripAnsi = require('strip-ansi');
|
||||
var codePointAt = require('code-point-at');
|
||||
var isFullwidthCodePoint = require('is-fullwidth-code-point');
|
||||
|
||||
// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345
|
||||
module.exports = function (str) {
|
||||
if (typeof str !== 'string' || str.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var width = 0;
|
||||
|
||||
str = stripAnsi(str);
|
||||
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var code = codePointAt(str, i);
|
||||
|
||||
// ignore control characters
|
||||
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// surrogates
|
||||
if (code >= 0x10000) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (isFullwidthCodePoint(code)) {
|
||||
width += 2;
|
||||
} else {
|
||||
width++;
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
};
|
||||
21
node_modules/gauge/node_modules/string-width/license
generated
vendored
Normal file
21
node_modules/gauge/node_modules/string-width/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
27
node_modules/gauge/node_modules/string-width/package.json
generated
vendored
Normal file
27
node_modules/gauge/node_modules/string-width/package.json
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "string-width",
|
||||
"version": "1.0.2",
|
||||
"description": "Get the visual width of a string - the number of columns required to display it",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/string-width",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
"strip-ansi": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
51
node_modules/gauge/package.json
generated
vendored
Normal file
51
node_modules/gauge/package.json
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "gauge",
|
||||
"version": "2.7.4",
|
||||
"description": "A terminal based horizontal guage",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/iarna/gauge"
|
||||
},
|
||||
"author": "Rebecca Turner <me@re-becca.org>",
|
||||
"license": "ISC",
|
||||
"homepage": "https://github.com/iarna/gauge",
|
||||
"dependencies": {
|
||||
"aproba": "^1.0.3",
|
||||
"console-control-strings": "^1.0.0",
|
||||
"has-unicode": "^2.0.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"signal-exit": "^3.0.0",
|
||||
"string-width": "^1.0.1",
|
||||
"strip-ansi": "^3.0.1",
|
||||
"wide-align": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"readable-stream": "^2.0.6",
|
||||
"require-inject": "^1.4.0",
|
||||
"standard": "^7.1.2",
|
||||
"tap": "^5.7.2",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"files": [
|
||||
"base-theme.js",
|
||||
"CHANGELOG.md",
|
||||
"error.js",
|
||||
"has-color.js",
|
||||
"index.js",
|
||||
"LICENSE",
|
||||
"package.json",
|
||||
"plumbing.js",
|
||||
"process.js",
|
||||
"progress-bar.js",
|
||||
"README.md",
|
||||
"render-template.js",
|
||||
"set-immediate.js",
|
||||
"set-interval.js",
|
||||
"spin.js",
|
||||
"template-item.js",
|
||||
"theme-set.js",
|
||||
"themes.js",
|
||||
"wide-truncate.js"
|
||||
]
|
||||
}
|
||||
48
node_modules/gauge/plumbing.js
generated
vendored
Normal file
48
node_modules/gauge/plumbing.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict'
|
||||
var consoleControl = require('console-control-strings')
|
||||
var renderTemplate = require('./render-template.js')
|
||||
var validate = require('aproba')
|
||||
|
||||
var Plumbing = module.exports = function (theme, template, width) {
|
||||
if (!width) width = 80
|
||||
validate('OAN', [theme, template, width])
|
||||
this.showing = false
|
||||
this.theme = theme
|
||||
this.width = width
|
||||
this.template = template
|
||||
}
|
||||
Plumbing.prototype = {}
|
||||
|
||||
Plumbing.prototype.setTheme = function (theme) {
|
||||
validate('O', [theme])
|
||||
this.theme = theme
|
||||
}
|
||||
|
||||
Plumbing.prototype.setTemplate = function (template) {
|
||||
validate('A', [template])
|
||||
this.template = template
|
||||
}
|
||||
|
||||
Plumbing.prototype.setWidth = function (width) {
|
||||
validate('N', [width])
|
||||
this.width = width
|
||||
}
|
||||
|
||||
Plumbing.prototype.hide = function () {
|
||||
return consoleControl.gotoSOL() + consoleControl.eraseLine()
|
||||
}
|
||||
|
||||
Plumbing.prototype.hideCursor = consoleControl.hideCursor
|
||||
|
||||
Plumbing.prototype.showCursor = consoleControl.showCursor
|
||||
|
||||
Plumbing.prototype.show = function (status) {
|
||||
var values = Object.create(this.theme)
|
||||
for (var key in status) {
|
||||
values[key] = status[key]
|
||||
}
|
||||
|
||||
return renderTemplate(this.width, this.template, values).trim() +
|
||||
consoleControl.color('reset') +
|
||||
consoleControl.eraseLine() + consoleControl.gotoSOL()
|
||||
}
|
||||
3
node_modules/gauge/process.js
generated
vendored
Normal file
3
node_modules/gauge/process.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
// this exists so we can replace it during testing
|
||||
module.exports = process
|
||||
35
node_modules/gauge/progress-bar.js
generated
vendored
Normal file
35
node_modules/gauge/progress-bar.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
'use strict'
|
||||
var validate = require('aproba')
|
||||
var renderTemplate = require('./render-template.js')
|
||||
var wideTruncate = require('./wide-truncate')
|
||||
var stringWidth = require('string-width')
|
||||
|
||||
module.exports = function (theme, width, completed) {
|
||||
validate('ONN', [theme, width, completed])
|
||||
if (completed < 0) completed = 0
|
||||
if (completed > 1) completed = 1
|
||||
if (width <= 0) return ''
|
||||
var sofar = Math.round(width * completed)
|
||||
var rest = width - sofar
|
||||
var template = [
|
||||
{type: 'complete', value: repeat(theme.complete, sofar), length: sofar},
|
||||
{type: 'remaining', value: repeat(theme.remaining, rest), length: rest}
|
||||
]
|
||||
return renderTemplate(width, template, theme)
|
||||
}
|
||||
|
||||
// lodash's way of repeating
|
||||
function repeat (string, width) {
|
||||
var result = ''
|
||||
var n = width
|
||||
do {
|
||||
if (n % 2) {
|
||||
result += string
|
||||
}
|
||||
n = Math.floor(n / 2)
|
||||
/*eslint no-self-assign: 0*/
|
||||
string += string
|
||||
} while (n && stringWidth(result) < width)
|
||||
|
||||
return wideTruncate(result, width)
|
||||
}
|
||||
181
node_modules/gauge/render-template.js
generated
vendored
Normal file
181
node_modules/gauge/render-template.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
'use strict'
|
||||
var align = require('wide-align')
|
||||
var validate = require('aproba')
|
||||
var objectAssign = require('object-assign')
|
||||
var wideTruncate = require('./wide-truncate')
|
||||
var error = require('./error')
|
||||
var TemplateItem = require('./template-item')
|
||||
|
||||
function renderValueWithValues (values) {
|
||||
return function (item) {
|
||||
return renderValue(item, values)
|
||||
}
|
||||
}
|
||||
|
||||
var renderTemplate = module.exports = function (width, template, values) {
|
||||
var items = prepareItems(width, template, values)
|
||||
var rendered = items.map(renderValueWithValues(values)).join('')
|
||||
return align.left(wideTruncate(rendered, width), width)
|
||||
}
|
||||
|
||||
function preType (item) {
|
||||
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1)
|
||||
return 'pre' + cappedTypeName
|
||||
}
|
||||
|
||||
function postType (item) {
|
||||
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1)
|
||||
return 'post' + cappedTypeName
|
||||
}
|
||||
|
||||
function hasPreOrPost (item, values) {
|
||||
if (!item.type) return
|
||||
return values[preType(item)] || values[postType(item)]
|
||||
}
|
||||
|
||||
function generatePreAndPost (baseItem, parentValues) {
|
||||
var item = objectAssign({}, baseItem)
|
||||
var values = Object.create(parentValues)
|
||||
var template = []
|
||||
var pre = preType(item)
|
||||
var post = postType(item)
|
||||
if (values[pre]) {
|
||||
template.push({value: values[pre]})
|
||||
values[pre] = null
|
||||
}
|
||||
item.minLength = null
|
||||
item.length = null
|
||||
item.maxLength = null
|
||||
template.push(item)
|
||||
values[item.type] = values[item.type]
|
||||
if (values[post]) {
|
||||
template.push({value: values[post]})
|
||||
values[post] = null
|
||||
}
|
||||
return function ($1, $2, length) {
|
||||
return renderTemplate(length, template, values)
|
||||
}
|
||||
}
|
||||
|
||||
function prepareItems (width, template, values) {
|
||||
function cloneAndObjectify (item, index, arr) {
|
||||
var cloned = new TemplateItem(item, width)
|
||||
var type = cloned.type
|
||||
if (cloned.value == null) {
|
||||
if (!(type in values)) {
|
||||
if (cloned.default == null) {
|
||||
throw new error.MissingTemplateValue(cloned, values)
|
||||
} else {
|
||||
cloned.value = cloned.default
|
||||
}
|
||||
} else {
|
||||
cloned.value = values[type]
|
||||
}
|
||||
}
|
||||
if (cloned.value == null || cloned.value === '') return null
|
||||
cloned.index = index
|
||||
cloned.first = index === 0
|
||||
cloned.last = index === arr.length - 1
|
||||
if (hasPreOrPost(cloned, values)) cloned.value = generatePreAndPost(cloned, values)
|
||||
return cloned
|
||||
}
|
||||
|
||||
var output = template.map(cloneAndObjectify).filter(function (item) { return item != null })
|
||||
|
||||
var outputLength = 0
|
||||
var remainingSpace = width
|
||||
var variableCount = output.length
|
||||
|
||||
function consumeSpace (length) {
|
||||
if (length > remainingSpace) length = remainingSpace
|
||||
outputLength += length
|
||||
remainingSpace -= length
|
||||
}
|
||||
|
||||
function finishSizing (item, length) {
|
||||
if (item.finished) throw new error.Internal('Tried to finish template item that was already finished')
|
||||
if (length === Infinity) throw new error.Internal('Length of template item cannot be infinity')
|
||||
if (length != null) item.length = length
|
||||
item.minLength = null
|
||||
item.maxLength = null
|
||||
--variableCount
|
||||
item.finished = true
|
||||
if (item.length == null) item.length = item.getBaseLength()
|
||||
if (item.length == null) throw new error.Internal('Finished template items must have a length')
|
||||
consumeSpace(item.getLength())
|
||||
}
|
||||
|
||||
output.forEach(function (item) {
|
||||
if (!item.kerning) return
|
||||
var prevPadRight = item.first ? 0 : output[item.index - 1].padRight
|
||||
if (!item.first && prevPadRight < item.kerning) item.padLeft = item.kerning - prevPadRight
|
||||
if (!item.last) item.padRight = item.kerning
|
||||
})
|
||||
|
||||
// Finish any that have a fixed (literal or intuited) length
|
||||
output.forEach(function (item) {
|
||||
if (item.getBaseLength() == null) return
|
||||
finishSizing(item)
|
||||
})
|
||||
|
||||
var resized = 0
|
||||
var resizing
|
||||
var hunkSize
|
||||
do {
|
||||
resizing = false
|
||||
hunkSize = Math.round(remainingSpace / variableCount)
|
||||
output.forEach(function (item) {
|
||||
if (item.finished) return
|
||||
if (!item.maxLength) return
|
||||
if (item.getMaxLength() < hunkSize) {
|
||||
finishSizing(item, item.maxLength)
|
||||
resizing = true
|
||||
}
|
||||
})
|
||||
} while (resizing && resized++ < output.length)
|
||||
if (resizing) throw new error.Internal('Resize loop iterated too many times while determining maxLength')
|
||||
|
||||
resized = 0
|
||||
do {
|
||||
resizing = false
|
||||
hunkSize = Math.round(remainingSpace / variableCount)
|
||||
output.forEach(function (item) {
|
||||
if (item.finished) return
|
||||
if (!item.minLength) return
|
||||
if (item.getMinLength() >= hunkSize) {
|
||||
finishSizing(item, item.minLength)
|
||||
resizing = true
|
||||
}
|
||||
})
|
||||
} while (resizing && resized++ < output.length)
|
||||
if (resizing) throw new error.Internal('Resize loop iterated too many times while determining minLength')
|
||||
|
||||
hunkSize = Math.round(remainingSpace / variableCount)
|
||||
output.forEach(function (item) {
|
||||
if (item.finished) return
|
||||
finishSizing(item, hunkSize)
|
||||
})
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
function renderFunction (item, values, length) {
|
||||
validate('OON', arguments)
|
||||
if (item.type) {
|
||||
return item.value(values, values[item.type + 'Theme'] || {}, length)
|
||||
} else {
|
||||
return item.value(values, {}, length)
|
||||
}
|
||||
}
|
||||
|
||||
function renderValue (item, values) {
|
||||
var length = item.getBaseLength()
|
||||
var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value
|
||||
if (value == null || value === '') return ''
|
||||
var alignWith = align[item.align] || align.left
|
||||
var leftPadding = item.padLeft ? align.left('', item.padLeft) : ''
|
||||
var rightPadding = item.padRight ? align.right('', item.padRight) : ''
|
||||
var truncated = wideTruncate(String(value), length)
|
||||
var aligned = alignWith(truncated, length)
|
||||
return leftPadding + aligned + rightPadding
|
||||
}
|
||||
7
node_modules/gauge/set-immediate.js
generated
vendored
Normal file
7
node_modules/gauge/set-immediate.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
var process = require('./process')
|
||||
try {
|
||||
module.exports = setImmediate
|
||||
} catch (ex) {
|
||||
module.exports = process.nextTick
|
||||
}
|
||||
3
node_modules/gauge/set-interval.js
generated
vendored
Normal file
3
node_modules/gauge/set-interval.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
// this exists so we can replace it during testing
|
||||
module.exports = setInterval
|
||||
5
node_modules/gauge/spin.js
generated
vendored
Normal file
5
node_modules/gauge/spin.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = function spin (spinstr, spun) {
|
||||
return spinstr[spun % spinstr.length]
|
||||
}
|
||||
73
node_modules/gauge/template-item.js
generated
vendored
Normal file
73
node_modules/gauge/template-item.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
'use strict'
|
||||
var stringWidth = require('string-width')
|
||||
|
||||
module.exports = TemplateItem
|
||||
|
||||
function isPercent (num) {
|
||||
if (typeof num !== 'string') return false
|
||||
return num.slice(-1) === '%'
|
||||
}
|
||||
|
||||
function percent (num) {
|
||||
return Number(num.slice(0, -1)) / 100
|
||||
}
|
||||
|
||||
function TemplateItem (values, outputLength) {
|
||||
this.overallOutputLength = outputLength
|
||||
this.finished = false
|
||||
this.type = null
|
||||
this.value = null
|
||||
this.length = null
|
||||
this.maxLength = null
|
||||
this.minLength = null
|
||||
this.kerning = null
|
||||
this.align = 'left'
|
||||
this.padLeft = 0
|
||||
this.padRight = 0
|
||||
this.index = null
|
||||
this.first = null
|
||||
this.last = null
|
||||
if (typeof values === 'string') {
|
||||
this.value = values
|
||||
} else {
|
||||
for (var prop in values) this[prop] = values[prop]
|
||||
}
|
||||
// Realize percents
|
||||
if (isPercent(this.length)) {
|
||||
this.length = Math.round(this.overallOutputLength * percent(this.length))
|
||||
}
|
||||
if (isPercent(this.minLength)) {
|
||||
this.minLength = Math.round(this.overallOutputLength * percent(this.minLength))
|
||||
}
|
||||
if (isPercent(this.maxLength)) {
|
||||
this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength))
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
TemplateItem.prototype = {}
|
||||
|
||||
TemplateItem.prototype.getBaseLength = function () {
|
||||
var length = this.length
|
||||
if (length == null && typeof this.value === 'string' && this.maxLength == null && this.minLength == null) {
|
||||
length = stringWidth(this.value)
|
||||
}
|
||||
return length
|
||||
}
|
||||
|
||||
TemplateItem.prototype.getLength = function () {
|
||||
var length = this.getBaseLength()
|
||||
if (length == null) return null
|
||||
return length + this.padLeft + this.padRight
|
||||
}
|
||||
|
||||
TemplateItem.prototype.getMaxLength = function () {
|
||||
if (this.maxLength == null) return null
|
||||
return this.maxLength + this.padLeft + this.padRight
|
||||
}
|
||||
|
||||
TemplateItem.prototype.getMinLength = function () {
|
||||
if (this.minLength == null) return null
|
||||
return this.minLength + this.padLeft + this.padRight
|
||||
}
|
||||
|
||||
115
node_modules/gauge/theme-set.js
generated
vendored
Normal file
115
node_modules/gauge/theme-set.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
'use strict'
|
||||
var objectAssign = require('object-assign')
|
||||
|
||||
module.exports = function () {
|
||||
return ThemeSetProto.newThemeSet()
|
||||
}
|
||||
|
||||
var ThemeSetProto = {}
|
||||
|
||||
ThemeSetProto.baseTheme = require('./base-theme.js')
|
||||
|
||||
ThemeSetProto.newTheme = function (parent, theme) {
|
||||
if (!theme) {
|
||||
theme = parent
|
||||
parent = this.baseTheme
|
||||
}
|
||||
return objectAssign({}, parent, theme)
|
||||
}
|
||||
|
||||
ThemeSetProto.getThemeNames = function () {
|
||||
return Object.keys(this.themes)
|
||||
}
|
||||
|
||||
ThemeSetProto.addTheme = function (name, parent, theme) {
|
||||
this.themes[name] = this.newTheme(parent, theme)
|
||||
}
|
||||
|
||||
ThemeSetProto.addToAllThemes = function (theme) {
|
||||
var themes = this.themes
|
||||
Object.keys(themes).forEach(function (name) {
|
||||
objectAssign(themes[name], theme)
|
||||
})
|
||||
objectAssign(this.baseTheme, theme)
|
||||
}
|
||||
|
||||
ThemeSetProto.getTheme = function (name) {
|
||||
if (!this.themes[name]) throw this.newMissingThemeError(name)
|
||||
return this.themes[name]
|
||||
}
|
||||
|
||||
ThemeSetProto.setDefault = function (opts, name) {
|
||||
if (name == null) {
|
||||
name = opts
|
||||
opts = {}
|
||||
}
|
||||
var platform = opts.platform == null ? 'fallback' : opts.platform
|
||||
var hasUnicode = !!opts.hasUnicode
|
||||
var hasColor = !!opts.hasColor
|
||||
if (!this.defaults[platform]) this.defaults[platform] = {true: {}, false: {}}
|
||||
this.defaults[platform][hasUnicode][hasColor] = name
|
||||
}
|
||||
|
||||
ThemeSetProto.getDefault = function (opts) {
|
||||
if (!opts) opts = {}
|
||||
var platformName = opts.platform || process.platform
|
||||
var platform = this.defaults[platformName] || this.defaults.fallback
|
||||
var hasUnicode = !!opts.hasUnicode
|
||||
var hasColor = !!opts.hasColor
|
||||
if (!platform) throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor)
|
||||
if (!platform[hasUnicode][hasColor]) {
|
||||
if (hasUnicode && hasColor && platform[!hasUnicode][hasColor]) {
|
||||
hasUnicode = false
|
||||
} else if (hasUnicode && hasColor && platform[hasUnicode][!hasColor]) {
|
||||
hasColor = false
|
||||
} else if (hasUnicode && hasColor && platform[!hasUnicode][!hasColor]) {
|
||||
hasUnicode = false
|
||||
hasColor = false
|
||||
} else if (hasUnicode && !hasColor && platform[!hasUnicode][hasColor]) {
|
||||
hasUnicode = false
|
||||
} else if (!hasUnicode && hasColor && platform[hasUnicode][!hasColor]) {
|
||||
hasColor = false
|
||||
} else if (platform === this.defaults.fallback) {
|
||||
throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor)
|
||||
}
|
||||
}
|
||||
if (platform[hasUnicode][hasColor]) {
|
||||
return this.getTheme(platform[hasUnicode][hasColor])
|
||||
} else {
|
||||
return this.getDefault(objectAssign({}, opts, {platform: 'fallback'}))
|
||||
}
|
||||
}
|
||||
|
||||
ThemeSetProto.newMissingThemeError = function newMissingThemeError (name) {
|
||||
var err = new Error('Could not find a gauge theme named "' + name + '"')
|
||||
Error.captureStackTrace.call(err, newMissingThemeError)
|
||||
err.theme = name
|
||||
err.code = 'EMISSINGTHEME'
|
||||
return err
|
||||
}
|
||||
|
||||
ThemeSetProto.newMissingDefaultThemeError = function newMissingDefaultThemeError (platformName, hasUnicode, hasColor) {
|
||||
var err = new Error(
|
||||
'Could not find a gauge theme for your platform/unicode/color use combo:\n' +
|
||||
' platform = ' + platformName + '\n' +
|
||||
' hasUnicode = ' + hasUnicode + '\n' +
|
||||
' hasColor = ' + hasColor)
|
||||
Error.captureStackTrace.call(err, newMissingDefaultThemeError)
|
||||
err.platform = platformName
|
||||
err.hasUnicode = hasUnicode
|
||||
err.hasColor = hasColor
|
||||
err.code = 'EMISSINGTHEME'
|
||||
return err
|
||||
}
|
||||
|
||||
ThemeSetProto.newThemeSet = function () {
|
||||
var themeset = function (opts) {
|
||||
return themeset.getDefault(opts)
|
||||
}
|
||||
return objectAssign(themeset, ThemeSetProto, {
|
||||
themes: objectAssign({}, this.themes),
|
||||
baseTheme: objectAssign({}, this.baseTheme),
|
||||
defaults: JSON.parse(JSON.stringify(this.defaults || {}))
|
||||
})
|
||||
}
|
||||
|
||||
54
node_modules/gauge/themes.js
generated
vendored
Normal file
54
node_modules/gauge/themes.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict'
|
||||
var consoleControl = require('console-control-strings')
|
||||
var ThemeSet = require('./theme-set.js')
|
||||
|
||||
var themes = module.exports = new ThemeSet()
|
||||
|
||||
themes.addTheme('ASCII', {
|
||||
preProgressbar: '[',
|
||||
postProgressbar: ']',
|
||||
progressbarTheme: {
|
||||
complete: '#',
|
||||
remaining: '.'
|
||||
},
|
||||
activityIndicatorTheme: '-\\|/',
|
||||
preSubsection: '>'
|
||||
})
|
||||
|
||||
themes.addTheme('colorASCII', themes.getTheme('ASCII'), {
|
||||
progressbarTheme: {
|
||||
preComplete: consoleControl.color('inverse'),
|
||||
complete: ' ',
|
||||
postComplete: consoleControl.color('stopInverse'),
|
||||
preRemaining: consoleControl.color('brightBlack'),
|
||||
remaining: '.',
|
||||
postRemaining: consoleControl.color('reset')
|
||||
}
|
||||
})
|
||||
|
||||
themes.addTheme('brailleSpinner', {
|
||||
preProgressbar: '⸨',
|
||||
postProgressbar: '⸩',
|
||||
progressbarTheme: {
|
||||
complete: '░',
|
||||
remaining: '⠂'
|
||||
},
|
||||
activityIndicatorTheme: '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏',
|
||||
preSubsection: '>'
|
||||
})
|
||||
|
||||
themes.addTheme('colorBrailleSpinner', themes.getTheme('brailleSpinner'), {
|
||||
progressbarTheme: {
|
||||
preComplete: consoleControl.color('inverse'),
|
||||
complete: ' ',
|
||||
postComplete: consoleControl.color('stopInverse'),
|
||||
preRemaining: consoleControl.color('brightBlack'),
|
||||
remaining: '░',
|
||||
postRemaining: consoleControl.color('reset')
|
||||
}
|
||||
})
|
||||
|
||||
themes.setDefault({}, 'ASCII')
|
||||
themes.setDefault({hasColor: true}, 'colorASCII')
|
||||
themes.setDefault({platform: 'darwin', hasUnicode: true}, 'brailleSpinner')
|
||||
themes.setDefault({platform: 'darwin', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner')
|
||||
25
node_modules/gauge/wide-truncate.js
generated
vendored
Normal file
25
node_modules/gauge/wide-truncate.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict'
|
||||
var stringWidth = require('string-width')
|
||||
var stripAnsi = require('strip-ansi')
|
||||
|
||||
module.exports = wideTruncate
|
||||
|
||||
function wideTruncate (str, target) {
|
||||
if (stringWidth(str) === 0) return str
|
||||
if (target <= 0) return ''
|
||||
if (stringWidth(str) <= target) return str
|
||||
|
||||
// We compute the number of bytes of ansi sequences here and add
|
||||
// that to our initial truncation to ensure that we don't slice one
|
||||
// that we want to keep in half.
|
||||
var noAnsi = stripAnsi(str)
|
||||
var ansiSize = str.length + noAnsi.length
|
||||
var truncated = str.slice(0, target + ansiSize)
|
||||
|
||||
// we have to shrink the result to account for our ansi sequence buffer
|
||||
// (if an ansi sequence was truncated) and double width characters.
|
||||
while (stringWidth(truncated) > target) {
|
||||
truncated = truncated.slice(0, -1)
|
||||
}
|
||||
return truncated
|
||||
}
|
||||
Reference in New Issue
Block a user