@sc-voice/tools 3.15.0 → 3.16.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/package.json +1 -1
- package/src/defines.mjs +1 -0
- package/src/math/interval.mjs +18 -8
- package/src/text/color-console.mjs +41 -64
package/package.json
CHANGED
package/src/defines.mjs
CHANGED
package/src/math/interval.mjs
CHANGED
|
@@ -99,7 +99,7 @@ export class Interval {
|
|
|
99
99
|
const msg = 'i6l.contains';
|
|
100
100
|
const dbg = DBG.I6L_CONTAINS;
|
|
101
101
|
if (typeof num !== 'number' || Number.isNaN(num)) {
|
|
102
|
-
dbg && cc.fyi1(msg+0.1, false);
|
|
102
|
+
dbg && cc.fyi1(msg + 0.1, false);
|
|
103
103
|
return false;
|
|
104
104
|
}
|
|
105
105
|
let { lo, hi, leftOpen, rightOpen } = this;
|
|
@@ -151,28 +151,38 @@ export class Interval {
|
|
|
151
151
|
overlaps(iv2) {
|
|
152
152
|
const msg = 'i6l.overlaps';
|
|
153
153
|
const dbg = DBG.I6L_OVERLAPS;
|
|
154
|
-
let {
|
|
155
|
-
|
|
154
|
+
let {
|
|
155
|
+
lo: lo1,
|
|
156
|
+
hi: hi1,
|
|
157
|
+
leftOpen: lOpen1,
|
|
158
|
+
rightOpen: rOpen1,
|
|
159
|
+
} = this;
|
|
160
|
+
let {
|
|
161
|
+
lo: lo2,
|
|
162
|
+
hi: hi2,
|
|
163
|
+
leftOpen: lOpen2,
|
|
164
|
+
rightOpen: rOpen2,
|
|
165
|
+
} = iv2;
|
|
156
166
|
|
|
157
167
|
//console.log(msg, {lo1, lo2, hi1, hi2});
|
|
158
168
|
if (!lOpen1 && iv2.contains(lo1)) {
|
|
159
|
-
dbg && cc.fyi1(msg+1, 'lo1');
|
|
169
|
+
dbg && cc.fyi1(msg + 1, 'lo1');
|
|
160
170
|
return true;
|
|
161
171
|
}
|
|
162
172
|
if (!rOpen1 && iv2.contains(hi1)) {
|
|
163
|
-
dbg && cc.fyi1(msg+2, 'hi1');
|
|
173
|
+
dbg && cc.fyi1(msg + 2, 'hi1');
|
|
164
174
|
return true;
|
|
165
175
|
}
|
|
166
176
|
if (!lOpen2 && this.contains(lo2)) {
|
|
167
|
-
dbg && cc.fyi1(msg+3, 'lo2');
|
|
177
|
+
dbg && cc.fyi1(msg + 3, 'lo2');
|
|
168
178
|
return true;
|
|
169
179
|
}
|
|
170
180
|
if (!rOpen2 && this.contains(hi2)) {
|
|
171
|
-
dbg && cc.fyi1(msg+4, 'hi2');
|
|
181
|
+
dbg && cc.fyi1(msg + 4, 'hi2');
|
|
172
182
|
return true;
|
|
173
183
|
}
|
|
174
184
|
|
|
175
|
-
dbg && cc.fyi1(msg+0.1, false);
|
|
185
|
+
dbg && cc.fyi1(msg + 0.1, false);
|
|
176
186
|
return false;
|
|
177
187
|
}
|
|
178
188
|
}
|
|
@@ -25,31 +25,25 @@ let CC;
|
|
|
25
25
|
export class ColorConsole {
|
|
26
26
|
constructor(opts = {}) {
|
|
27
27
|
let {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
colorTag2 = BRIGHT_CYAN,
|
|
36
|
-
colorTag3 = MAGENTA,
|
|
37
|
-
colorTag4 = BRIGHT_MAGENTA,
|
|
28
|
+
badColor1 = BRIGHT_RED,
|
|
29
|
+
badColor2 = RED,
|
|
30
|
+
fyiColor1 = BRIGHT_WHITE,
|
|
31
|
+
fyiColor2 = BRIGHT_BLACK,
|
|
32
|
+
okColor1 = BRIGHT_GREEN,
|
|
33
|
+
okColor2 = GREEN,
|
|
34
|
+
valueColor = CYAN,
|
|
38
35
|
precision = 3,
|
|
39
36
|
write = (...args) => console.log.call(null, ...args),
|
|
40
37
|
} = opts;
|
|
41
38
|
|
|
42
39
|
Object.assign(this, {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
colorTag2,
|
|
51
|
-
colorTag3,
|
|
52
|
-
colorTag4,
|
|
40
|
+
badColor1,
|
|
41
|
+
badColor2,
|
|
42
|
+
fyiColor1,
|
|
43
|
+
fyiColor2,
|
|
44
|
+
okColor1,
|
|
45
|
+
okColor2,
|
|
46
|
+
valueColor,
|
|
53
47
|
precision,
|
|
54
48
|
write,
|
|
55
49
|
});
|
|
@@ -60,28 +54,34 @@ export class ColorConsole {
|
|
|
60
54
|
return CC;
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
color(
|
|
64
|
-
let { precision } = this;
|
|
57
|
+
color(textColor, ...things) {
|
|
58
|
+
let { precision, valueColor } = this;
|
|
65
59
|
let label = '';
|
|
60
|
+
let endColor = NO_COLOR;
|
|
66
61
|
return things.reduce((a, thing) => {
|
|
67
62
|
let newLabel = '';
|
|
68
63
|
switch (typeof thing) {
|
|
69
64
|
case 'object': {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
if (thing === null) {
|
|
66
|
+
a.push(label + valueColor + 'null' + endColor);
|
|
67
|
+
} else if (
|
|
73
68
|
thing.constructor !== Object &&
|
|
74
69
|
typeof thing.toString === 'function'
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
) {
|
|
71
|
+
a.push(label + valueColor + thing.toString() + endColor);
|
|
72
|
+
} else {
|
|
73
|
+
label && a.push(label + endColor);
|
|
74
|
+
a.push(thing);
|
|
75
|
+
}
|
|
78
76
|
break;
|
|
79
77
|
}
|
|
80
78
|
case 'string':
|
|
81
79
|
if (thing.endsWith(':')) {
|
|
82
|
-
newLabel =
|
|
80
|
+
newLabel = textColor + thing;
|
|
81
|
+
} else if (label) {
|
|
82
|
+
a.push(label + valueColor + thing + endColor);
|
|
83
83
|
} else {
|
|
84
|
-
a.push(
|
|
84
|
+
a.push(textColor + thing + endColor);
|
|
85
85
|
}
|
|
86
86
|
break;
|
|
87
87
|
case 'number': {
|
|
@@ -89,30 +89,30 @@ export class ColorConsole {
|
|
|
89
89
|
if (thing === Number(v)) {
|
|
90
90
|
v = v.replace(/\.?0+$/, '');
|
|
91
91
|
}
|
|
92
|
-
a.push(label +
|
|
92
|
+
a.push(label + valueColor + v + endColor);
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
95
|
default:
|
|
96
|
-
a.push(
|
|
96
|
+
a.push(
|
|
97
|
+
label + valueColor + JSON.stringify(thing) + endColor,
|
|
98
|
+
);
|
|
97
99
|
break;
|
|
98
100
|
}
|
|
99
101
|
label = newLabel;
|
|
100
102
|
return a;
|
|
101
103
|
}, []);
|
|
102
|
-
}
|
|
104
|
+
} // color
|
|
103
105
|
|
|
104
106
|
fyi(...rest) {
|
|
105
107
|
return this.fyi2(...rest);
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
fyi1(...rest) {
|
|
109
|
-
|
|
110
|
-
this.write(...this.color(color, ...rest));
|
|
111
|
+
this.write(...this.color(this.fyiColor1, ...rest));
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
fyi2(...rest) {
|
|
114
|
-
|
|
115
|
-
this.write(...this.color(color, ...rest));
|
|
115
|
+
this.write(...this.color(this.fyiColor2, ...rest));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
ok(...rest) {
|
|
@@ -120,13 +120,11 @@ export class ColorConsole {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
ok1(...rest) {
|
|
123
|
-
|
|
124
|
-
this.write(...this.color(color, ...rest));
|
|
123
|
+
this.write(...this.color(this.okColor1, ...rest));
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
ok2(...rest) {
|
|
128
|
-
|
|
129
|
-
this.write(...this.color(color, ...rest));
|
|
127
|
+
this.write(...this.color(this.okColor2, ...rest));
|
|
130
128
|
}
|
|
131
129
|
|
|
132
130
|
bad(...rest) {
|
|
@@ -134,32 +132,11 @@ export class ColorConsole {
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
bad1(...rest) {
|
|
137
|
-
|
|
138
|
-
this.write(...this.color(color, ...rest));
|
|
135
|
+
this.write(...this.color(this.badColor1, ...rest));
|
|
139
136
|
}
|
|
140
137
|
|
|
141
138
|
bad2(...rest) {
|
|
142
|
-
|
|
143
|
-
this.write(...this.color(color, ...rest));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
tag1(...rest) {
|
|
147
|
-
let color = this.colorTag1;
|
|
148
|
-
this.write(...this.color(color, ...rest));
|
|
139
|
+
this.write(...this.color(this.badColor2, ...rest));
|
|
149
140
|
}
|
|
150
141
|
|
|
151
|
-
tag2(...rest) {
|
|
152
|
-
let color = this.colorTag2;
|
|
153
|
-
this.write(...this.color(color, ...rest));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
tag3(...rest) {
|
|
157
|
-
let color = this.colorTag3;
|
|
158
|
-
this.write(...this.color(color, ...rest));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
tag4(...rest) {
|
|
162
|
-
let color = this.colorTag4;
|
|
163
|
-
this.write(...this.color(color, ...rest));
|
|
164
|
-
}
|
|
165
142
|
}
|