discombobulator 1.0.6 → 1.0.8

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": "discombobulator",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Discombobulator core library",
5
5
  "license": "ISC",
6
6
  "author": "Mark Webb",
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // An articulation is a modification to a note, such as an accent or roll.
4
4
 
5
- import util from "util";
5
+ // import util from "util";
6
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
6
7
 
7
8
  import { Element } from "./element.mjs";
8
9
 
@@ -21,7 +22,8 @@ export class Articulation extends Element {
21
22
  return "Articulation";
22
23
  }
23
24
 
24
- [util.inspect.custom](depth, opts) {
25
+ // [util.inspect.custom](depth, opts) {
26
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
25
27
  return `${this[Symbol.toStringTag]} {${
26
28
  !!this.#symbol ? this.#symbol.toString() : "undefined"
27
29
  }}`;
package/src/group.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // A group is a time-axis pattern that specifies how chords may be grouped.
4
4
 
5
- import util from "util";
5
+ // import util from "util";
6
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
6
7
 
7
8
  import { Element } from "./element.mjs";
8
9
 
@@ -56,7 +57,8 @@ export class Group extends Element {
56
57
  return description;
57
58
  }
58
59
 
59
- [util.inspect.custom](depth, opts) {
60
+ // [util.inspect.custom](depth, opts) {
61
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
60
62
  return `${this[Symbol.toStringTag]} {${this.#describe()}}`;
61
63
  }
62
64
 
package/src/groupset.mjs CHANGED
@@ -3,7 +3,8 @@
3
3
  // A group set is a set of groups, and allows patterns to be generated by
4
4
  // permutating the group set with a pattern set.
5
5
 
6
- import util from "util";
6
+ // import util from "util";
7
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
7
8
 
8
9
  import { bitCount, factorial } from "./util.mjs";
9
10
  import { permutations, permutationIndexGenerator } from "./permute.mjs";
@@ -60,13 +61,15 @@ export class GroupSet extends Set {
60
61
  let description = "";
61
62
 
62
63
  for (let pattern of this) {
63
- description += util.inspect(pattern);
64
+ // description += util.inspect(pattern);
65
+ description += inspect(pattern); // from Disco App (base44)
64
66
  }
65
67
 
66
68
  return description;
67
69
  }
68
70
 
69
- [util.inspect.custom](depth, opts) {
71
+ // [util.inspect.custom](depth, opts) {
72
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
70
73
  return `${this[Symbol.toStringTag]} {${this.#describe()}}`;
71
74
  }
72
75
 
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // An instrument is a playing surface that generates a note.
4
4
 
5
- import util from "util";
5
+ // import util from "util";
6
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
6
7
 
7
8
  import { Element } from "./element.mjs";
8
9
 
@@ -21,7 +22,8 @@ export class Instrument extends Element {
21
22
  return "Instrument";
22
23
  }
23
24
 
24
- [util.inspect.custom](depth, opts) {
25
+ // [util.inspect.custom](depth, opts) {
26
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
25
27
  return `Instrument {${
26
28
  !!this.#symbol ? this.#symbol.toString() : "undefined"
27
29
  }}`;
@@ -3,7 +3,8 @@
3
3
  // chords in a group varies based on another range, and all permutation of such groups
4
4
  // are generated.
5
5
 
6
- import util from "util";
6
+ // import util from "util";
7
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
7
8
 
8
9
  import { bitCount } from "./util.mjs";
9
10
  import { combinations, ithBinaryCombination } from "./permute.mjs";
@@ -103,11 +104,13 @@ export class IrregularGroupSet extends RegularGroupSet {
103
104
  );
104
105
  }
105
106
 
106
- [util.inspect.custom](depth, opts) {
107
+ // [util.inspect.custom](depth, opts) {
108
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
107
109
  let groups = "";
108
110
 
109
111
  for (const group of this) {
110
- groups += (groups.length == 0 ? "" : ", ") + util.inspect(group);
112
+ // groups += (groups.length == 0 ? "" : ", ") + util.inspect(group);
113
+ groups += (groups.length == 0 ? "" : ", ") + inspect(group);
111
114
  }
112
115
 
113
116
  return `${this[Symbol.toStringTag]} {[${groups}]}`;
package/src/note.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // A note is a tuple of an instrument and a set of articulations that affect how it's played.
4
4
 
5
- import util from "util";
5
+ // import util from "util";
6
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
6
7
 
7
8
  import { Element } from "./element.mjs";
8
9
  import { Instrument } from "./instrument.mjs";
@@ -87,11 +88,14 @@ export class Note extends Element {
87
88
  return this;
88
89
  }
89
90
 
90
- [util.inspect.custom](depth, opts) {
91
+ // [util.inspect.custom](depth, opts) {
92
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
91
93
  return `${this[Symbol.toStringTag]} {${
92
- !!this.#instrument ? util.inspect(this.#instrument) : "undefined"
94
+ // !!this.#instrument ? util.inspect(this.#instrument) : "undefined"
95
+ !!this.#instrument ? inspect(this.#instrument) : "undefined"
93
96
  }, {${
94
- !!this.#articulations ? util.inspect(this.#articulations) : "undefined"
97
+ // !!this.#articulations ? util.inspect(this.#articulations) : "undefined"
98
+ !!this.#articulations ? inspect(this.#articulations) : "undefined"
95
99
  }}}`;
96
100
  }
97
101
 
@@ -1,7 +1,8 @@
1
1
  // RegularGroupGenerator is a Group generator that generates fully active
2
2
  // groups in a range determined by boundaries and a step rate.
3
3
 
4
- import util from "util";
4
+ // import util from "util";
5
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
5
6
 
6
7
  import { bitCount } from "./util.mjs";
7
8
  import { Group } from "./group.mjs";
@@ -77,11 +78,13 @@ export class RegularGroupSet extends GroupSet {
77
78
  return "RegularGroupSet";
78
79
  }
79
80
 
80
- [util.inspect.custom](depth, opts) {
81
+ // [util.inspect.custom](depth, opts) {
82
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
81
83
  let groups = "";
82
84
 
83
85
  for (const group of this) {
84
- groups += (groups.length == 0 ? "" : ", ") + util.inspect(group);
86
+ // groups += (groups.length == 0 ? "" : ", ") + util.inspect(group);
87
+ groups += (groups.length == 0 ? "" : ", ") + inspect(group);
85
88
  }
86
89
 
87
90
  return `${this[Symbol.toStringTag]} {[${groups}]}`;
package/src/schedule.mjs CHANGED
@@ -7,7 +7,9 @@
7
7
  // The duration is used by Schema to calculate the duration of each chord in each
8
8
  // pattern.
9
9
 
10
- import util from "util";
10
+ // import util from "util";
11
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
12
+
11
13
  import Fraction from "fraction.js"
12
14
 
13
15
  import { Set } from "./set.mjs";
@@ -42,13 +44,15 @@ export class Schedule extends Set {
42
44
  let description = "";
43
45
 
44
46
  for (let patterns of this) {
45
- description += util.inspect(patterns);
47
+ // description += util.inspect(patterns);
48
+ description += inspect(patterns); // from Disco App (base44)
46
49
  }
47
50
 
48
51
  return description;
49
52
  }
50
53
 
51
- [util.inspect.custom](depth, opts) {
54
+ // [util.inspect.custom](depth, opts) {
55
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
52
56
  return `${this[Symbol.toStringTag]} {${this.#duration.toString()}, {${this.#describe()}}}`;
53
57
  }
54
58
 
package/src/set.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // Base class for sets and sequences.
4
4
 
5
- import util from "util";
5
+ // import util from "util";
6
+ import { inspect } from "./util-adapter.mjs"; // From Disco App (base44)
6
7
 
7
8
  import { Element } from "./element.mjs";
8
9
 
@@ -141,8 +142,10 @@ export class Set extends Element {
141
142
  if (this.isAbstract) throw new Error("Attempt to modify immutable set");
142
143
  }
143
144
 
144
- [util.inspect.custom](depth, opts) {
145
- return `${this[Symbol.toStringTag]} {${util.inspect(this.elements)}}`;
145
+ // [util.inspect.custom](depth, opts) {
146
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
147
+ // return `${this[Symbol.toStringTag]} {${util.inspect(this.elements)}}`;
148
+ return `${this[Symbol.toStringTag]} {${inspect(this.elements)}}`; // from Disco App (base44)
146
149
  }
147
150
 
148
151
  // Set generator/iterator. By default, just enumerate the elements in the set.
@@ -210,9 +213,11 @@ export class Set extends Element {
210
213
  return "SetOf";
211
214
  }
212
215
 
213
- [util.inspect.custom](depth, opts) {
214
- return `${this[Symbol.toStringTag]} {${util.inspect(this.#setof)}}`;
215
- }
216
+ // [util.inspect.custom](depth, opts) {
217
+ // return `${this[Symbol.toStringTag]} {${util.inspect(this.#setof)}}`;
218
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
219
+ return `${this[Symbol.toStringTag]} {${inspect(this.#setof)}}`;
220
+ }
216
221
 
217
222
  get name() {
218
223
  return this[util.inspect.custom]();
@@ -620,7 +625,9 @@ export class Set extends Element {
620
625
  return inspect;
621
626
  }
622
627
 
623
- [util.inspect.custom](depth, opts) {
628
+ // [util.inspect.custom](depth, opts) {
629
+ // return `${this[Symbol.toStringTag]} {${this.inspect()}}`;
630
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) { // from Disco App (base44)
624
631
  return `${this[Symbol.toStringTag]} {${this.inspect()}}`;
625
632
  }
626
633
 
@@ -687,11 +694,13 @@ export class Set extends Element {
687
694
  return this.elements[0];
688
695
  }
689
696
 
690
- [util.inspect.custom](depth, opts) {
697
+ // [util.inspect.custom](depth, opts) {
698
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) {
691
699
  let elements = "";
692
700
 
693
701
  for (const element of this) {
694
- elements += (elements.length == 0 ? "" : ", ") + util.inspect(element);
702
+ // elements += (elements.length == 0 ? "" : ", ") + util.inspect(element);
703
+ elements += (elements.length == 0 ? "" : ", ") + inspect(element);
695
704
  }
696
705
 
697
706
  return `${this[Symbol.toStringTag]} {[${elements}]}`;
@@ -774,7 +783,8 @@ export class Set extends Element {
774
783
  return inspect;
775
784
  }
776
785
 
777
- [util.inspect.custom](depth, opts) {
786
+ // [util.inspect.custom](depth, opts) {
787
+ [Symbol.for('nodejs.util.inspect.custom')](depth, opts) {
778
788
  return `${this[Symbol.toStringTag]} {${this.inspect()}}`;
779
789
  }
780
790
 
@@ -0,0 +1,21 @@
1
+ // Inserted from Disco App (base44)
2
+
3
+ // A browser-safe adapter for Node's util module
4
+ let inspect = (value) => String(value);
5
+
6
+ try {
7
+ // Dynamic import works in both Node (as of v12+) and browser environments
8
+ const util = await import('util');
9
+ inspect = util.inspect;
10
+ } catch (e) {
11
+ // Fallback for browsers
12
+ inspect = (value) => {
13
+ try {
14
+ return JSON.stringify(value, null, 2);
15
+ } catch (err) {
16
+ return String(value);
17
+ }
18
+ };
19
+ }
20
+
21
+ export { inspect };