@sc-voice/tools 3.28.0 → 3.29.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 +26 -20
package/package.json
CHANGED
package/src/math/interval.mjs
CHANGED
|
@@ -3,11 +3,14 @@ const { EMPTY_SET, INFINITY } = Unicode;
|
|
|
3
3
|
import { ColorConsole } from '../text/color-console.mjs';
|
|
4
4
|
const { cc } = ColorConsole;
|
|
5
5
|
import { DBG } from '../defines.mjs';
|
|
6
|
+
import util from 'node:util';
|
|
6
7
|
|
|
7
8
|
const MINUS_INFINITY = `-${INFINITY}`;
|
|
8
9
|
const PLUS_INFINITY = `+${INFINITY}`;
|
|
9
10
|
|
|
10
11
|
export class Interval {
|
|
12
|
+
styleText = (text)=>text;
|
|
13
|
+
|
|
11
14
|
constructor(a, b, opts = {}) {
|
|
12
15
|
const msg = 'i6l.ctor';
|
|
13
16
|
let hi = null;
|
|
@@ -131,25 +134,28 @@ export class Interval {
|
|
|
131
134
|
|
|
132
135
|
toString() {
|
|
133
136
|
let { lo, hi, leftOpen, rightOpen, isEmpty } = this;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
let result = EMPTY_SET;
|
|
138
|
+
if (!isEmpty) {
|
|
139
|
+
if (lo === hi) {
|
|
140
|
+
result = [
|
|
141
|
+
leftOpen ? '(' : '[',
|
|
142
|
+
lo === INFINITY ? MINUS_INFINITY : lo,
|
|
143
|
+
lo == null ? '' : ',',
|
|
144
|
+
hi === INFINITY ? PLUS_INFINITY : hi,
|
|
145
|
+
rightOpen ? ')' : ']',
|
|
146
|
+
].join('');
|
|
147
|
+
} else {
|
|
148
|
+
result = [
|
|
149
|
+
leftOpen ? '(' : '[',
|
|
150
|
+
lo === INFINITY ? MINUS_INFINITY : lo,
|
|
151
|
+
lo === hi ? '' : ',',
|
|
152
|
+
hi === INFINITY ? PLUS_INFINITY : hi,
|
|
153
|
+
rightOpen ? ')' : ']',
|
|
154
|
+
].join('');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return Interval.styleText ? Interval.styleText(result) : result;
|
|
153
159
|
}
|
|
154
160
|
|
|
155
161
|
overlaps(iv2) {
|
|
@@ -189,4 +195,4 @@ export class Interval {
|
|
|
189
195
|
dbg && cc.fyi1(msg + 0.1, false);
|
|
190
196
|
return false;
|
|
191
197
|
}
|
|
192
|
-
}
|
|
198
|
+
} // Interval
|