@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sc-voice/tools",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "Utilities for SC-Voice",
5
5
  "main": "index.mjs",
6
6
  "files": [
@@ -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
- a.push(label+GREEN+thing.toFixed(precision)+NO_COLOR);
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;