@sc-voice/tools 3.8.0 → 3.10.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/math/interval.mjs +16 -0
- package/src/text/color-console.mjs +7 -2
package/package.json
CHANGED
package/src/math/interval.mjs
CHANGED
|
@@ -16,6 +16,9 @@ export class Interval {
|
|
|
16
16
|
|
|
17
17
|
let isClosed = true;
|
|
18
18
|
if (an && bn) {
|
|
19
|
+
if (b < a) {
|
|
20
|
+
throw new Error(`${msg} invalid interval ${b}<${a}?`);
|
|
21
|
+
}
|
|
19
22
|
dbg && console.log(msg, 'an bn');
|
|
20
23
|
lo = a;
|
|
21
24
|
hi = b;
|
|
@@ -110,4 +113,17 @@ export class Interval {
|
|
|
110
113
|
hi === INFINITY ? ')' : ']',
|
|
111
114
|
].join('');
|
|
112
115
|
}
|
|
116
|
+
|
|
117
|
+
overlaps(iv2) {
|
|
118
|
+
const msg = 'i6l.overlaps';
|
|
119
|
+
let { lo:lo1, hi:hi1 } = this;
|
|
120
|
+
let { lo:lo2, hi:hi2 } = iv2;
|
|
121
|
+
|
|
122
|
+
//console.log(msg, {lo1, lo2, hi1, hi2});
|
|
123
|
+
return (
|
|
124
|
+
(lo2 <= lo1 && lo1 <= hi2) ||
|
|
125
|
+
(lo2 <= hi1 && hi1 <= hi2) ||
|
|
126
|
+
(lo1 <= lo2 && lo2 <= hi1)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
113
129
|
}
|
|
@@ -73,9 +73,14 @@ export class ColorConsole {
|
|
|
73
73
|
a.push(label+color+thing+NO_COLOR);
|
|
74
74
|
}
|
|
75
75
|
break;
|
|
76
|
-
case 'number':
|
|
77
|
-
|
|
76
|
+
case 'number': {
|
|
77
|
+
let v = thing.toFixed(precision);
|
|
78
|
+
if (thing === Number(v)) {
|
|
79
|
+
v = v.replace(/\.?0+$/, '')
|
|
80
|
+
}
|
|
81
|
+
a.push(label+GREEN+v+NO_COLOR);
|
|
78
82
|
break;
|
|
83
|
+
}
|
|
79
84
|
default:
|
|
80
85
|
a.push(label+color+JSON.stringify(thing)+NO_COLOR);
|
|
81
86
|
break;
|