discombobulator 1.0.6 → 1.0.7

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.7",
4
4
  "description": "Discombobulator core library",
5
5
  "license": "ISC",
6
6
  "author": "Mark Webb",
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 };