@sc-voice/tools 3.4.0 → 3.5.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/index.mjs +2 -0
- package/package.json +1 -1
- package/src/math/interval.mjs +4 -5
- package/src/text/color-console.mjs +111 -0
package/index.mjs
CHANGED
|
@@ -18,9 +18,11 @@ import { WordSpace } from './src/text/word-space.mjs';
|
|
|
18
18
|
import { WordVector } from './src/text/word-vector.mjs';
|
|
19
19
|
import { TfidfSpace } from './src/text/tfidf-space.mjs';
|
|
20
20
|
import { LogEntry, Logger } from './src/text/logger.mjs';
|
|
21
|
+
import { ColorConsole} from './src/text/color-console.mjs';
|
|
21
22
|
|
|
22
23
|
export const Text = {
|
|
23
24
|
BilaraPath,
|
|
25
|
+
ColorConsole,
|
|
24
26
|
Corpus,
|
|
25
27
|
EbtDoc,
|
|
26
28
|
LegacyDoc,
|
package/package.json
CHANGED
package/src/math/interval.mjs
CHANGED
|
@@ -48,16 +48,15 @@ export class Interval {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
static get INFINITY() {
|
|
51
|
+
static get INFINITY() {
|
|
52
|
+
return INFINITY;
|
|
53
|
+
}
|
|
52
54
|
|
|
53
55
|
get isEmpty() {
|
|
54
56
|
if (this.lo === null && this.hi === null) {
|
|
55
57
|
return true;
|
|
56
58
|
}
|
|
57
|
-
if (
|
|
58
|
-
this.lo === INFINITY ||
|
|
59
|
-
this.hi === INFINITY
|
|
60
|
-
) {
|
|
59
|
+
if (this.lo === INFINITY || this.hi === INFINITY) {
|
|
61
60
|
return false;
|
|
62
61
|
}
|
|
63
62
|
return this.hi < this.lo;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Unicode } from './unicode.mjs';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
BLACK,
|
|
5
|
+
WHITE,
|
|
6
|
+
RED,
|
|
7
|
+
GREEN,
|
|
8
|
+
BLUE,
|
|
9
|
+
CYAN,
|
|
10
|
+
MAGENTA,
|
|
11
|
+
YELLOW,
|
|
12
|
+
BRIGHT_BLACK,
|
|
13
|
+
BRIGHT_WHITE,
|
|
14
|
+
BRIGHT_RED,
|
|
15
|
+
BRIGHT_GREEN,
|
|
16
|
+
BRIGHT_BLUE,
|
|
17
|
+
BRIGHT_CYAN,
|
|
18
|
+
BRIGHT_MAGENTA,
|
|
19
|
+
BRIGHT_YELLOW,
|
|
20
|
+
NO_COLOR,
|
|
21
|
+
} = Unicode.LINUX_COLOR;
|
|
22
|
+
|
|
23
|
+
export class ColorConsole {
|
|
24
|
+
constructor(opts = {}) {
|
|
25
|
+
let {
|
|
26
|
+
write = (...args) => console.log.call(null, ...args),
|
|
27
|
+
colorOk1 = BRIGHT_GREEN,
|
|
28
|
+
colorOk2 = GREEN,
|
|
29
|
+
colorFYI1 = BRIGHT_BLACK,
|
|
30
|
+
colorBad1 = BRIGHT_RED,
|
|
31
|
+
colorBad2 = RED,
|
|
32
|
+
colorTag1 = CYAN,
|
|
33
|
+
colorTag2 = BRIGHT_CYAN,
|
|
34
|
+
colorTag3 = MAGENTA,
|
|
35
|
+
colorTag4 = BRIGHT_MAGENTA,
|
|
36
|
+
} = opts;
|
|
37
|
+
|
|
38
|
+
Object.assign(this, {
|
|
39
|
+
write,
|
|
40
|
+
colorOk1,
|
|
41
|
+
colorOk2,
|
|
42
|
+
colorFYI1,
|
|
43
|
+
colorBad1,
|
|
44
|
+
colorBad2,
|
|
45
|
+
colorTag1,
|
|
46
|
+
colorTag2,
|
|
47
|
+
colorTag3,
|
|
48
|
+
colorTag4,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
color(color, ...things) {
|
|
53
|
+
return things.map((thing) => {
|
|
54
|
+
switch (typeof thing) {
|
|
55
|
+
case 'object':
|
|
56
|
+
// TODO: pretty objects like console
|
|
57
|
+
return thing;
|
|
58
|
+
case 'string':
|
|
59
|
+
return `${color}${thing}${NO_COLOR}`;
|
|
60
|
+
case 'number':
|
|
61
|
+
return `${GREEN}${thing}${NO_COLOR}`;
|
|
62
|
+
default:
|
|
63
|
+
return `${color}${JSON.stringify(thing)}${NO_COLOR}`;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
msgLvl(color, msg, lvl, rest) {
|
|
69
|
+
return this.color(color, msg + (lvl ? `@${lvl}` : ''), ...rest);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ok1(msg, lvl, ...rest) {
|
|
73
|
+
let color = this.colorOk1;
|
|
74
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ok2(msg, lvl, ...rest) {
|
|
78
|
+
let color = this.colorOk2;
|
|
79
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
bad1(msg, lvl, ...rest) {
|
|
83
|
+
let color = this.colorBad1;
|
|
84
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
bad2(msg, lvl, ...rest) {
|
|
88
|
+
let color = this.colorBad2;
|
|
89
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
tag1(msg, lvl, ...rest) {
|
|
93
|
+
let color = this.colorTag1;
|
|
94
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
tag2(msg, lvl, ...rest) {
|
|
98
|
+
let color = this.colorTag2;
|
|
99
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
tag3(msg, lvl, ...rest) {
|
|
103
|
+
let color = this.colorTag3;
|
|
104
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
tag4(msg, lvl, ...rest) {
|
|
108
|
+
let color = this.colorTag4;
|
|
109
|
+
this.write(...this.msgLvl(color, msg, lvl, rest));
|
|
110
|
+
}
|
|
111
|
+
}
|