@daneren2005/shared-memory-objects 0.0.13 → 0.0.15

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.
@@ -1,31 +1,31 @@
1
- const ie = 20, se = 12, J = Math.pow(2, 20), Q = Math.pow(2, 12);
2
- function c(s, t = 0) {
3
- return A(Atomics.load(s, t));
1
+ const he = 20, ce = 12, rt = Math.pow(2, 20), it = Math.pow(2, 12);
2
+ function c(i, t = 0) {
3
+ return g(Atomics.load(i, t));
4
4
  }
5
- function O(s, t = 0) {
6
- return Atomics.load(s, t);
5
+ function O(i, t = 0) {
6
+ return Atomics.load(i, t);
7
7
  }
8
- function m(s, t = 0, e, r) {
9
- Atomics.store(s, t, T(e, r));
8
+ function m(i, t = 0, e, r) {
9
+ Atomics.store(i, t, T(e, r));
10
10
  }
11
- function W(s, t = 0, e) {
12
- Atomics.store(s, t, e);
11
+ function j(i, t = 0, e) {
12
+ Atomics.store(i, t, e);
13
13
  }
14
- function oe(s, t, e, r, i, o) {
15
- let a = T(i, o);
16
- return Atomics.compareExchange(s, t, a, T(e, r)) === a;
14
+ function ue(i, t, e, r, s, o) {
15
+ let n = T(s, o);
16
+ return Atomics.compareExchange(i, t, n, T(e, r)) === n;
17
17
  }
18
- function z(s, t, e, r) {
19
- return Atomics.compareExchange(s, t, r, e) === r;
18
+ function H(i, t, e, r) {
19
+ return Atomics.compareExchange(i, t, r, e) === r;
20
20
  }
21
- function A(s) {
21
+ function g(i) {
22
22
  return {
23
- bufferPosition: s & 4095,
24
- bufferByteOffset: s >>> 12
23
+ bufferPosition: i & 4095,
24
+ bufferByteOffset: i >>> 12
25
25
  };
26
26
  }
27
- function T(s, t) {
28
- return s + (t << 12);
27
+ function T(i, t) {
28
+ return i + (t << 12);
29
29
  }
30
30
  class h {
31
31
  memory;
@@ -60,15 +60,15 @@ class h {
60
60
  };
61
61
  }
62
62
  }
63
- const v = 0, F = 1;
64
- function x(s, t = 0) {
65
- for (; Atomics.compareExchange(s, t, v, F) !== v; )
66
- "WorkerGlobalScope" in self && Atomics.wait(s, t, F);
63
+ const q = 0, D = 1;
64
+ function x(i, t = 0) {
65
+ for (; Atomics.compareExchange(i, t, q, D) !== q; )
66
+ "WorkerGlobalScope" in self && Atomics.wait(i, t, D);
67
67
  }
68
- function k(s, t = 0) {
69
- Atomics.compareExchange(s, t, F, v) !== F && console.warn("We are unlocking when it was not locked!"), Atomics.notify(s, t);
68
+ function A(i, t = 0) {
69
+ Atomics.compareExchange(i, t, D, q) !== D && console.warn("We are unlocking when it was not locked!"), Atomics.notify(i, t);
70
70
  }
71
- const ae = 1, Ft = {
71
+ const ye = 1, Vt = {
72
72
  5120: "i8",
73
73
  5121: "u8",
74
74
  5122: "i16",
@@ -76,35 +76,35 @@ const ae = 1, Ft = {
76
76
  5124: "i32",
77
77
  5125: "u32",
78
78
  5126: "f32"
79
- }, xt = {
79
+ }, Kt = {
80
80
  f32: Float32Array,
81
81
  f64: Float64Array
82
- }, Rt = {
82
+ }, Gt = {
83
83
  i8: Int8Array,
84
84
  i16: Int16Array,
85
85
  i32: Int32Array
86
- }, $t = {
86
+ }, Xt = {
87
87
  u8: Uint8Array,
88
88
  u8c: Uint8ClampedArray,
89
89
  u16: Uint16Array,
90
90
  u32: Uint32Array
91
- }, zt = {
91
+ }, Zt = {
92
92
  i64: BigInt64Array,
93
93
  u64: BigUint64Array
94
- }, Yt = {
95
- ...xt,
96
- ...Rt,
97
- ...$t
98
- }, Ht = (s) => {
99
- const t = Ft[s];
100
- return t !== void 0 ? t : s;
94
+ }, Wt = {
95
+ ...Kt,
96
+ ...Gt,
97
+ ...Xt
98
+ }, vt = (i) => {
99
+ const t = Vt[i];
100
+ return t !== void 0 ? t : i;
101
101
  };
102
- function Kt(s, ...t) {
103
- const e = zt[s];
104
- return new (e || Yt[Ht(s)])(...t);
102
+ function jt(i, ...t) {
103
+ const e = Zt[i];
104
+ return new (e || Wt[vt(i)])(...t);
105
105
  }
106
- const tt = 0, et = 1, rt = 2, it = 3, st = 4, g = 5, ot = 6, Y = 1, H = 2, at = 32, K = 0, G = 1, d = 8;
107
- class V {
106
+ const st = 0, ot = 1, nt = 2, at = 3, ft = 4, k = 5, lt = 6, V = 1, K = 2, ht = 32, G = 0, X = 1, y = 8;
107
+ class Z {
108
108
  buf;
109
109
  start;
110
110
  u8;
@@ -112,29 +112,29 @@ class V {
112
112
  state;
113
113
  lock;
114
114
  constructor(t = {}) {
115
- if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = t.start != null ? N(Math.max(t.start, 0), 4) : 0, this.u8 = new Uint8Array(this.buf), this.u32 = new Uint32Array(this.buf), this.state = new Uint32Array(this.buf, this.start, at / 4), this.lock = new Int32Array(this.buf, this.start + this.state.byteLength - 4, 1), !t.skipInitialization) {
115
+ if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = t.start != null ? P(Math.max(t.start, 0), 4) : 0, this.u8 = new Uint8Array(this.buf), this.u32 = new Uint32Array(this.buf), this.state = new Uint32Array(this.buf, this.start, ht / 4), this.lock = new Int32Array(this.buf, this.start + this.state.byteLength - 4, 1), !t.skipInitialization) {
116
116
  const e = t.align || 8;
117
117
  if (e < 8)
118
118
  throw new Error(`invalid alignment: ${e}, must be a pow2 and >= 8`);
119
- const r = this.initialTop(e), i = t.end != null ? Math.min(t.end, this.buf.byteLength) : this.buf.byteLength;
120
- if (r >= i)
119
+ const r = this.initialTop(e), s = t.end != null ? Math.min(t.end, this.buf.byteLength) : this.buf.byteLength;
120
+ if (r >= s)
121
121
  throw new Error(
122
122
  `insufficient address range (0x${this.start.toString(
123
123
  16
124
- )} - 0x${i.toString(16)})`
124
+ )} - 0x${s.toString(16)})`
125
125
  );
126
- this.align = e, this.doCompact = t.compact !== !1, this.doSplit = t.split !== !1, this.minSplit = t.minSplit || 16, this.end = i, this.top = r, this._free = 0, this._used = 0;
126
+ this.align = e, this.doCompact = t.compact !== !1, this.doSplit = t.split !== !1, this.minSplit = t.minSplit || 16, this.end = s, this.top = r, this._free = 0, this._used = 0;
127
127
  }
128
128
  }
129
129
  stats() {
130
130
  const t = (r) => {
131
- let i = 0, o = 0;
131
+ let s = 0, o = 0;
132
132
  for (; r; )
133
- if (i++, o += this.blockSize(r), r = this.blockNext(r), r > this.end) {
133
+ if (s++, o += this.blockSize(r), r = this.blockNext(r), r > this.end) {
134
134
  console.error(`Trying to get stats for block past end of buffer: ${r} > ${this.end}`);
135
135
  break;
136
136
  }
137
- return { count: i, size: o };
137
+ return { count: s, size: o };
138
138
  }, e = t(this._free);
139
139
  return {
140
140
  free: e,
@@ -145,12 +145,12 @@ class V {
145
145
  };
146
146
  }
147
147
  callocAs(t, e, r = 0) {
148
- const i = this.mallocAs(t, e);
149
- return i && i.fill(r), i;
148
+ const s = this.mallocAs(t, e);
149
+ return s && s.fill(r), s;
150
150
  }
151
151
  mallocAs(t, e) {
152
- const r = this.malloc(e * Gt[t]);
153
- return r ? Kt(t, this.buf, r, e) : void 0;
152
+ const r = this.malloc(e * qt[t]);
153
+ return r ? jt(t, this.buf, r, e) : void 0;
154
154
  }
155
155
  calloc(t, e = 0) {
156
156
  const r = this.malloc(t);
@@ -160,67 +160,67 @@ class V {
160
160
  if (t <= 0)
161
161
  return 0;
162
162
  x(this.lock);
163
- const e = N(t + d, this.align), r = this.end;
164
- let i = this.top, o = this._free, a = 0;
163
+ const e = P(t + y, this.align), r = this.end;
164
+ let s = this.top, o = this._free, n = 0;
165
165
  for (; o; ) {
166
- const f = this.blockSize(o), n = o + f >= i;
167
- if (n || f >= e) {
166
+ const f = this.blockSize(o), a = o + f >= s;
167
+ if (a || f >= e) {
168
168
  let l = this.mallocTop(
169
169
  o,
170
- a,
170
+ n,
171
171
  f,
172
172
  e,
173
- n
173
+ a
174
174
  );
175
- return k(this.lock), l;
175
+ return A(this.lock), l;
176
176
  }
177
- a = o, o = this.blockNext(o);
177
+ n = o, o = this.blockNext(o);
178
178
  }
179
- if (o = i, i = o + e, i <= r) {
180
- this.initBlock(o, e, this._used), this._used = o, this.top = i;
179
+ if (o = s, s = o + e, s <= r) {
180
+ this.initBlock(o, e, this._used), this._used = o, this.top = s;
181
181
  let f = _(o);
182
- return k(this.lock), f;
182
+ return A(this.lock), f;
183
183
  }
184
- return k(this.lock), 0;
184
+ return A(this.lock), 0;
185
185
  }
186
- mallocTop(t, e, r, i, o) {
187
- if (o && t + i > this.end) return 0;
186
+ mallocTop(t, e, r, s, o) {
187
+ if (o && t + s > this.end) return 0;
188
188
  if (e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t), this.setBlockNext(t, this._used), this._used = t, o)
189
- this.top = t + this.setBlockSize(t, i);
189
+ this.top = t + this.setBlockSize(t, s);
190
190
  else if (this.doSplit) {
191
- const a = r - i;
192
- a >= this.minSplit && this.splitBlock(t, i, a);
191
+ const n = r - s;
192
+ n >= this.minSplit && this.splitBlock(t, s, n);
193
193
  }
194
194
  return _(t);
195
195
  }
196
196
  realloc(t, e) {
197
197
  if (e <= 0)
198
198
  return 0;
199
- const r = P(t);
200
- let i = 0, o = this._used, a = 0;
199
+ const r = I(t);
200
+ let s = 0, o = this._used, n = 0;
201
201
  for (; o; ) {
202
202
  if (o === r) {
203
- [i, a] = this.reallocBlock(o, e);
203
+ [s, n] = this.reallocBlock(o, e);
204
204
  break;
205
205
  }
206
206
  o = this.blockNext(o);
207
207
  }
208
- return i && i !== r && this.u8.copyWithin(
209
- _(i),
208
+ return s && s !== r && this.u8.copyWithin(
209
+ _(s),
210
210
  _(r),
211
- a
212
- ), _(i);
211
+ n
212
+ ), _(s);
213
213
  }
214
214
  reallocBlock(t, e) {
215
- const r = this.blockSize(t), i = t + r, o = i >= this.top, a = N(e + d, this.align);
216
- if (a <= r) {
215
+ const r = this.blockSize(t), s = t + r, o = s >= this.top, n = P(e + y, this.align);
216
+ if (n <= r) {
217
217
  if (this.doSplit) {
218
- const f = r - a;
219
- f >= this.minSplit ? this.splitBlock(t, a, f) : o && (this.top = t + a);
220
- } else o && (this.top = t + a);
221
- return [t, i];
218
+ const f = r - n;
219
+ f >= this.minSplit ? this.splitBlock(t, n, f) : o && (this.top = t + n);
220
+ } else o && (this.top = t + n);
221
+ return [t, s];
222
222
  }
223
- return o && t + a < this.end ? (this.top = t + this.setBlockSize(t, a), [t, i]) : (this.free(t), [P(this.malloc(e)), i]);
223
+ return o && t + n < this.end ? (this.top = t + this.setBlockSize(t, n), [t, s]) : (this.free(t), [I(this.malloc(e)), s]);
224
224
  }
225
225
  reallocArray(t, e) {
226
226
  if (t.buffer !== this.buf)
@@ -239,11 +239,11 @@ class V {
239
239
  e = t.byteOffset;
240
240
  } else
241
241
  e = t;
242
- e = P(e);
242
+ e = I(e);
243
243
  let r = this._used;
244
244
  for (; r; ) {
245
245
  if (r === e)
246
- return this.blockSize(e) - d;
246
+ return this.blockSize(e) - y;
247
247
  r = this.blockNext(r);
248
248
  }
249
249
  }
@@ -260,14 +260,14 @@ class V {
260
260
  e = t.byteOffset;
261
261
  } else
262
262
  e = t;
263
- x(this.lock), e = P(e);
264
- let r = this._used, i = 0;
263
+ x(this.lock), e = I(e);
264
+ let r = this._used, s = 0;
265
265
  for (; r; ) {
266
266
  if (r === e)
267
- return i ? this.unlinkBlock(i, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(), k(this.lock), !0;
268
- i = r, r = this.blockNext(r);
267
+ return s ? this.unlinkBlock(s, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(), A(this.lock), !0;
268
+ s = r, r = this.blockNext(r);
269
269
  }
270
- return k(this.lock), !1;
270
+ return A(this.lock), !1;
271
271
  }
272
272
  freeAll() {
273
273
  this._free = 0, this._used = 0, this.top = this.initialTop();
@@ -276,57 +276,57 @@ class V {
276
276
  return delete this.u8, delete this.u32, delete this.state, delete this.buf, !0;
277
277
  }
278
278
  get align() {
279
- return this.state[st];
279
+ return this.state[ft];
280
280
  }
281
281
  set align(t) {
282
- this.state[st] = t;
282
+ this.state[ft] = t;
283
283
  }
284
284
  get end() {
285
- return this.state[it];
285
+ return this.state[at];
286
286
  }
287
287
  set end(t) {
288
- this.state[it] = t;
288
+ this.state[at] = t;
289
289
  }
290
290
  get top() {
291
- return Atomics.load(this.state, rt);
291
+ return Atomics.load(this.state, nt);
292
292
  }
293
293
  set top(t) {
294
- Atomics.store(this.state, rt, t);
294
+ Atomics.store(this.state, nt, t);
295
295
  }
296
296
  get _free() {
297
- return Atomics.load(this.state, tt);
297
+ return Atomics.load(this.state, st);
298
298
  }
299
299
  set _free(t) {
300
- Atomics.store(this.state, tt, t);
300
+ Atomics.store(this.state, st, t);
301
301
  }
302
302
  get _used() {
303
- return Atomics.load(this.state, et);
303
+ return Atomics.load(this.state, ot);
304
304
  }
305
305
  set _used(t) {
306
- Atomics.store(this.state, et, t);
306
+ Atomics.store(this.state, ot, t);
307
307
  }
308
308
  get doCompact() {
309
- return !!(this.state[g] & Y);
309
+ return !!(this.state[k] & V);
310
310
  }
311
311
  set doCompact(t) {
312
- t ? this.state[g] |= 1 << Y - 1 : this.state[g] &= ~Y;
312
+ t ? this.state[k] |= 1 << V - 1 : this.state[k] &= ~V;
313
313
  }
314
314
  get doSplit() {
315
- return !!(this.state[g] & H);
315
+ return !!(this.state[k] & K);
316
316
  }
317
317
  set doSplit(t) {
318
- t ? this.state[g] |= 1 << H - 1 : this.state[g] &= ~H;
318
+ t ? this.state[k] |= 1 << K - 1 : this.state[k] &= ~K;
319
319
  }
320
320
  get minSplit() {
321
- return this.state[ot];
321
+ return this.state[lt];
322
322
  }
323
323
  set minSplit(t) {
324
- if (t <= d)
325
- throw new Error(`illegal min split threshold: ${t}, require at least ${d + 1}`);
326
- this.state[ot] = t;
324
+ if (t <= y)
325
+ throw new Error(`illegal min split threshold: ${t}, require at least ${y + 1}`);
326
+ this.state[lt] = t;
327
327
  }
328
328
  blockSize(t) {
329
- return Atomics.load(this.u32, (t >> 2) + K);
329
+ return Atomics.load(this.u32, (t >> 2) + G);
330
330
  }
331
331
  /**
332
332
  * Sets & returns given block size.
@@ -335,10 +335,10 @@ class V {
335
335
  * @param size -
336
336
  */
337
337
  setBlockSize(t, e) {
338
- return Atomics.store(this.u32, (t >> 2) + K, e), e;
338
+ return Atomics.store(this.u32, (t >> 2) + G, e), e;
339
339
  }
340
340
  blockNext(t) {
341
- return Atomics.load(this.u32, (t >> 2) + G);
341
+ return Atomics.load(this.u32, (t >> 2) + X);
342
342
  }
343
343
  /**
344
344
  * Sets block next pointer to `next`. Use zero to indicate list end.
@@ -346,7 +346,7 @@ class V {
346
346
  * @param block -
347
347
  */
348
348
  setBlockNext(t, e) {
349
- Atomics.store(this.u32, (t >> 2) + G, e);
349
+ Atomics.store(this.u32, (t >> 2) + X, e);
350
350
  }
351
351
  /**
352
352
  * Initializes block header with given `size` and `next` pointer. Returns `block`.
@@ -356,8 +356,8 @@ class V {
356
356
  * @param next -
357
357
  */
358
358
  initBlock(t, e, r) {
359
- const i = t >>> 2;
360
- return Atomics.store(this.u32, i + K, e), Atomics.store(this.u32, i + G, r), t;
359
+ const s = t >>> 2;
360
+ return Atomics.store(this.u32, s + G, e), Atomics.store(this.u32, s + X, r), t;
361
361
  }
362
362
  unlinkBlock(t, e) {
363
363
  this.setBlockNext(t, this.blockNext(e));
@@ -372,7 +372,7 @@ class V {
372
372
  ), this.doCompact && this.compact();
373
373
  }
374
374
  initialTop(t = this.align) {
375
- return N(this.start + at + d, t) - d;
375
+ return P(this.start + ht + y, t) - y;
376
376
  }
377
377
  /**
378
378
  * Traverses free list and attempts to recursively merge blocks
@@ -380,18 +380,18 @@ class V {
380
380
  * have been merged. Only called if `compact` option is enabled.
381
381
  */
382
382
  compact() {
383
- let t = this._free, e = 0, r = 0, i, o = !1;
383
+ let t = this._free, e = 0, r = 0, s, o = !1;
384
384
  for (; t; ) {
385
- for (i = t, r = this.blockNext(t); r && i + this.blockSize(i) === r; )
386
- i = r, r = this.blockNext(r);
387
- if (i !== t) {
388
- const a = i - t + this.blockSize(i);
389
- this.setBlockSize(t, a);
390
- const f = this.blockNext(i);
391
- let n = this.blockNext(t);
392
- for (; n && n !== f; ) {
393
- const l = this.blockNext(n);
394
- this.setBlockNext(n, 0), n = l;
385
+ for (s = t, r = this.blockNext(t); r && s + this.blockSize(s) === r; )
386
+ s = r, r = this.blockNext(r);
387
+ if (s !== t) {
388
+ const n = s - t + this.blockSize(s);
389
+ this.setBlockSize(t, n);
390
+ const f = this.blockNext(s);
391
+ let a = this.blockNext(t);
392
+ for (; a && a !== f; ) {
393
+ const l = this.blockNext(a);
394
+ this.setBlockNext(a, 0), a = l;
395
395
  }
396
396
  this.setBlockNext(t, f), o = !0;
397
397
  }
@@ -411,7 +411,7 @@ class V {
411
411
  r ? this.setBlockNext(r, t) : this._free = t, this.setBlockNext(t, e);
412
412
  }
413
413
  }
414
- const _ = (s) => s > 0 ? s + d : 0, P = (s) => s > 0 ? s - d : 0, N = (s, t) => (t--, s + t & ~t), Gt = {
414
+ const _ = (i) => i > 0 ? i + y : 0, I = (i) => i > 0 ? i - y : 0, P = (i, t) => (t--, i + t & ~t), qt = {
415
415
  u8: 1,
416
416
  u8c: 1,
417
417
  i8: 1,
@@ -423,7 +423,7 @@ const _ = (s) => s > 0 ? s + d : 0, P = (s) => s > 0 ? s - d : 0, N = (s, t) =>
423
423
  u64: 8,
424
424
  f32: 4,
425
425
  f64: 8
426
- }, Vt = [
426
+ }, Jt = [
427
427
  "B",
428
428
  "kB",
429
429
  "MB",
@@ -433,7 +433,7 @@ const _ = (s) => s > 0 ? s + d : 0, P = (s) => s > 0 ? s - d : 0, N = (s, t) =>
433
433
  "EB",
434
434
  "ZB",
435
435
  "YB"
436
- ], Xt = [
436
+ ], Qt = [
437
437
  "B",
438
438
  "KiB",
439
439
  "MiB",
@@ -443,7 +443,7 @@ const _ = (s) => s > 0 ? s + d : 0, P = (s) => s > 0 ? s - d : 0, N = (s, t) =>
443
443
  "EiB",
444
444
  "ZiB",
445
445
  "YiB"
446
- ], Zt = [
446
+ ], te = [
447
447
  "b",
448
448
  "kbit",
449
449
  "Mbit",
@@ -453,7 +453,7 @@ const _ = (s) => s > 0 ? s + d : 0, P = (s) => s > 0 ? s - d : 0, N = (s, t) =>
453
453
  "Ebit",
454
454
  "Zbit",
455
455
  "Ybit"
456
- ], Wt = [
456
+ ], ee = [
457
457
  "b",
458
458
  "kibit",
459
459
  "Mibit",
@@ -463,27 +463,27 @@ const _ = (s) => s > 0 ? s + d : 0, P = (s) => s > 0 ? s - d : 0, N = (s, t) =>
463
463
  "Eibit",
464
464
  "Zibit",
465
465
  "Yibit"
466
- ], nt = (s, t, e) => {
467
- let r = s;
468
- return typeof t == "string" || Array.isArray(t) ? r = s.toLocaleString(t, e) : (t === !0 || e !== void 0) && (r = s.toLocaleString(void 0, e)), r;
469
- }, wt = (s) => {
470
- if (typeof s == "number")
471
- return Math.log10(s);
472
- const t = s.toString(10);
466
+ ], ct = (i, t, e) => {
467
+ let r = i;
468
+ return typeof t == "string" || Array.isArray(t) ? r = i.toLocaleString(t, e) : (t === !0 || e !== void 0) && (r = i.toLocaleString(void 0, e)), r;
469
+ }, _t = (i) => {
470
+ if (typeof i == "number")
471
+ return Math.log10(i);
472
+ const t = i.toString(10);
473
473
  return t.length + Math.log10(`0.${t.slice(0, 15)}`);
474
- }, vt = (s) => typeof s == "number" ? Math.log(s) : wt(s) * Math.log(10), jt = (s, t) => {
475
- if (typeof s == "number")
476
- return s / t;
477
- const e = s / BigInt(t), r = s % BigInt(t);
474
+ }, re = (i) => typeof i == "number" ? Math.log(i) : _t(i) * Math.log(10), ie = (i, t) => {
475
+ if (typeof i == "number")
476
+ return i / t;
477
+ const e = i / BigInt(t), r = i % BigInt(t);
478
478
  return Number(e) + Number(r) / t;
479
- }, ft = (s, t) => {
479
+ }, ut = (i, t) => {
480
480
  if (t === void 0)
481
- return s;
481
+ return i;
482
482
  if (typeof t != "number" || !Number.isSafeInteger(t) || t < 0)
483
483
  throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof t}: ${t}`);
484
- return t === 0 ? s : s.length < t ? s.padStart(t, " ") : s;
485
- }, qt = (s) => {
486
- const { minimumFractionDigits: t, maximumFractionDigits: e } = s;
484
+ return t === 0 ? i : i.length < t ? i.padStart(t, " ") : i;
485
+ }, se = (i) => {
486
+ const { minimumFractionDigits: t, maximumFractionDigits: e } = i;
487
487
  if (!(t === void 0 && e === void 0))
488
488
  return {
489
489
  ...t !== void 0 && { minimumFractionDigits: t },
@@ -491,9 +491,9 @@ const _ = (s) => s > 0 ? s + d : 0, P = (s) => s > 0 ? s - d : 0, N = (s, t) =>
491
491
  roundingMode: "trunc"
492
492
  };
493
493
  };
494
- function Jt(s, t) {
495
- if (typeof s != "bigint" && !Number.isFinite(s))
496
- throw new TypeError(`Expected a finite number, got ${typeof s}: ${s}`);
494
+ function oe(i, t) {
495
+ if (typeof i != "bigint" && !Number.isFinite(i))
496
+ throw new TypeError(`Expected a finite number, got ${typeof i}: ${i}`);
497
497
  t = {
498
498
  bits: !1,
499
499
  binary: !1,
@@ -501,41 +501,41 @@ function Jt(s, t) {
501
501
  nonBreakingSpace: !1,
502
502
  ...t
503
503
  };
504
- const e = t.bits ? t.binary ? Wt : Zt : t.binary ? Xt : Vt, r = t.space ? t.nonBreakingSpace ? " " : " " : "", i = typeof s == "number" ? s === 0 : s === 0n;
505
- if (t.signed && i) {
504
+ const e = t.bits ? t.binary ? ee : te : t.binary ? Qt : Jt, r = t.space ? t.nonBreakingSpace ? " " : " " : "", s = typeof i == "number" ? i === 0 : i === 0n;
505
+ if (t.signed && s) {
506
506
  const l = ` 0${r}${e[0]}`;
507
- return ft(l, t.fixedWidth);
508
- }
509
- const o = s < 0, a = o ? "-" : t.signed ? "+" : "";
510
- o && (s = -s);
511
- const f = qt(t);
512
- let n;
513
- if (s < 1) {
514
- const l = nt(s, t.locale, f);
515
- n = a + l + r + e[0];
507
+ return ut(l, t.fixedWidth);
508
+ }
509
+ const o = i < 0, n = o ? "-" : t.signed ? "+" : "";
510
+ o && (i = -i);
511
+ const f = se(t);
512
+ let a;
513
+ if (i < 1) {
514
+ const l = ct(i, t.locale, f);
515
+ a = n + l + r + e[0];
516
516
  } else {
517
- const l = Math.min(Math.floor(t.binary ? vt(s) / Math.log(1024) : wt(s) / 3), e.length - 1);
518
- if (s = jt(s, (t.binary ? 1024 : 1e3) ** l), !f) {
519
- const M = Math.max(3, Math.floor(s).toString().length);
520
- s = s.toPrecision(M);
517
+ const l = Math.min(Math.floor(t.binary ? re(i) / Math.log(1024) : _t(i) / 3), e.length - 1);
518
+ if (i = ie(i, (t.binary ? 1024 : 1e3) ** l), !f) {
519
+ const M = Math.max(3, Math.floor(i).toString().length);
520
+ i = i.toPrecision(M);
521
521
  }
522
- const S = nt(Number(s), t.locale, f), $ = e[l];
523
- n = a + S + r + $;
522
+ const S = ct(Number(i), t.locale, f), Y = e[l];
523
+ a = n + S + r + Y;
524
524
  }
525
- return ft(n, t.fixedWidth);
525
+ return ut(a, t.fixedWidth);
526
526
  }
527
- const Qt = 8192, lt = 0, X = 1, U = 2;
528
- class ne {
527
+ const ne = 8192, yt = 0, W = 1, N = 2;
528
+ class de {
529
529
  buffers;
530
530
  onGrowBufferHandlers = [];
531
531
  isClone;
532
532
  memory;
533
533
  get bufferSize() {
534
- return this.memory.data[lt];
534
+ return this.memory.data[yt];
535
535
  }
536
536
  constructor(t) {
537
537
  if (t && "buffers" in t)
538
- this.buffers = t.buffers.map((e) => new V({
538
+ this.buffers = t.buffers.map((e) => new Z({
539
539
  buf: e,
540
540
  skipInitialization: !0
541
541
  })), this.memory = new h(this, {
@@ -544,35 +544,35 @@ class ne {
544
544
  }), this.isClone = !0;
545
545
  else {
546
546
  "SharedArrayBuffer" in globalThis || console.warn("SharedArrayBuffer is not working: falling back to ArrayBuffer");
547
- const e = t?.bufferSize ?? Qt;
548
- if (e > J)
549
- throw new Error(`Buffer size ${e} is greater than max ${J} that we can reference with pointers`);
547
+ const e = t?.bufferSize ?? ne;
548
+ if (e > rt)
549
+ throw new Error(`Buffer size ${e} is greater than max ${rt} that we can reference with pointers`);
550
550
  let r = this.createBuffer(e);
551
551
  this.buffers = [
552
552
  r
553
553
  ];
554
- const i = r.callocAs("u32", 3);
555
- if (i)
554
+ const s = r.callocAs("u32", 3);
555
+ if (s)
556
556
  this.memory = new h(this, {
557
557
  bufferPosition: 0,
558
- bufferByteOffset: i.byteOffset
558
+ bufferByteOffset: s.byteOffset
559
559
  });
560
560
  else
561
561
  throw new Error("Failed to initialize first byte from buffer");
562
- this.memory.data[lt] = e, this.memory.data[X] = 1, this.memory.data[U] = t?.autoGrowSize ?? 100, this.isClone = !1;
562
+ this.memory.data[yt] = e, this.memory.data[W] = 1, this.memory.data[N] = t?.autoGrowSize ?? 100, this.isClone = !1;
563
563
  for (let o = 1; o < (t?.initialBuffers ?? 1); o++)
564
564
  this.buffers.push(this.createBuffer(e));
565
565
  }
566
566
  }
567
567
  addSharedBuffer(t) {
568
- this.buffers[t.bufferPosition] = new V({
568
+ this.buffers[t.bufferPosition] = new Z({
569
569
  buf: t.buffer,
570
570
  skipInitialization: !0
571
571
  });
572
572
  }
573
573
  growBuffer() {
574
574
  const t = this.createBuffer();
575
- let e = Atomics.add(this.memory.data, X, 1);
575
+ let e = Atomics.add(this.memory.data, W, 1);
576
576
  return this.buffers[e] = t, this.onGrowBufferHandlers.forEach((r) => r({
577
577
  bufferPosition: e,
578
578
  buffer: t.buf
@@ -581,7 +581,7 @@ class ne {
581
581
  createBuffer(t) {
582
582
  const e = t ?? this.bufferSize;
583
583
  let r;
584
- return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new V({
584
+ return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new Z({
585
585
  buf: r,
586
586
  // We can't use this unless we can 100% guarantee that every thread will stop using memory the instant it is freed
587
587
  // ex: Allocate 16 bytes. Thread A frees that allocation and then allocates 12 bytes and 4 bytes, but Thread B is mid-execution on the old allocation can changes the internal state of the 4-byte allocation breaking everything
@@ -595,19 +595,19 @@ class ne {
595
595
  }
596
596
  allocUI32(t) {
597
597
  t = Math.ceil(t);
598
- for (let i = 0; i < this.buffers.length; i++) {
599
- const o = this.buffers[i];
598
+ for (let s = 0; s < this.buffers.length; s++) {
599
+ const o = this.buffers[s];
600
600
  if (!o)
601
601
  continue;
602
- const a = o.callocAs("u32", t);
603
- if (a)
604
- return i === this.buffers.length - 1 && Atomics.load(this.memory.data, X) === this.buffers.length && this.memory.data[U] < 100 && this.memory.data[U] > 0 && o.top / o.end > this.memory.data[U] / 100 && this.growBuffer(), new h(this, {
605
- data: a,
602
+ const n = o.callocAs("u32", t);
603
+ if (n)
604
+ return s === this.buffers.length - 1 && Atomics.load(this.memory.data, W) === this.buffers.length && this.memory.data[N] < 100 && this.memory.data[N] > 0 && o.top / o.end > this.memory.data[N] / 100 && this.growBuffer(), new h(this, {
605
+ data: n,
606
606
  buffer: o
607
607
  });
608
608
  }
609
- if (this.buffers.length >= Q)
610
- throw new Error(`Can't initialize a new buffer since it would have a position greater than the max of ${Q}`);
609
+ if (this.buffers.length >= it)
610
+ throw new Error(`Can't initialize a new buffer since it would have a position greater than the max of ${it}`);
611
611
  let e = this.growBuffer();
612
612
  const r = e.callocAs("u32", t);
613
613
  if (r)
@@ -628,7 +628,7 @@ class ne {
628
628
  return this.buffers[0].buf.byteLength * this.buffers.length;
629
629
  }
630
630
  prettyMemory() {
631
- return `${ht(this.currentUsed)} / ${ht(this.totalAllocated)}`;
631
+ return `${dt(this.currentUsed)} / ${dt(this.totalAllocated)}`;
632
632
  }
633
633
  getSharedMemory() {
634
634
  return {
@@ -636,16 +636,16 @@ class ne {
636
636
  };
637
637
  }
638
638
  }
639
- function ht(s) {
640
- return Jt(s, {
639
+ function dt(i) {
640
+ return oe(i, {
641
641
  binary: !0,
642
642
  minimumFractionDigits: 1,
643
643
  maximumFractionDigits: 1
644
644
  });
645
645
  }
646
- const ct = 4, ut = 1, E = 2;
646
+ const Bt = 4, mt = 1, E = 2;
647
647
  class u {
648
- static ALLOCATE_COUNT = ct;
648
+ static ALLOCATE_COUNT = Bt;
649
649
  memory;
650
650
  /* First block
651
651
  32 index 0
@@ -688,7 +688,7 @@ class u {
688
688
  if (this.memory = t, e && "firstBlock" in e)
689
689
  this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (E + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
690
690
  else {
691
- e && e.initWithBlock ? this.firstBlock = new h(t, e.initWithBlock) : this.firstBlock = t.allocUI32(ct), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (E + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
691
+ e && e.initWithBlock ? this.firstBlock = new h(t, e.initWithBlock) : this.firstBlock = t.allocUI32(Bt), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (E + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
692
692
  const r = e?.type ?? Uint32Array;
693
693
  r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2), this.dataLength = e?.dataLength ?? 1;
694
694
  }
@@ -698,23 +698,23 @@ class u {
698
698
  let e = this.dataLength;
699
699
  if (t.length > e)
700
700
  throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
701
- let r = this.memory.allocUI32(ut + e), i = this.getDataBlock(r.data), o = r.pointer;
702
- for (let n = 0; n < t.length; n++)
703
- i instanceof Int32Array || i instanceof Uint32Array ? Atomics.store(i, n, t[n]) : i[n] = t[n];
704
- let a, f = !1;
701
+ let r = this.memory.allocUI32(mt + e), s = this.getDataBlock(r.data), o = r.pointer;
702
+ for (let a = 0; a < t.length; a++)
703
+ s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s, a, t[a]) : s[a] = t[a];
704
+ let n, f = !1;
705
705
  for (; !f; )
706
- a = O(this.firstBlock.data, 1), f = z(this.firstBlock.data, 1, o, a);
707
- if (a) {
708
- let { bufferPosition: n, bufferByteOffset: l } = A(a), S = new Uint32Array(this.memory.buffers[n].buf, l, 1);
709
- W(S, 0, o);
706
+ n = O(this.firstBlock.data, 1), f = H(this.firstBlock.data, 1, o, n);
707
+ if (n) {
708
+ let { bufferPosition: a, bufferByteOffset: l } = g(n), S = new Uint32Array(this.memory.buffers[a].buf, l, 1);
709
+ j(S, 0, o);
710
710
  } else
711
- W(this.firstBlock.data, 0, o);
711
+ j(this.firstBlock.data, 0, o);
712
712
  Atomics.add(this.firstBlock.data, E, 1);
713
713
  }
714
714
  deleteMatch(t) {
715
- for (let { data: e, index: r, deleteCurrent: i } of this)
715
+ for (let { data: e, index: r, deleteCurrent: s } of this)
716
716
  if (t(e, r))
717
- return i(), !0;
717
+ return s(), !0;
718
718
  return !1;
719
719
  }
720
720
  deleteIndex(t) {
@@ -735,37 +735,37 @@ class u {
735
735
  for (; !r; ) {
736
736
  if (t = O(this.firstBlock.data, 0), e = O(this.firstBlock.data, 1), !e)
737
737
  return;
738
- r = z(this.firstBlock.data, 1, 0, e);
738
+ r = H(this.firstBlock.data, 1, 0, e);
739
739
  }
740
740
  if (!t)
741
741
  return;
742
- z(this.firstBlock.data, 0, 0, t);
743
- let i = 0, o = t;
742
+ H(this.firstBlock.data, 0, 0, t);
743
+ let s = 0, o = t;
744
744
  for (; o; ) {
745
- let { bufferPosition: a, bufferByteOffset: f } = A(o), n = this.memory.buffers[a];
746
- if (!n)
745
+ let { bufferPosition: n, bufferByteOffset: f } = g(o), a = this.memory.buffers[n];
746
+ if (!a)
747
747
  break;
748
- let l = new Uint32Array(n.buf, f, 2);
749
- o = O(l, 0), i++, this.onDelete && this.onDelete(this.getDataBlock(l)), n.free(l.byteOffset);
748
+ let l = new Uint32Array(a.buf, f, 2);
749
+ o = O(l, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(l)), a.free(l.byteOffset);
750
750
  }
751
- Atomics.sub(this.firstBlock.data, E, i);
751
+ Atomics.sub(this.firstBlock.data, E, s);
752
752
  }
753
753
  *[Symbol.iterator]() {
754
- let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), i = this.firstBlock.data, o = 0, a = 0;
754
+ let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0, n = 0;
755
755
  for (; r; ) {
756
756
  let f = this.memory.buffers[e];
757
757
  if (!f)
758
758
  return;
759
- let n = new Uint32Array(f.buf, r, 2), l = this.getDataBlock(n), S = e, $ = r;
760
- ({ bufferPosition: e, bufferByteOffset: r } = c(n, 0));
759
+ let a = new Uint32Array(f.buf, r, 2), l = this.getDataBlock(a), S = e, Y = r;
760
+ ({ bufferPosition: e, bufferByteOffset: r } = c(a, 0));
761
761
  let M = !0;
762
762
  yield {
763
763
  data: l,
764
764
  index: t,
765
765
  deleteCurrent: () => {
766
- m(i, 0, e, r), r || m(this.firstBlock.data, 1, o, a), this.onDelete && this.onDelete(this.getDataBlock(n)), f.free(n.byteOffset), Atomics.sub(this.firstBlock.data, E, 1), M = !1;
766
+ m(s, 0, e, r), r || m(this.firstBlock.data, 1, o, n), this.onDelete && this.onDelete(this.getDataBlock(a)), f.free(a.byteOffset), Atomics.sub(this.firstBlock.data, E, 1), M = !1;
767
767
  }
768
- }, M && (i = n, o = S, a = $, t++);
768
+ }, M && (s = a, o = S, n = Y, t++);
769
769
  }
770
770
  }
771
771
  forEach(t) {
@@ -778,7 +778,7 @@ class u {
778
778
  };
779
779
  }
780
780
  getDataBlock(t) {
781
- const e = t.byteOffset + ut * t.BYTES_PER_ELEMENT;
781
+ const e = t.byteOffset + mt * t.BYTES_PER_ELEMENT;
782
782
  switch (this.type) {
783
783
  case 1:
784
784
  return new Int32Array(t.buffer, e, this.dataLength);
@@ -802,8 +802,8 @@ class u {
802
802
  this.firstBlock.free();
803
803
  }
804
804
  }
805
- const dt = 10;
806
- class Tt {
805
+ const bt = 10;
806
+ class Ot {
807
807
  static ALLOCATE_COUNT = 4;
808
808
  memory;
809
809
  // Memory order: Pointer, Lock, Length, MaxHash
@@ -822,9 +822,9 @@ class Tt {
822
822
  if (this.memory = t, e)
823
823
  this.pointerMemory = new h(t, e.firstBlock);
824
824
  else {
825
- this.pointerMemory = t.allocUI32(Tt.ALLOCATE_COUNT);
826
- let r = t.allocUI32(dt);
827
- m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, dt);
825
+ this.pointerMemory = t.allocUI32(Ot.ALLOCATE_COUNT);
826
+ let r = t.allocUI32(bt);
827
+ m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, bt);
828
828
  }
829
829
  this.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);
830
830
  }
@@ -833,67 +833,67 @@ class Tt {
833
833
  let r = C(t);
834
834
  this.setHashKey(this.hashMemory, this.maxHash, r, e) && Atomics.add(this.pointerMemory.data, 2, 1);
835
835
  }
836
- setHashKey(t, e, r, i) {
837
- let o = this.hash(r, e), a, f = c(t.data, o);
836
+ setHashKey(t, e, r, s) {
837
+ let o = this.hash(r, e), n, f = c(t.data, o);
838
838
  if (f.bufferByteOffset === 0) {
839
- a = new u(this.memory, {
839
+ n = new u(this.memory, {
840
840
  dataLength: 2
841
841
  });
842
- let l = a.getSharedMemory();
842
+ let l = n.getSharedMemory();
843
843
  m(t.data, o, l.firstBlock.bufferPosition, l.firstBlock.bufferByteOffset);
844
844
  } else
845
- a = new u(this.memory, {
845
+ n = new u(this.memory, {
846
846
  firstBlock: f
847
847
  });
848
- let n = !0;
849
- return a.deleteValue(r) && (n = !1), a.insert([r, i]), n;
848
+ let a = !0;
849
+ return n.deleteValue(r) && (a = !1), n.insert([r, s]), a;
850
850
  }
851
851
  get(t) {
852
- let e = C(t), r = this.hash(e, this.maxHash), i = c(this.hashMemory.data, r);
853
- if (i.bufferByteOffset === 0)
852
+ let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
853
+ if (s.bufferByteOffset === 0)
854
854
  return;
855
855
  let o = new u(this.memory, {
856
- firstBlock: i
856
+ firstBlock: s
857
857
  });
858
- for (let { data: a } of o)
859
- if (a[0] === e)
860
- return a[1];
858
+ for (let { data: n } of o)
859
+ if (n[0] === e)
860
+ return n[1];
861
861
  }
862
862
  has(t) {
863
- let e = C(t), r = this.hash(e, this.maxHash), i = c(this.hashMemory.data, r);
864
- if (i.bufferByteOffset === 0)
863
+ let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
864
+ if (s.bufferByteOffset === 0)
865
865
  return !1;
866
866
  let o = new u(this.memory, {
867
- firstBlock: i
867
+ firstBlock: s
868
868
  });
869
- for (let { data: a } of o)
870
- if (a[0] === e)
869
+ for (let { data: n } of o)
870
+ if (n[0] === e)
871
871
  return !0;
872
872
  return !1;
873
873
  }
874
874
  delete(t) {
875
- let e = C(t), r = this.hash(e, this.maxHash), i = c(this.hashMemory.data, r);
876
- if (i.bufferByteOffset === 0)
875
+ let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
876
+ if (s.bufferByteOffset === 0)
877
877
  return !1;
878
878
  let o = new u(this.memory, {
879
- firstBlock: i
879
+ firstBlock: s
880
880
  });
881
- for (let { data: a, deleteCurrent: f } of o)
882
- if (a[0] === e)
881
+ for (let { data: n, deleteCurrent: f } of o)
882
+ if (n[0] === e)
883
883
  return f(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
884
884
  return !1;
885
885
  }
886
886
  growHashTable() {
887
- let t = this.maxHash, e = t * 2, r = this.memory.allocUI32(e), i = this.hashMemory;
887
+ let t = this.maxHash, e = t * 2, r = this.memory.allocUI32(e), s = this.hashMemory;
888
888
  for (let o = 0; o < t; o++) {
889
- let a = c(i.data, o);
890
- if (a.bufferByteOffset === 0)
889
+ let n = c(s.data, o);
890
+ if (n.bufferByteOffset === 0)
891
891
  continue;
892
892
  let f = new u(this.memory, {
893
- firstBlock: a
893
+ firstBlock: n
894
894
  });
895
- for (let { data: n } of f)
896
- this.setHashKey(r, e, n[0], n[1]);
895
+ for (let { data: a } of f)
896
+ this.setHashKey(r, e, a[0], a[1]);
897
897
  }
898
898
  m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
899
899
  }
@@ -917,24 +917,24 @@ class Tt {
917
917
  };
918
918
  }
919
919
  }
920
- function C(s) {
921
- return typeof s == "number" ? s : typeof s == "string" ? te(s) : s;
920
+ function C(i) {
921
+ return typeof i == "number" ? i : typeof i == "string" ? ae(i) : i;
922
922
  }
923
- function te(s) {
924
- let t = s.length, e = 17 ^ t, r = 0, i;
923
+ function ae(i) {
924
+ let t = i.length, e = 17 ^ t, r = 0, s;
925
925
  for (; t >= 4; )
926
- i = s.charCodeAt(r) & 255 | (s.charCodeAt(++r) & 255) << 8 | (s.charCodeAt(++r) & 255) << 16 | (s.charCodeAt(++r) & 255) << 14, i = (i & 65535) * 1540483477 + (((i >>> 16) * 1540483477 & 65535) << 16), i ^= i >>> 14, i = (i & 65535) * 1540483477 + (((i >>> 16) * 1540483477 & 65535) << 16), e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16) ^ i, t -= 4, ++r;
926
+ s = i.charCodeAt(r) & 255 | (i.charCodeAt(++r) & 255) << 8 | (i.charCodeAt(++r) & 255) << 16 | (i.charCodeAt(++r) & 255) << 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), s ^= s >>> 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16) ^ s, t -= 4, ++r;
927
927
  switch (t) {
928
928
  case 3:
929
- e ^= (s.charCodeAt(r + 2) & 255) << 16;
929
+ e ^= (i.charCodeAt(r + 2) & 255) << 16;
930
930
  case 2:
931
- e ^= (s.charCodeAt(r + 1) & 255) << 8;
931
+ e ^= (i.charCodeAt(r + 1) & 255) << 8;
932
932
  case 1:
933
- e ^= s.charCodeAt(r) & 255, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16);
933
+ e ^= i.charCodeAt(r) & 255, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16);
934
934
  }
935
935
  return e ^= e >>> 13, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16), e ^= e >>> 15, e = e >>> 0, e;
936
936
  }
937
- class fe {
937
+ class Be {
938
938
  memory;
939
939
  list;
940
940
  constructor(t, e) {
@@ -952,9 +952,9 @@ class fe {
952
952
  *[Symbol.iterator]() {
953
953
  let t = this.list[Symbol.iterator]();
954
954
  for (let { data: e } of t) {
955
- let { bufferPosition: r, bufferByteOffset: i } = c(e, 0), o = new h(this.memory, {
955
+ let { bufferPosition: r, bufferByteOffset: s } = c(e, 0), o = new h(this.memory, {
956
956
  bufferPosition: r,
957
- bufferByteOffset: i
957
+ bufferByteOffset: s
958
958
  });
959
959
  yield this.createItem(o);
960
960
  }
@@ -977,11 +977,11 @@ class fe {
977
977
  this.list.free();
978
978
  }
979
979
  }
980
- const yt = {
980
+ const At = {
981
981
  1: Uint8Array,
982
982
  2: Uint16Array
983
- }, I = 0, Bt = 1, mt = 2, bt = 3;
984
- class Lt {
983
+ }, U = 0, gt = 1, kt = 2, Et = 3;
984
+ class Mt {
985
985
  static ALLOCATE_COUNT = 4;
986
986
  memory;
987
987
  allocatedMemory;
@@ -989,11 +989,11 @@ class Lt {
989
989
  cachedPointer;
990
990
  cachedString;
991
991
  constructor(t, e) {
992
- this.memory = t, typeof e == "string" ? (this.allocatedMemory = this.memory.allocUI32(Lt.ALLOCATE_COUNT), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + bt * this.allocatedMemory.data.BYTES_PER_ELEMENT), this.updateString(e)) : (this.allocatedMemory = new h(t, e), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + bt * this.allocatedMemory.data.BYTES_PER_ELEMENT), "value" in e && this.updateString(e.value));
992
+ this.memory = t, typeof e == "string" ? (this.allocatedMemory = this.memory.allocUI32(Mt.ALLOCATE_COUNT), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + Et * this.allocatedMemory.data.BYTES_PER_ELEMENT), this.updateString(e)) : (this.allocatedMemory = new h(t, e), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + Et * this.allocatedMemory.data.BYTES_PER_ELEMENT), "value" in e && this.updateString(e.value));
993
993
  }
994
994
  updateString(t) {
995
995
  let e = this.createString(t);
996
- x(this.lock), W(this.allocatedMemory.data, I, e.pointer), Atomics.store(this.allocatedMemory.data, Bt, t.length), Atomics.store(this.allocatedMemory.data, mt, e.charType), k(this.lock), this.cachedPointer = e.pointer, this.cachedString = t;
996
+ x(this.lock), j(this.allocatedMemory.data, U, e.pointer), Atomics.store(this.allocatedMemory.data, gt, t.length), Atomics.store(this.allocatedMemory.data, kt, e.charType), A(this.lock), this.cachedPointer = e.pointer, this.cachedString = t;
997
997
  }
998
998
  createString(t) {
999
999
  if (t === "")
@@ -1003,29 +1003,29 @@ class Lt {
1003
1003
  /* ASCII */
1004
1004
  };
1005
1005
  let e = [];
1006
- for (let n = 0; n < t.length; n++)
1007
- e.push(t.charCodeAt(n));
1008
- let i = Math.max(...e) > 255 ? 2 : 1, o = yt[i], a = this.memory.allocUI32(Math.ceil(t.length / (4 / o.BYTES_PER_ELEMENT))), f = new o(a.data.buffer, a.data.byteOffset, t.length);
1009
- for (let n = 0; n < t.length; n++)
1010
- f[n] = t.charCodeAt(n);
1006
+ for (let a = 0; a < t.length; a++)
1007
+ e.push(t.charCodeAt(a));
1008
+ let s = Math.max(...e) > 255 ? 2 : 1, o = At[s], n = this.memory.allocUI32(Math.ceil(t.length / (4 / o.BYTES_PER_ELEMENT))), f = new o(n.data.buffer, n.data.byteOffset, t.length);
1009
+ for (let a = 0; a < t.length; a++)
1010
+ f[a] = t.charCodeAt(a);
1011
1011
  return {
1012
- pointer: a.pointer,
1013
- charType: i
1012
+ pointer: n.pointer,
1013
+ charType: s
1014
1014
  };
1015
1015
  }
1016
1016
  get value() {
1017
- let t = O(this.allocatedMemory.data, I);
1017
+ let t = O(this.allocatedMemory.data, U);
1018
1018
  if (this.cachedPointer === t && this.cachedString !== void 0)
1019
1019
  return this.cachedString;
1020
1020
  if (t === 0)
1021
1021
  return "";
1022
- let { bufferPosition: e, bufferByteOffset: r } = A(t);
1022
+ let { bufferPosition: e, bufferByteOffset: r } = g(t);
1023
1023
  x(this.lock);
1024
- let i = Atomics.load(this.allocatedMemory.data, mt), o = yt[i], a = Atomics.load(this.allocatedMemory.data, Bt), f = new o(this.memory.buffers[e].buf, r, a), n = String.fromCharCode.apply(null, f);
1025
- return k(this.lock), this.cachedPointer = t, this.cachedString = n, n;
1024
+ let s = Atomics.load(this.allocatedMemory.data, kt), o = At[s], n = Atomics.load(this.allocatedMemory.data, gt), f = new o(this.memory.buffers[e].buf, r, n), a = String.fromCharCode.apply(null, f);
1025
+ return A(this.lock), this.cachedPointer = t, this.cachedString = a, a;
1026
1026
  }
1027
1027
  set value(t) {
1028
- let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data, I);
1028
+ let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data, U);
1029
1029
  this.updateString(t), r && this.memory.buffers[e].free(r);
1030
1030
  }
1031
1031
  getSharedMemory() {
@@ -1035,12 +1035,12 @@ class Lt {
1035
1035
  return this.allocatedMemory.pointer;
1036
1036
  }
1037
1037
  free() {
1038
- let { bufferPosition: t, bufferByteOffset: e } = c(this.allocatedMemory.data, I);
1038
+ let { bufferPosition: t, bufferByteOffset: e } = c(this.allocatedMemory.data, U);
1039
1039
  e && this.memory.buffers[t].free(e), this.allocatedMemory.free();
1040
1040
  }
1041
1041
  }
1042
- const p = 0, b = 1, kt = 2, At = 3, Z = 4;
1043
- class y {
1042
+ const w = 0, b = 1, wt = 2, pt = 3, v = 4;
1043
+ class d {
1044
1044
  static ALLOCATE_COUNT = 4;
1045
1045
  memory;
1046
1046
  // Pointer, List Length, Buffer Length, Type/DataLength
@@ -1062,10 +1062,10 @@ class y {
1062
1062
  Atomics.store(this.uint16Array, 1, t);
1063
1063
  }
1064
1064
  get bufferLength() {
1065
- return Atomics.load(this.firstBlock.data, kt);
1065
+ return Atomics.load(this.firstBlock.data, wt);
1066
1066
  }
1067
1067
  set bufferLength(t) {
1068
- Atomics.store(this.firstBlock.data, kt, t);
1068
+ Atomics.store(this.firstBlock.data, wt, t);
1069
1069
  }
1070
1070
  get pointer() {
1071
1071
  return this.firstBlock.pointer;
@@ -1074,20 +1074,20 @@ class y {
1074
1074
  cachedPointer;
1075
1075
  constructor(t, e) {
1076
1076
  if (this.memory = t, e && "firstBlock" in e) {
1077
- if (this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + At * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
1078
- let r = t.allocUI32(Z * (e.dataLength ?? 1));
1079
- m(this.firstBlock.data, p, r.bufferPosition, r.bufferByteOffset), this.bufferLength = Z, this.dataLength = e.dataLength ?? 1;
1077
+ if (this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + pt * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
1078
+ let r = t.allocUI32(v * (e.dataLength ?? 1));
1079
+ m(this.firstBlock.data, w, r.bufferPosition, r.bufferByteOffset), this.bufferLength = v, this.dataLength = e.dataLength ?? 1;
1080
1080
  }
1081
1081
  if ("type" in e) {
1082
1082
  const r = e?.type ?? Uint32Array;
1083
1083
  r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2);
1084
1084
  }
1085
1085
  } else {
1086
- this.firstBlock = t.allocUI32(y.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + At * Uint32Array.BYTES_PER_ELEMENT, 2);
1087
- let r = e?.dataLength ?? 1, i = e?.bufferLength ?? Z, o = t.allocUI32(i * r);
1088
- m(this.firstBlock.data, p, o.bufferPosition, o.bufferByteOffset), this.bufferLength = i;
1089
- const a = e?.type ?? Uint32Array;
1090
- a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r;
1086
+ this.firstBlock = t.allocUI32(d.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + pt * Uint32Array.BYTES_PER_ELEMENT, 2);
1087
+ let r = e?.dataLength ?? 1, s = e?.bufferLength ?? v, o = t.allocUI32(s * r);
1088
+ m(this.firstBlock.data, w, o.bufferPosition, o.bufferByteOffset), this.bufferLength = s;
1089
+ const n = e?.type ?? Uint32Array;
1090
+ n === Uint32Array ? this.type = 0 : n === Int32Array ? this.type = 1 : n === Float32Array && (this.type = 2), this.dataLength = r;
1091
1091
  }
1092
1092
  this.cachedPointer = this.firstBlock.data[0], this.cachedFullDataBlock = this.getFullDataBlock();
1093
1093
  }
@@ -1110,8 +1110,8 @@ class y {
1110
1110
  let e = this.dataLength;
1111
1111
  if (t.length > e)
1112
1112
  throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
1113
- let r = this.getFullDataBlock(), i = this.length;
1114
- return r.set(t, e * i), Atomics.add(this.firstBlock.data, b, 1) + 1 >= this.bufferLength && this.growBuffer(), i;
1113
+ let r = this.getFullDataBlock(), s = this.length;
1114
+ return r.set(t, e * s), Atomics.add(this.firstBlock.data, b, 1) + 1 >= this.bufferLength && this.growBuffer(), s;
1115
1115
  }
1116
1116
  pop() {
1117
1117
  let t = Atomics.sub(this.firstBlock.data, b, b), e = this.getFullDataBlock();
@@ -1121,10 +1121,10 @@ class y {
1121
1121
  let e = this.length;
1122
1122
  if (t >= e || t < 0)
1123
1123
  throw new Error(`${t} is out of bounds ${e}`);
1124
- let r = this.dataLength, i = this.getFullDataBlock();
1124
+ let r = this.dataLength, s = this.getFullDataBlock();
1125
1125
  for (let o = t; o < e; o++)
1126
- for (let a = 0; a < r; a++)
1127
- i[o * r + a] = i[(o + 1) * r + a];
1126
+ for (let n = 0; n < r; n++)
1127
+ s[o * r + n] = s[(o + 1) * r + n];
1128
1128
  Atomics.sub(this.firstBlock.data, b, b);
1129
1129
  }
1130
1130
  clear() {
@@ -1136,48 +1136,48 @@ class y {
1136
1136
  yield this.getDataBlock(t, e);
1137
1137
  }
1138
1138
  getFullDataBlock() {
1139
- let t = Atomics.load(this.firstBlock.data, p);
1139
+ let t = Atomics.load(this.firstBlock.data, w);
1140
1140
  if (this.cachedPointer === t && this.cachedFullDataBlock)
1141
1141
  return this.cachedFullDataBlock;
1142
- let e = A(t), r = new h(this.memory, e), i;
1142
+ let e = g(t), r = new h(this.memory, e), s;
1143
1143
  switch (this.type) {
1144
1144
  case 1:
1145
- i = new Int32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1145
+ s = new Int32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1146
1146
  break;
1147
1147
  case 0:
1148
- i = new Uint32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1148
+ s = new Uint32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1149
1149
  break;
1150
1150
  case 2:
1151
- i = new Float32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1151
+ s = new Float32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1152
1152
  break;
1153
1153
  default:
1154
1154
  throw new Error(`Unknown data block type ${this.type}`);
1155
1155
  }
1156
- return this.cachedPointer = t, this.cachedFullDataBlock = i, i;
1156
+ return this.cachedPointer = t, this.cachedFullDataBlock = s, s;
1157
1157
  }
1158
1158
  getDataBlock(t, e) {
1159
1159
  const r = e * this.dataLength;
1160
1160
  return t.subarray(r, r + this.dataLength);
1161
1161
  }
1162
1162
  growBuffer() {
1163
- let e = this.bufferLength * 2, r = this.dataLength, i = c(this.firstBlock.data, p), o = new h(this.memory, i), a = this.getFullDataBlock(), f = this.memory.allocUI32(e * r), n;
1163
+ let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, w), o = new h(this.memory, s), n = this.getFullDataBlock(), f = this.memory.allocUI32(e * r), a;
1164
1164
  switch (this.type) {
1165
1165
  case 1:
1166
- n = new Int32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1166
+ a = new Int32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1167
1167
  break;
1168
1168
  case 0:
1169
- n = new Uint32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1169
+ a = new Uint32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1170
1170
  break;
1171
1171
  case 2:
1172
- n = new Float32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1172
+ a = new Float32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1173
1173
  break;
1174
1174
  default:
1175
1175
  throw new Error(`Unknown data block type ${this.type}`);
1176
1176
  }
1177
- n.set(a), m(this.firstBlock.data, p, f.bufferPosition, f.bufferByteOffset), this.bufferLength = e, o.free();
1177
+ a.set(n), m(this.firstBlock.data, w, f.bufferPosition, f.bufferByteOffset), this.bufferLength = e, o.free();
1178
1178
  }
1179
1179
  free() {
1180
- let t = c(this.firstBlock.data, p);
1180
+ let t = c(this.firstBlock.data, w);
1181
1181
  new h(this.memory, t).free(), this.firstBlock.free();
1182
1182
  }
1183
1183
  getSharedMemory() {
@@ -1186,17 +1186,17 @@ class y {
1186
1186
  };
1187
1187
  }
1188
1188
  }
1189
- class le {
1189
+ class me {
1190
1190
  static ALLOCATE_COUNT = u.ALLOCATE_COUNT;
1191
1191
  heap;
1192
1192
  list;
1193
1193
  cache = /* @__PURE__ */ new Map();
1194
1194
  constructor(t, e) {
1195
1195
  e ? this.list = new u(t, e) : this.list = new u(t), this.heap = t, this.list.onDelete = (r) => {
1196
- let i = Atomics.load(r, 0);
1197
- if (i) {
1198
- let o = this.cache.get(i);
1199
- o || (o = this.initItem(i)), o && (o.free(), this.cache.delete(i));
1196
+ let s = Atomics.load(r, 0);
1197
+ if (s) {
1198
+ let o = this.cache.get(s);
1199
+ o || (o = this.initItem(s)), o && (o.free(), this.cache.delete(s));
1200
1200
  }
1201
1201
  };
1202
1202
  }
@@ -1219,11 +1219,11 @@ class le {
1219
1219
  *[Symbol.iterator]() {
1220
1220
  let t = this.list[Symbol.iterator]();
1221
1221
  for (let { data: e, deleteCurrent: r } of t) {
1222
- let i = Atomics.load(e, 0);
1223
- if (!i)
1222
+ let s = Atomics.load(e, 0);
1223
+ if (!s)
1224
1224
  continue;
1225
- let o = this.cache.get(i);
1226
- o || (o = this.initItem(i), o && this.cache.set(i, o)), o && (yield {
1225
+ let o = this.cache.get(s);
1226
+ o || (o = this.initItem(s), o && this.cache.set(s, o)), o && (yield {
1227
1227
  item: o,
1228
1228
  deleteCurrent: r
1229
1229
  });
@@ -1257,9 +1257,9 @@ class le {
1257
1257
  this.list.free(), this.cache.clear();
1258
1258
  }
1259
1259
  }
1260
- const D = 0, gt = 1, Et = 2, j = 3, pt = j + y.ALLOCATE_COUNT;
1261
- class St {
1262
- static ALLOCATE_COUNT = 3 + y.ALLOCATE_COUNT * 2;
1260
+ const F = 0, Tt = 1, Lt = 2, J = 3, St = J + d.ALLOCATE_COUNT;
1261
+ class It {
1262
+ static ALLOCATE_COUNT = 3 + d.ALLOCATE_COUNT * 2;
1263
1263
  memory;
1264
1264
  // Current Length, Type/DataLength, MaxChunkLength, Pointer vector, Recycle vector
1265
1265
  firstBlock;
@@ -1268,13 +1268,13 @@ class St {
1268
1268
  recycleVector;
1269
1269
  cachedFullDataBlock = {};
1270
1270
  get length() {
1271
- return Atomics.load(this.firstBlock.data, D) - this.recycleVector.length;
1271
+ return Atomics.load(this.firstBlock.data, F) - this.recycleVector.length;
1272
1272
  }
1273
1273
  get maxChunkSize() {
1274
- return this.firstBlock.data[Et];
1274
+ return this.firstBlock.data[Lt];
1275
1275
  }
1276
1276
  set maxChunkSize(t) {
1277
- Atomics.store(this.firstBlock.data, Et, t);
1277
+ Atomics.store(this.firstBlock.data, Lt, t);
1278
1278
  }
1279
1279
  get type() {
1280
1280
  return this.uint16Array[0];
@@ -1291,39 +1291,42 @@ class St {
1291
1291
  get bufferLength() {
1292
1292
  return this.maxChunkSize * this.pointerVector.length;
1293
1293
  }
1294
+ get byteMultipler() {
1295
+ return this.type === 3 ? 2 : 1;
1296
+ }
1294
1297
  constructor(t, e) {
1295
1298
  if (this.memory = t, e && "firstBlock" in e)
1296
- this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + gt * Uint32Array.BYTES_PER_ELEMENT, 2), this.pointerVector = new y(t, {
1299
+ this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT, 2), this.pointerVector = new d(t, {
1297
1300
  firstBlock: {
1298
1301
  bufferPosition: this.firstBlock.bufferPosition,
1299
- bufferByteOffset: this.firstBlock.bufferByteOffset + j * Uint32Array.BYTES_PER_ELEMENT
1302
+ bufferByteOffset: this.firstBlock.bufferByteOffset + J * Uint32Array.BYTES_PER_ELEMENT
1300
1303
  }
1301
- }), this.recycleVector = new y(t, {
1304
+ }), this.recycleVector = new d(t, {
1302
1305
  firstBlock: {
1303
1306
  bufferPosition: this.firstBlock.bufferPosition,
1304
- bufferByteOffset: this.firstBlock.bufferByteOffset + pt * Uint32Array.BYTES_PER_ELEMENT
1307
+ bufferByteOffset: this.firstBlock.bufferByteOffset + St * Uint32Array.BYTES_PER_ELEMENT
1305
1308
  }
1306
1309
  });
1307
1310
  else {
1308
- this.firstBlock = t.allocUI32(St.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + gt * Uint32Array.BYTES_PER_ELEMENT, 2);
1309
- let r = e?.dataLength ?? 1, i = e?.maxChunkSize ?? 100;
1310
- this.pointerVector = new y(t, {
1311
+ this.firstBlock = t.allocUI32(It.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT, 2);
1312
+ let r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
1313
+ this.pointerVector = new d(t, {
1311
1314
  type: Uint32Array,
1312
1315
  firstBlock: {
1313
1316
  bufferPosition: this.firstBlock.bufferPosition,
1314
- bufferByteOffset: this.firstBlock.bufferByteOffset + j * Uint32Array.BYTES_PER_ELEMENT
1317
+ bufferByteOffset: this.firstBlock.bufferByteOffset + J * Uint32Array.BYTES_PER_ELEMENT
1315
1318
  }
1316
- }), this.recycleVector = new y(t, {
1319
+ }), this.recycleVector = new d(t, {
1317
1320
  type: Uint32Array,
1318
1321
  firstBlock: {
1319
1322
  bufferPosition: this.firstBlock.bufferPosition,
1320
- bufferByteOffset: this.firstBlock.bufferByteOffset + pt * Uint32Array.BYTES_PER_ELEMENT
1323
+ bufferByteOffset: this.firstBlock.bufferByteOffset + St * Uint32Array.BYTES_PER_ELEMENT
1321
1324
  }
1322
1325
  });
1323
- let o = t.allocUI32(i * r);
1324
- this.pointerVector.push(o.pointer);
1325
- const a = e?.type ?? Uint32Array;
1326
- a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r, this.maxChunkSize = i;
1326
+ const o = e?.type ?? Uint32Array;
1327
+ o === Uint32Array ? this.type = 0 : o === Int32Array ? this.type = 1 : o === Float32Array ? this.type = 2 : o === Float64Array && (this.type = 3), this.dataLength = r, this.maxChunkSize = s;
1328
+ let n = t.allocUI32(s * r * this.byteMultipler);
1329
+ this.pointerVector.push(n.pointer);
1327
1330
  }
1328
1331
  }
1329
1332
  at(t) {
@@ -1342,22 +1345,22 @@ class St {
1342
1345
  if (t.length > e)
1343
1346
  throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
1344
1347
  let r;
1345
- this.recycleVector.length ? r = this.recycleVector.pop()[0] : r = Atomics.add(this.firstBlock.data, D, 1);
1346
- let i = this.getFullDataBlock(r), o = r % this.maxChunkSize;
1347
- return i.set(t, e * o), r;
1348
+ this.recycleVector.length ? r = this.recycleVector.pop()[0] : r = Atomics.add(this.firstBlock.data, F, 1);
1349
+ let s = this.getFullDataBlock(r), o = r % this.maxChunkSize;
1350
+ return s.set(t, e * o), r;
1348
1351
  }
1349
1352
  deleteIndex(t) {
1350
1353
  this.recycleVector.push(t);
1351
1354
  }
1352
1355
  clear() {
1353
- this.firstBlock.data[D] = 0;
1356
+ this.firstBlock.data[F] = 0;
1354
1357
  }
1355
1358
  *[Symbol.iterator]() {
1356
- let t = [...this.recycleVector].reduce((i, o) => (i.push(...o), i), []), e = this.getFullDataBlock(0), r = 0;
1357
- for (let i = 0; i < Atomics.load(this.firstBlock.data, D); i++)
1358
- if (!t.includes(i)) {
1359
- let o = Math.floor(i / this.maxChunkSize);
1360
- o !== r && (e = this.getFullDataBlock(i), r = o), yield this.getDataBlock(e, i % this.maxChunkSize);
1359
+ let t = [...this.recycleVector].reduce((s, o) => (s.push(...o), s), []), e = this.getFullDataBlock(0), r = 0;
1360
+ for (let s = 0; s < Atomics.load(this.firstBlock.data, F); s++)
1361
+ if (!t.includes(s)) {
1362
+ let o = Math.floor(s / this.maxChunkSize);
1363
+ o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
1361
1364
  }
1362
1365
  }
1363
1366
  getFullDataBlock(t) {
@@ -1365,19 +1368,22 @@ class St {
1365
1368
  if (r)
1366
1369
  return r;
1367
1370
  if (e >= this.pointerVector.length) {
1368
- let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength);
1369
- this.pointerVector.push(a.pointer);
1371
+ let n = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1372
+ this.pointerVector.push(n.pointer);
1370
1373
  }
1371
- let i = new h(this.memory, A(this.pointerVector.get(e))), o;
1374
+ let s = new h(this.memory, g(this.pointerVector.get(e))), o;
1372
1375
  switch (this.type) {
1373
1376
  case 1:
1374
- o = new Int32Array(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
1377
+ o = new Int32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1375
1378
  break;
1376
1379
  case 0:
1377
- o = new Uint32Array(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
1380
+ o = new Uint32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1378
1381
  break;
1379
1382
  case 2:
1380
- o = new Float32Array(i.data.buffer, i.bufferByteOffset, this.dataLength * this.maxChunkSize);
1383
+ o = new Float32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1384
+ break;
1385
+ case 3:
1386
+ o = new Float64Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1381
1387
  break;
1382
1388
  default:
1383
1389
  throw new Error(`Unknown data block type ${this.type}`);
@@ -1392,7 +1398,7 @@ class St {
1392
1398
  this.recycleVector.free();
1393
1399
  for (let t of this.pointerVector) {
1394
1400
  let e = t[0];
1395
- new h(this.memory, A(e)).free();
1401
+ new h(this.memory, g(e)).free();
1396
1402
  }
1397
1403
  this.pointerVector.free(), this.firstBlock.free();
1398
1404
  }
@@ -1402,101 +1408,158 @@ class St {
1402
1408
  };
1403
1409
  }
1404
1410
  }
1405
- const _t = new ArrayBuffer(4), Ot = new Uint32Array(_t), R = new Uint16Array(_t);
1406
- function he(s, t) {
1407
- return ee(Atomics.load(s, t));
1411
+ const Pt = new ArrayBuffer(4), Nt = new Uint32Array(Pt), R = new Uint16Array(Pt);
1412
+ function be(i, t) {
1413
+ return fe(Atomics.load(i, t));
1414
+ }
1415
+ function Ae(i, t, e, r) {
1416
+ Atomics.store(i, t, le(e, r));
1417
+ }
1418
+ function fe(i) {
1419
+ return Nt[0] = i, [R[0], R[1]];
1420
+ }
1421
+ function le(i, t) {
1422
+ return R[0] = i, R[1] = t, Nt[0];
1423
+ }
1424
+ const Ct = new ArrayBuffer(8), Ut = new BigUint64Array(Ct), B = new Uint16Array(Ct);
1425
+ function ge(i, t) {
1426
+ return Ut[0] = Atomics.load(i, t), [B[0], B[1], B[2], B[3]];
1427
+ }
1428
+ function ke(i, t, e, r, s, o = 0) {
1429
+ B[0] = e, B[1] = r, B[2] = s, B[3] = o, Atomics.store(i, t, Ut[0]);
1430
+ }
1431
+ const Ft = new ArrayBuffer(4), Dt = new Float32Array(Ft), xt = new Int32Array(Ft);
1432
+ function Rt(i, t) {
1433
+ return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.load(i, t));
1434
+ }
1435
+ function Ee(i, t, e) {
1436
+ i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, $(e));
1437
+ }
1438
+ function tt(i) {
1439
+ return xt[0] = i, Dt[0];
1440
+ }
1441
+ function $(i) {
1442
+ return Dt[0] = i, xt[0];
1443
+ }
1444
+ function we(i, t, e) {
1445
+ return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.exchange(i, t, $(e)));
1446
+ }
1447
+ function $t(i, t, e, r) {
1448
+ return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.compareExchange(i, t, $(e), $(r)));
1408
1449
  }
1409
- function ce(s, t, e, r) {
1410
- Atomics.store(s, t, re(e, r));
1450
+ function pe(i, t, e, r) {
1451
+ let s, o;
1452
+ do
1453
+ s = Atomics.load(i, t), o = Math.min(s + e, r);
1454
+ while (Atomics.compareExchange(i, t, s, o) !== s);
1411
1455
  }
1412
- function ee(s) {
1413
- return Ot[0] = s, [R[0], R[1]];
1456
+ function Te(i, t, e, r) {
1457
+ let s, o;
1458
+ do
1459
+ s = Atomics.load(i, t), o = Math.max(s - e, r);
1460
+ while (Atomics.compareExchange(i, t, s, o) !== s);
1414
1461
  }
1415
- function re(s, t) {
1416
- return R[0] = s, R[1] = t, Ot[0];
1462
+ function Le(i, t, e, r) {
1463
+ let s, o;
1464
+ do
1465
+ s = Rt(i, t), o = Math.min(s + e, r);
1466
+ while ($t(i, t, s, o) !== s);
1417
1467
  }
1418
- const Mt = new ArrayBuffer(8), Pt = new BigUint64Array(Mt), B = new Uint16Array(Mt);
1419
- function ue(s, t) {
1420
- return Pt[0] = Atomics.load(s, t), [B[0], B[1], B[2], B[3]];
1468
+ function Se(i, t, e, r) {
1469
+ let s, o;
1470
+ do
1471
+ s = Rt(i, t), o = Math.max(s - e, r);
1472
+ while ($t(i, t, s, o) !== s);
1421
1473
  }
1422
- function de(s, t, e, r, i, o = 0) {
1423
- B[0] = e, B[1] = r, B[2] = i, B[3] = o, Atomics.store(s, t, Pt[0]);
1474
+ const zt = new ArrayBuffer(8), Yt = new Float64Array(zt), Ht = new BigInt64Array(zt);
1475
+ function _e(i, t) {
1476
+ return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), et(Atomics.load(i, t));
1424
1477
  }
1425
- const Nt = new ArrayBuffer(4), Ut = new Float32Array(Nt), Ct = new Int32Array(Nt);
1426
- function ye(s, t) {
1427
- return It(Atomics.load(s, t));
1478
+ function Oe(i, t, e) {
1479
+ i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, z(e));
1428
1480
  }
1429
- function Be(s, t, e) {
1430
- Atomics.store(s, t, Dt(e));
1481
+ function et(i) {
1482
+ return Ht[0] = i, Yt[0];
1431
1483
  }
1432
- function It(s) {
1433
- return Ct[0] = s, Ut[0];
1484
+ function z(i) {
1485
+ return Yt[0] = i, Ht[0];
1434
1486
  }
1435
- function Dt(s) {
1436
- return Ut[0] = s, Ct[0];
1487
+ function Me(i, t, e) {
1488
+ return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), et(Atomics.exchange(i, t, z(e)));
1437
1489
  }
1438
- function me(s, t, e) {
1439
- return It(Atomics.exchange(s, t, Dt(e)));
1490
+ function Ie(i, t, e, r) {
1491
+ return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), et(Atomics.compareExchange(i, t, z(e), z(r)));
1440
1492
  }
1441
- const w = 0, q = 1, L = 2;
1442
- function be(s, t = 0) {
1443
- for (; Atomics.compareExchange(s, t, w, q) === L; )
1444
- Atomics.wait(s, t, L);
1445
- Atomics.add(s, t + 1, 1);
1493
+ const p = 0, Q = 1, L = 2;
1494
+ function Pe(i, t = 0) {
1495
+ for (; Atomics.compareExchange(i, t, p, Q) === L; )
1496
+ Atomics.wait(i, t, L);
1497
+ Atomics.add(i, t + 1, 1);
1446
1498
  }
1447
- function ke(s, t = 0) {
1448
- let e = Atomics.compareExchange(s, t, w, L);
1449
- for (; e !== w; )
1450
- Atomics.wait(s, t, e), e = Atomics.compareExchange(s, t, w, L);
1499
+ function Ne(i, t = 0) {
1500
+ let e = Atomics.compareExchange(i, t, p, L);
1501
+ for (; e !== p; )
1502
+ Atomics.wait(i, t, e), e = Atomics.compareExchange(i, t, p, L);
1451
1503
  }
1452
- function Ae(s, t = 0) {
1453
- Atomics.sub(s, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(s, t, q, w) !== q && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(s, t));
1504
+ function Ce(i, t = 0) {
1505
+ Atomics.sub(i, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(i, t, Q, p) !== Q && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(i, t));
1454
1506
  }
1455
- function ge(s, t = 0) {
1456
- Atomics.compareExchange(s, t, L, w) !== L && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(s, t);
1507
+ function Ue(i, t = 0) {
1508
+ Atomics.compareExchange(i, t, L, p) !== L && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(i, t);
1457
1509
  }
1458
- const Ee = 2;
1510
+ const Fe = 2;
1459
1511
  export {
1460
1512
  h as AllocatedMemory,
1461
- ie as BYTE_OFFSET_BIT_COUNT,
1462
- le as CachedItemList,
1463
- J as MAX_BYTE_OFFSET_LENGTH,
1464
- Q as MAX_POSITION_LENGTH,
1465
- V as MemoryBuffer,
1466
- ne as MemoryHeap,
1467
- se as POSITION_BIT_COUNT,
1468
- Ee as READ_WRITE_LOCK_ALLOCATE_COUNT,
1469
- ae as SIMPLE_LOCK_ALLOCATE_COUNT,
1513
+ he as BYTE_OFFSET_BIT_COUNT,
1514
+ me as CachedItemList,
1515
+ rt as MAX_BYTE_OFFSET_LENGTH,
1516
+ it as MAX_POSITION_LENGTH,
1517
+ Z as MemoryBuffer,
1518
+ de as MemoryHeap,
1519
+ ce as POSITION_BIT_COUNT,
1520
+ Fe as READ_WRITE_LOCK_ALLOCATE_COUNT,
1521
+ ye as SIMPLE_LOCK_ALLOCATE_COUNT,
1470
1522
  u as SharedList,
1471
- Tt as SharedMap,
1472
- fe as SharedPointerList,
1473
- St as SharedPool,
1474
- Lt as SharedString,
1475
- y as SharedVector,
1476
- re as convert16To32,
1477
- ee as convert32To16,
1478
- Dt as convertFloat32ToInt32,
1479
- It as convertInt32ToFloat32,
1523
+ Ot as SharedMap,
1524
+ Be as SharedPointerList,
1525
+ It as SharedPool,
1526
+ Mt as SharedString,
1527
+ d as SharedVector,
1528
+ Le as addAtomicFloat32,
1529
+ pe as addAtomicInt,
1530
+ $t as compareExchangeFloat32,
1531
+ Ie as compareExchangeFloat64,
1532
+ le as convert16To32,
1533
+ fe as convert32To16,
1534
+ $ as convertFloat32ToInt32,
1535
+ z as convertFloat64ToInt64,
1536
+ tt as convertInt32ToFloat32,
1537
+ et as convertInt64ToFloat64,
1480
1538
  T as createPointer,
1481
- me as exchangeFloat32,
1482
- A as getPointer,
1483
- he as load16From32,
1484
- ue as load16From64,
1485
- ye as loadFloat32,
1539
+ we as exchangeFloat32,
1540
+ Me as exchangeFloat64,
1541
+ g as getPointer,
1542
+ be as load16From32,
1543
+ ge as load16From64,
1544
+ Rt as loadFloat32,
1545
+ _e as loadFloat64,
1486
1546
  c as loadPointer,
1487
1547
  O as loadRawPointer,
1488
1548
  x as lock,
1489
- be as readLock,
1490
- Ae as readUnlock,
1491
- oe as replacePointer,
1492
- z as replaceRawPointer,
1493
- ce as store16In32,
1494
- de as store16In64,
1495
- Be as storeFloat32,
1549
+ Pe as readLock,
1550
+ Ce as readUnlock,
1551
+ ue as replacePointer,
1552
+ H as replaceRawPointer,
1553
+ Ae as store16In32,
1554
+ ke as store16In64,
1555
+ Ee as storeFloat32,
1556
+ Oe as storeFloat64,
1496
1557
  m as storePointer,
1497
- W as storeRawPointer,
1498
- k as unlock,
1499
- ke as writeLock,
1500
- ge as writeUnlock
1558
+ j as storeRawPointer,
1559
+ Se as subtractAtomicFloat,
1560
+ Te as subtractAtomicInt,
1561
+ A as unlock,
1562
+ Ne as writeLock,
1563
+ Ue as writeUnlock
1501
1564
  };
1502
1565
  //# sourceMappingURL=shared-memory-objects.js.map