tty-table 5.0.0 → 6.0.0

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/src/style.js DELETED
@@ -1,62 +0,0 @@
1
- const chalk = require("chalk")
2
- const kleur = require("kleur")
3
-
4
- // user kleur if we are in the browser
5
- const colorLib = (process && process.stdout) ? chalk : kleur
6
-
7
- const stripAnsi = require("strip-ansi")
8
-
9
- module.exports.style = (str, ...colors) => {
10
- const out = colors.reduce(function (input, color) {
11
- return colorLib[color](input)
12
- }, str)
13
- return out
14
- }
15
-
16
- module.exports.styleEachChar = (str, ...colors) => {
17
- // strip existing ansi chars so we dont loop them
18
- // @ TODO create a really clever workaround so that you can accrete styles
19
- const chars = [...stripAnsi(str)]
20
-
21
- // style each character
22
- const out = chars.reduce((prev, current) => {
23
- const coded = colors.reduce((input, color) => {
24
- return colorLib[color](input)
25
- }, current)
26
- return prev + coded
27
- }, "")
28
-
29
- return out
30
- }
31
-
32
- module.exports.resetStyle = function (str) {
33
- this.configure({ reset: true })
34
- return stripAnsi(str)
35
- }
36
-
37
- module.exports.colorizeCell = (str, cellOptions, rowType) => {
38
- let color = false // false will keep terminal default
39
-
40
- switch (true) {
41
- case (rowType === "body"):
42
- color = cellOptions.color || color
43
- break
44
-
45
- case (rowType === "header"):
46
- color = cellOptions.headerColor || color
47
- break
48
-
49
- default:
50
- color = cellOptions.footerColor || color
51
- }
52
-
53
- if (color) {
54
- str = exports.style(str, color)
55
- }
56
-
57
- return str
58
- }
59
-
60
- module.exports.isColorEnabled = () => {
61
- return (process && process.stdout) ? colorLib.level > 0 : colorLib.enabled
62
- }