@daneren2005/shared-memory-objects 0.0.18 → 0.0.20

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,30 +1,30 @@
1
1
  const he = 20, ce = 12, et = Math.pow(2, 20), rt = Math.pow(2, 12);
2
2
  function c(i, t = 0) {
3
- return g(Atomics.load(i, t));
3
+ return B(Atomics.load(i, t));
4
4
  }
5
5
  function O(i, t = 0) {
6
6
  return Atomics.load(i, t);
7
7
  }
8
- function m(i, t = 0, e, r) {
9
- Atomics.store(i, t, T(e, r));
8
+ function k(i, t = 0, e, r) {
9
+ Atomics.store(i, t, L(e, r));
10
10
  }
11
- function v(i, t = 0, e) {
11
+ function x(i, t = 0, e) {
12
12
  Atomics.store(i, t, e);
13
13
  }
14
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;
15
+ let a = L(s, o);
16
+ return Atomics.compareExchange(i, t, a, L(e, r)) === a;
17
17
  }
18
- function H(i, t, e, r) {
18
+ function V(i, t, e, r) {
19
19
  return Atomics.compareExchange(i, t, r, e) === r;
20
20
  }
21
- function g(i) {
21
+ function B(i) {
22
22
  return {
23
23
  bufferPosition: i & 4095,
24
24
  bufferByteOffset: i >>> 12
25
25
  };
26
26
  }
27
- function T(i, t) {
27
+ function L(i, t) {
28
28
  return i + (t << 12);
29
29
  }
30
30
  class h {
@@ -34,7 +34,7 @@ class h {
34
34
  return this.data.byteOffset;
35
35
  }
36
36
  get pointer() {
37
- return T(this.bufferPosition, this.bufferByteOffset);
37
+ return L(this.bufferPosition, this.bufferByteOffset);
38
38
  }
39
39
  buffer;
40
40
  data;
@@ -60,15 +60,15 @@ class h {
60
60
  };
61
61
  }
62
62
  }
63
- const j = 0, D = 1;
64
- function x(i, t = 0) {
65
- for (; Atomics.compareExchange(i, t, j, D) !== j; )
66
- "WorkerGlobalScope" in self && Atomics.wait(i, t, D);
63
+ const j = 0, F = 1;
64
+ function z(i, t = 0) {
65
+ for (; Atomics.compareExchange(i, t, j, F) !== j; )
66
+ "WorkerGlobalScope" in self && Atomics.wait(i, t, F);
67
67
  }
68
- function A(i, t = 0) {
69
- Atomics.compareExchange(i, t, D, j) !== D && console.warn("We are unlocking when it was not locked!"), Atomics.notify(i, t);
68
+ function g(i, t = 0) {
69
+ Atomics.compareExchange(i, t, F, j) !== F && console.warn("We are unlocking when it was not locked!"), Atomics.notify(i, t);
70
70
  }
71
- const ye = 1, Vt = {
71
+ const de = 1, Vt = {
72
72
  5120: "i8",
73
73
  5121: "u8",
74
74
  5122: "i16",
@@ -103,8 +103,8 @@ function jt(i, ...t) {
103
103
  const e = Zt[i];
104
104
  return new (e || Wt[vt(i)])(...t);
105
105
  }
106
- const it = 0, st = 1, ot = 2, nt = 3, at = 4, k = 5, ft = 6, V = 1, K = 2, lt = 32, G = 0, X = 1, y = 8;
107
- class Z {
106
+ const it = 0, st = 1, ot = 2, at = 3, nt = 4, A = 5, lt = 6, K = 1, G = 2, ft = 32, X = 0, Z = 1, y = 8;
107
+ class W {
108
108
  buf;
109
109
  start;
110
110
  u8;
@@ -112,7 +112,7 @@ class Z {
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 ? 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, lt / 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 ? I(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, ft / 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`);
@@ -159,48 +159,48 @@ class Z {
159
159
  malloc(t) {
160
160
  if (t <= 0)
161
161
  return 0;
162
- x(this.lock);
163
- const e = P(t + y, this.align), r = this.end;
164
- let s = this.top, o = this._free, n = 0;
162
+ z(this.lock);
163
+ const e = I(t + y, this.align), r = this.end;
164
+ let s = this.top, o = this._free, a = 0;
165
165
  for (; o; ) {
166
- const f = this.blockSize(o), a = o + f >= s;
167
- if (a || f >= e) {
168
- let l = this.mallocTop(
166
+ const l = this.blockSize(o), n = o + l >= s;
167
+ if (n || l >= e) {
168
+ let f = this.mallocTop(
169
169
  o,
170
- n,
171
- f,
170
+ a,
171
+ l,
172
172
  e,
173
- a
173
+ n
174
174
  );
175
- return A(this.lock), l;
175
+ return g(this.lock), f;
176
176
  }
177
- n = o, o = this.blockNext(o);
177
+ a = o, o = this.blockNext(o);
178
178
  }
179
179
  if (o = s, s = o + e, s <= r) {
180
180
  this.initBlock(o, e, this._used), this._used = o, this.top = s;
181
- let f = _(o);
182
- return A(this.lock), f;
181
+ let l = _(o);
182
+ return g(this.lock), l;
183
183
  }
184
- return A(this.lock), 0;
184
+ return g(this.lock), 0;
185
185
  }
186
186
  mallocTop(t, e, r, s, o) {
187
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
189
  this.top = t + this.setBlockSize(t, s);
190
190
  else if (this.doSplit) {
191
- const n = r - s;
192
- n >= this.minSplit && this.splitBlock(t, s, n);
191
+ const a = r - s;
192
+ a >= this.minSplit && this.splitBlock(t, s, a);
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 = I(t);
200
- let s = 0, o = this._used, n = 0;
199
+ const r = C(t);
200
+ let s = 0, o = this._used, a = 0;
201
201
  for (; o; ) {
202
202
  if (o === r) {
203
- [s, n] = this.reallocBlock(o, e);
203
+ [s, a] = this.reallocBlock(o, e);
204
204
  break;
205
205
  }
206
206
  o = this.blockNext(o);
@@ -208,19 +208,19 @@ class Z {
208
208
  return s && s !== r && this.u8.copyWithin(
209
209
  _(s),
210
210
  _(r),
211
- n
211
+ a
212
212
  ), _(s);
213
213
  }
214
214
  reallocBlock(t, e) {
215
- const r = this.blockSize(t), s = t + r, o = s >= this.top, n = P(e + y, this.align);
216
- if (n <= r) {
215
+ const r = this.blockSize(t), s = t + r, o = s >= this.top, a = I(e + y, this.align);
216
+ if (a <= r) {
217
217
  if (this.doSplit) {
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);
218
+ const l = r - a;
219
+ l >= this.minSplit ? this.splitBlock(t, a, l) : o && (this.top = t + a);
220
+ } else o && (this.top = t + a);
221
221
  return [t, s];
222
222
  }
223
- return o && t + n < this.end ? (this.top = t + this.setBlockSize(t, n), [t, s]) : (this.free(t), [I(this.malloc(e)), s]);
223
+ return o && t + a < this.end ? (this.top = t + this.setBlockSize(t, a), [t, s]) : (this.free(t), [C(this.malloc(e)), s]);
224
224
  }
225
225
  reallocArray(t, e) {
226
226
  if (t.buffer !== this.buf)
@@ -239,7 +239,7 @@ class Z {
239
239
  e = t.byteOffset;
240
240
  } else
241
241
  e = t;
242
- e = I(e);
242
+ e = C(e);
243
243
  let r = this._used;
244
244
  for (; r; ) {
245
245
  if (r === e)
@@ -260,14 +260,14 @@ class Z {
260
260
  e = t.byteOffset;
261
261
  } else
262
262
  e = t;
263
- x(this.lock), e = I(e);
263
+ z(this.lock), e = C(e);
264
264
  let r = this._used, s = 0;
265
265
  for (; r; ) {
266
266
  if (r === e)
267
- return s ? this.unlinkBlock(s, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(), A(this.lock), !0;
267
+ return s ? this.unlinkBlock(s, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(), g(this.lock), !0;
268
268
  s = r, r = this.blockNext(r);
269
269
  }
270
- return A(this.lock), !1;
270
+ return g(this.lock), !1;
271
271
  }
272
272
  freeAll() {
273
273
  this._free = 0, this._used = 0, this.top = this.initialTop();
@@ -276,16 +276,16 @@ class Z {
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[at];
279
+ return this.state[nt];
280
280
  }
281
281
  set align(t) {
282
- this.state[at] = t;
282
+ this.state[nt] = t;
283
283
  }
284
284
  get end() {
285
- return this.state[nt];
285
+ return this.state[at];
286
286
  }
287
287
  set end(t) {
288
- this.state[nt] = t;
288
+ this.state[at] = t;
289
289
  }
290
290
  get top() {
291
291
  return Atomics.load(this.state, ot);
@@ -306,27 +306,27 @@ class Z {
306
306
  Atomics.store(this.state, st, t);
307
307
  }
308
308
  get doCompact() {
309
- return !!(this.state[k] & V);
309
+ return !!(this.state[A] & K);
310
310
  }
311
311
  set doCompact(t) {
312
- t ? this.state[k] |= 1 << V - 1 : this.state[k] &= ~V;
312
+ t ? this.state[A] |= 1 << K - 1 : this.state[A] &= ~K;
313
313
  }
314
314
  get doSplit() {
315
- return !!(this.state[k] & K);
315
+ return !!(this.state[A] & G);
316
316
  }
317
317
  set doSplit(t) {
318
- t ? this.state[k] |= 1 << K - 1 : this.state[k] &= ~K;
318
+ t ? this.state[A] |= 1 << G - 1 : this.state[A] &= ~G;
319
319
  }
320
320
  get minSplit() {
321
- return this.state[ft];
321
+ return this.state[lt];
322
322
  }
323
323
  set minSplit(t) {
324
324
  if (t <= y)
325
325
  throw new Error(`illegal min split threshold: ${t}, require at least ${y + 1}`);
326
- this.state[ft] = t;
326
+ this.state[lt] = t;
327
327
  }
328
328
  blockSize(t) {
329
- return Atomics.load(this.u32, (t >> 2) + G);
329
+ return Atomics.load(this.u32, (t >> 2) + X);
330
330
  }
331
331
  /**
332
332
  * Sets & returns given block size.
@@ -335,10 +335,10 @@ class Z {
335
335
  * @param size -
336
336
  */
337
337
  setBlockSize(t, e) {
338
- return Atomics.store(this.u32, (t >> 2) + G, e), e;
338
+ return Atomics.store(this.u32, (t >> 2) + X, e), e;
339
339
  }
340
340
  blockNext(t) {
341
- return Atomics.load(this.u32, (t >> 2) + X);
341
+ return Atomics.load(this.u32, (t >> 2) + Z);
342
342
  }
343
343
  /**
344
344
  * Sets block next pointer to `next`. Use zero to indicate list end.
@@ -346,7 +346,7 @@ class Z {
346
346
  * @param block -
347
347
  */
348
348
  setBlockNext(t, e) {
349
- Atomics.store(this.u32, (t >> 2) + X, e);
349
+ Atomics.store(this.u32, (t >> 2) + Z, e);
350
350
  }
351
351
  /**
352
352
  * Initializes block header with given `size` and `next` pointer. Returns `block`.
@@ -357,7 +357,7 @@ class Z {
357
357
  */
358
358
  initBlock(t, e, r) {
359
359
  const s = t >>> 2;
360
- return Atomics.store(this.u32, s + G, e), Atomics.store(this.u32, s + X, r), t;
360
+ return Atomics.store(this.u32, s + X, e), Atomics.store(this.u32, s + Z, r), t;
361
361
  }
362
362
  unlinkBlock(t, e) {
363
363
  this.setBlockNext(t, this.blockNext(e));
@@ -372,7 +372,7 @@ class Z {
372
372
  ), this.doCompact && this.compact();
373
373
  }
374
374
  initialTop(t = this.align) {
375
- return P(this.start + lt + y, t) - y;
375
+ return I(this.start + ft + y, t) - y;
376
376
  }
377
377
  /**
378
378
  * Traverses free list and attempts to recursively merge blocks
@@ -385,15 +385,15 @@ class Z {
385
385
  for (s = t, r = this.blockNext(t); r && s + this.blockSize(s) === r; )
386
386
  s = r, r = this.blockNext(r);
387
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;
388
+ const a = s - t + this.blockSize(s);
389
+ this.setBlockSize(t, a);
390
+ const l = this.blockNext(s);
391
+ let n = this.blockNext(t);
392
+ for (; n && n !== l; ) {
393
+ const f = this.blockNext(n);
394
+ this.setBlockNext(n, 0), n = f;
395
395
  }
396
- this.setBlockNext(t, f), o = !0;
396
+ this.setBlockNext(t, l), o = !0;
397
397
  }
398
398
  t + this.blockSize(t) >= this.top && (this.top = t, e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t)), e = t, t = this.blockNext(t);
399
399
  }
@@ -411,7 +411,7 @@ class Z {
411
411
  r ? this.setBlockNext(r, t) : this._free = t, this.setBlockNext(t, e);
412
412
  }
413
413
  }
414
- const _ = (i) => i > 0 ? i + y : 0, I = (i) => i > 0 ? i - y : 0, P = (i, t) => (t--, i + t & ~t), qt = {
414
+ const _ = (i) => i > 0 ? i + y : 0, C = (i) => i > 0 ? i - y : 0, I = (i, t) => (t--, i + t & ~t), qt = {
415
415
  u8: 1,
416
416
  u8c: 1,
417
417
  i8: 1,
@@ -503,29 +503,29 @@ function oe(i, t) {
503
503
  };
504
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
505
  if (t.signed && s) {
506
- const l = ` 0${r}${e[0]}`;
507
- return ct(l, t.fixedWidth);
506
+ const f = ` 0${r}${e[0]}`;
507
+ return ct(f, t.fixedWidth);
508
508
  }
509
- const o = i < 0, n = o ? "-" : t.signed ? "+" : "";
509
+ const o = i < 0, a = o ? "-" : t.signed ? "+" : "";
510
510
  o && (i = -i);
511
- const f = se(t);
512
- let a;
511
+ const l = se(t);
512
+ let n;
513
513
  if (i < 1) {
514
- const l = ht(i, t.locale, f);
515
- a = n + l + r + e[0];
514
+ const f = ht(i, t.locale, l);
515
+ n = a + f + r + e[0];
516
516
  } else {
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) {
517
+ const f = 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) ** f), !l) {
519
519
  const M = Math.max(3, Math.floor(i).toString().length);
520
520
  i = i.toPrecision(M);
521
521
  }
522
- const S = ht(Number(i), t.locale, f), Y = e[l];
523
- a = n + S + r + Y;
522
+ const T = ht(Number(i), t.locale, l), H = e[f];
523
+ n = a + T + r + H;
524
524
  }
525
- return ct(a, t.fixedWidth);
525
+ return ct(n, t.fixedWidth);
526
526
  }
527
- const ne = 8192, ut = 0, W = 1, N = 2;
528
- class de {
527
+ const ae = 8192, ut = 0, v = 1, N = 2;
528
+ class ye {
529
529
  buffers;
530
530
  onGrowBufferHandlers = [];
531
531
  isClone;
@@ -535,7 +535,7 @@ class de {
535
535
  }
536
536
  constructor(t) {
537
537
  if (t && "buffers" in t)
538
- this.buffers = t.buffers.map((e) => new Z({
538
+ this.buffers = t.buffers.map((e) => new W({
539
539
  buf: e,
540
540
  skipInitialization: !0
541
541
  })), this.memory = new h(this, {
@@ -544,7 +544,7 @@ class de {
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 ?? ne;
547
+ const e = t?.bufferSize ?? ae;
548
548
  if (e > et)
549
549
  throw new Error(`Buffer size ${e} is greater than max ${et} that we can reference with pointers`);
550
550
  let r = this.createBuffer(e);
@@ -559,20 +559,20 @@ class de {
559
559
  });
560
560
  else
561
561
  throw new Error("Failed to initialize first byte from buffer");
562
- this.memory.data[ut] = e, this.memory.data[W] = 1, this.memory.data[N] = t?.autoGrowSize ?? 100, this.isClone = !1;
562
+ this.memory.data[ut] = e, this.memory.data[v] = 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 Z({
568
+ this.buffers[t.bufferPosition] = new W({
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, W, 1);
575
+ let e = Atomics.add(this.memory.data, v, 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 de {
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 Z({
584
+ return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new W({
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
@@ -599,10 +599,10 @@ class de {
599
599
  const o = this.buffers[s];
600
600
  if (!o)
601
601
  continue;
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,
602
+ const a = o.callocAs("u32", t);
603
+ if (a)
604
+ return s === this.buffers.length - 1 && Atomics.load(this.memory.data, v) === 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: a,
606
606
  buffer: o
607
607
  });
608
608
  }
@@ -628,7 +628,7 @@ class de {
628
628
  return this.buffers[0].buf.byteLength * this.buffers.length;
629
629
  }
630
630
  prettyMemory() {
631
- return `${yt(this.currentUsed)} / ${yt(this.totalAllocated)}`;
631
+ return `${dt(this.currentUsed)} / ${dt(this.totalAllocated)}`;
632
632
  }
633
633
  getSharedMemory() {
634
634
  return {
@@ -636,16 +636,16 @@ class de {
636
636
  };
637
637
  }
638
638
  }
639
- function yt(i) {
639
+ function dt(i) {
640
640
  return oe(i, {
641
641
  binary: !0,
642
642
  minimumFractionDigits: 1,
643
643
  maximumFractionDigits: 1
644
644
  });
645
645
  }
646
- const dt = 4, Bt = 1, E = 2;
646
+ const yt = 4, Bt = 1, p = 2;
647
647
  class u {
648
- static ALLOCATE_COUNT = dt;
648
+ static ALLOCATE_COUNT = yt;
649
649
  memory;
650
650
  /* First block
651
651
  32 index 0
@@ -670,7 +670,7 @@ class u {
670
670
  uint16Array;
671
671
  onDelete;
672
672
  get length() {
673
- return Atomics.load(this.firstBlock.data, E);
673
+ return Atomics.load(this.firstBlock.data, p);
674
674
  }
675
675
  get type() {
676
676
  return Atomics.load(this.uint16Array, 0);
@@ -686,9 +686,9 @@ class u {
686
686
  }
687
687
  constructor(t, e) {
688
688
  if (this.memory = t, e && "firstBlock" in e)
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);
689
+ this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (p + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
690
690
  else {
691
- e && e.initWithBlock ? this.firstBlock = new h(t, e.initWithBlock) : this.firstBlock = t.allocUI32(dt), 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(yt), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (p + 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
  }
@@ -699,17 +699,17 @@ class u {
699
699
  if (t.length > e)
700
700
  throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
701
701
  let r = this.memory.allocUI32(Bt + 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
- for (; !f; )
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
- v(S, 0, o);
702
+ for (let n = 0; n < t.length; n++)
703
+ s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s, n, t[n]) : s[n] = t[n];
704
+ let a, l = !1;
705
+ for (; !l; )
706
+ a = O(this.firstBlock.data, 1), l = V(this.firstBlock.data, 1, o, a);
707
+ if (a) {
708
+ let { bufferPosition: n, bufferByteOffset: f } = B(a), T = new Uint32Array(this.memory.buffers[n].buf, f, 1);
709
+ x(T, 0, o);
710
710
  } else
711
- v(this.firstBlock.data, 0, o);
712
- Atomics.add(this.firstBlock.data, E, 1);
711
+ x(this.firstBlock.data, 0, o);
712
+ Atomics.add(this.firstBlock.data, p, 1);
713
713
  }
714
714
  deleteMatch(t) {
715
715
  for (let { data: e, index: r, deleteCurrent: s } of this)
@@ -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 = H(this.firstBlock.data, 1, 0, e);
738
+ r = V(this.firstBlock.data, 1, 0, e);
739
739
  }
740
740
  if (!t)
741
741
  return;
742
- H(this.firstBlock.data, 0, 0, t);
742
+ V(this.firstBlock.data, 0, 0, t);
743
743
  let s = 0, o = t;
744
744
  for (; o; ) {
745
- let { bufferPosition: n, bufferByteOffset: f } = g(o), a = this.memory.buffers[n];
746
- if (!a)
745
+ let { bufferPosition: a, bufferByteOffset: l } = B(o), n = this.memory.buffers[a];
746
+ if (!n)
747
747
  break;
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);
748
+ let f = new Uint32Array(n.buf, l, 2);
749
+ o = O(f, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(f)), n.free(f.byteOffset);
750
750
  }
751
- Atomics.sub(this.firstBlock.data, E, s);
751
+ Atomics.sub(this.firstBlock.data, p, s);
752
752
  }
753
753
  *[Symbol.iterator]() {
754
- let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0, n = 0;
754
+ let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0, a = 0;
755
755
  for (; r; ) {
756
- let f = this.memory.buffers[e];
757
- if (!f)
756
+ let l = this.memory.buffers[e];
757
+ if (!l)
758
758
  return;
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));
759
+ let n = new Uint32Array(l.buf, r, 2), f = this.getDataBlock(n), T = e, H = r;
760
+ ({ bufferPosition: e, bufferByteOffset: r } = c(n, 0));
761
761
  let M = !0;
762
762
  yield {
763
- data: l,
763
+ data: f,
764
764
  index: t,
765
765
  deleteCurrent: () => {
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;
766
+ k(s, 0, e, r), r || k(this.firstBlock.data, 1, o, a), this.onDelete && this.onDelete(this.getDataBlock(n)), l.free(n.byteOffset), Atomics.sub(this.firstBlock.data, p, 1), M = !1;
767
767
  }
768
- }, M && (s = a, o = S, n = Y, t++);
768
+ }, M && (s = n, o = T, a = H, t++);
769
769
  }
770
770
  }
771
771
  forEach(t) {
@@ -824,78 +824,78 @@ class Ot {
824
824
  else {
825
825
  this.pointerMemory = t.allocUI32(Ot.ALLOCATE_COUNT);
826
826
  let r = t.allocUI32(mt);
827
- m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, mt);
827
+ k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, mt);
828
828
  }
829
829
  this.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);
830
830
  }
831
831
  set(t, e) {
832
832
  this.length >= this.maxHash * 2 && this.growHashTable();
833
- let r = C(t);
833
+ let r = P(t);
834
834
  this.setHashKey(this.hashMemory, this.maxHash, r, e) && Atomics.add(this.pointerMemory.data, 2, 1);
835
835
  }
836
836
  setHashKey(t, e, r, s) {
837
- let o = this.hash(r, e), n, f = c(t.data, o);
838
- if (f.bufferByteOffset === 0) {
839
- n = new u(this.memory, {
837
+ let o = this.hash(r, e), a, l = c(t.data, o);
838
+ if (l.bufferByteOffset === 0) {
839
+ a = new u(this.memory, {
840
840
  dataLength: 2
841
841
  });
842
- let l = n.getSharedMemory();
843
- m(t.data, o, l.firstBlock.bufferPosition, l.firstBlock.bufferByteOffset);
842
+ let f = a.getSharedMemory();
843
+ k(t.data, o, f.firstBlock.bufferPosition, f.firstBlock.bufferByteOffset);
844
844
  } else
845
- n = new u(this.memory, {
846
- firstBlock: f
845
+ a = new u(this.memory, {
846
+ firstBlock: l
847
847
  });
848
- let a = !0;
849
- return n.deleteValue(r) && (a = !1), n.insert([r, s]), a;
848
+ let n = !0;
849
+ return a.deleteValue(r) && (n = !1), a.insert([r, s]), n;
850
850
  }
851
851
  get(t) {
852
- let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
852
+ let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
853
853
  if (s.bufferByteOffset === 0)
854
854
  return;
855
855
  let o = new u(this.memory, {
856
856
  firstBlock: s
857
857
  });
858
- for (let { data: n } of o)
859
- if (n[0] === e)
860
- return n[1];
858
+ for (let { data: a } of o)
859
+ if (a[0] === e)
860
+ return a[1];
861
861
  }
862
862
  has(t) {
863
- let e = C(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
863
+ let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
864
864
  if (s.bufferByteOffset === 0)
865
865
  return !1;
866
866
  let o = new u(this.memory, {
867
867
  firstBlock: s
868
868
  });
869
- for (let { data: n } of o)
870
- if (n[0] === e)
869
+ for (let { data: a } of o)
870
+ if (a[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), s = c(this.hashMemory.data, r);
875
+ let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
876
876
  if (s.bufferByteOffset === 0)
877
877
  return !1;
878
878
  let o = new u(this.memory, {
879
879
  firstBlock: s
880
880
  });
881
- for (let { data: n, deleteCurrent: f } of o)
882
- if (n[0] === e)
883
- return f(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
881
+ for (let { data: a, deleteCurrent: l } of o)
882
+ if (a[0] === e)
883
+ return l(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
884
884
  return !1;
885
885
  }
886
886
  growHashTable() {
887
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 n = c(s.data, o);
890
- if (n.bufferByteOffset === 0)
889
+ let a = c(s.data, o);
890
+ if (a.bufferByteOffset === 0)
891
891
  continue;
892
- let f = new u(this.memory, {
893
- firstBlock: n
892
+ let l = new u(this.memory, {
893
+ firstBlock: a
894
894
  });
895
- for (let { data: a } of f)
896
- this.setHashKey(r, e, a[0], a[1]);
895
+ for (let { data: n } of l)
896
+ this.setHashKey(r, e, n[0], n[1]);
897
897
  }
898
- m(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
898
+ k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
899
899
  }
900
900
  hash(t, e) {
901
901
  return t % e;
@@ -917,10 +917,10 @@ class Ot {
917
917
  };
918
918
  }
919
919
  }
920
- function C(i) {
921
- return typeof i == "number" ? i : typeof i == "string" ? ae(i) : i;
920
+ function P(i) {
921
+ return typeof i == "number" ? i : typeof i == "string" ? ne(i) : i;
922
922
  }
923
- function ae(i) {
923
+ function ne(i) {
924
924
  let t = i.length, e = 17 ^ t, r = 0, s;
925
925
  for (; t >= 4; )
926
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;
@@ -944,10 +944,10 @@ class Be {
944
944
  return this.list.length;
945
945
  }
946
946
  insert(t) {
947
- this.list.insert(T(t.memory.bufferPosition, t.memory.bufferByteOffset));
947
+ this.list.insert(L(t.memory.bufferPosition, t.memory.bufferByteOffset));
948
948
  }
949
949
  delete(t) {
950
- return this.list.deleteValue(T(t.memory.bufferPosition, t.memory.bufferByteOffset));
950
+ return this.list.deleteValue(L(t.memory.bufferPosition, t.memory.bufferByteOffset));
951
951
  }
952
952
  *[Symbol.iterator]() {
953
953
  let t = this.list[Symbol.iterator]();
@@ -980,7 +980,7 @@ class Be {
980
980
  const bt = {
981
981
  1: Uint8Array,
982
982
  2: Uint16Array
983
- }, U = 0, At = 1, gt = 2, kt = 3;
983
+ }, U = 0, gt = 1, kt = 2, At = 3;
984
984
  class Mt {
985
985
  static ALLOCATE_COUNT = 4;
986
986
  memory;
@@ -989,11 +989,11 @@ class Mt {
989
989
  cachedPointer;
990
990
  cachedString;
991
991
  constructor(t, e) {
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 + kt * 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 + kt * 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 + At * 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 + At * 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), v(this.allocatedMemory.data, U, e.pointer), Atomics.store(this.allocatedMemory.data, At, t.length), Atomics.store(this.allocatedMemory.data, gt, e.charType), A(this.lock), this.cachedPointer = e.pointer, this.cachedString = t;
996
+ z(this.lock), x(this.allocatedMemory.data, U, e.pointer), Atomics.store(this.allocatedMemory.data, gt, t.length), Atomics.store(this.allocatedMemory.data, kt, e.charType), g(this.lock), this.cachedPointer = e.pointer, this.cachedString = t;
997
997
  }
998
998
  createString(t) {
999
999
  if (t === "")
@@ -1003,13 +1003,13 @@ class Mt {
1003
1003
  /* ASCII */
1004
1004
  };
1005
1005
  let e = [];
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 = bt[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);
1006
+ for (let n = 0; n < t.length; n++)
1007
+ e.push(t.charCodeAt(n));
1008
+ let s = Math.max(...e) > 255 ? 2 : 1, o = bt[s], a = this.memory.allocUI32(Math.ceil(t.length / (4 / o.BYTES_PER_ELEMENT))), l = new o(a.data.buffer, a.data.byteOffset, t.length);
1009
+ for (let n = 0; n < t.length; n++)
1010
+ l[n] = t.charCodeAt(n);
1011
1011
  return {
1012
- pointer: n.pointer,
1012
+ pointer: a.pointer,
1013
1013
  charType: s
1014
1014
  };
1015
1015
  }
@@ -1019,10 +1019,10 @@ class Mt {
1019
1019
  return this.cachedString;
1020
1020
  if (t === 0)
1021
1021
  return "";
1022
- let { bufferPosition: e, bufferByteOffset: r } = g(t);
1023
- x(this.lock);
1024
- let s = Atomics.load(this.allocatedMemory.data, gt), o = bt[s], n = Atomics.load(this.allocatedMemory.data, At), 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;
1022
+ let { bufferPosition: e, bufferByteOffset: r } = B(t);
1023
+ z(this.lock);
1024
+ let s = Atomics.load(this.allocatedMemory.data, kt), o = bt[s], a = Atomics.load(this.allocatedMemory.data, gt), l = new o(this.memory.buffers[e].buf, r, a), n = String.fromCharCode.apply(null, l);
1025
+ return g(this.lock), this.cachedPointer = t, this.cachedString = n, n;
1026
1026
  }
1027
1027
  set value(t) {
1028
1028
  let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data, U);
@@ -1039,15 +1039,15 @@ class Mt {
1039
1039
  e && this.memory.buffers[t].free(e), this.allocatedMemory.free();
1040
1040
  }
1041
1041
  }
1042
- const w = 0, b = 1, Et = 2, wt = 3, pt = 4;
1043
- class d {
1042
+ const E = 0, d = 1, pt = 2, Et = 3, wt = 4;
1043
+ class m {
1044
1044
  static ALLOCATE_COUNT = 4;
1045
1045
  memory;
1046
1046
  // Pointer, List Length, Buffer Length, Type/DataLength
1047
1047
  firstBlock;
1048
1048
  uint16Array;
1049
1049
  get length() {
1050
- return Atomics.load(this.firstBlock.data, b);
1050
+ return Atomics.load(this.firstBlock.data, d);
1051
1051
  }
1052
1052
  get type() {
1053
1053
  return this.uint16Array[0];
@@ -1056,16 +1056,16 @@ class d {
1056
1056
  Atomics.store(this.uint16Array, 0, t);
1057
1057
  }
1058
1058
  get dataLength() {
1059
- return Math.max(1, this.uint16Array[1]);
1059
+ return this.uint16Array[1] || 1;
1060
1060
  }
1061
1061
  set dataLength(t) {
1062
1062
  Atomics.store(this.uint16Array, 1, t);
1063
1063
  }
1064
1064
  get bufferLength() {
1065
- return Atomics.load(this.firstBlock.data, Et);
1065
+ return Atomics.load(this.firstBlock.data, pt);
1066
1066
  }
1067
1067
  set bufferLength(t) {
1068
- Atomics.store(this.firstBlock.data, Et, t);
1068
+ Atomics.store(this.firstBlock.data, pt, t);
1069
1069
  }
1070
1070
  get pointer() {
1071
1071
  return this.firstBlock.pointer;
@@ -1074,21 +1074,21 @@ class d {
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 + wt * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
1078
- const r = e.bufferLength ?? pt;
1077
+ if (this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
1078
+ const r = e.bufferLength ?? wt;
1079
1079
  let s = t.allocUI32(r * (e.dataLength ?? 1));
1080
- m(this.firstBlock.data, w, s.bufferPosition, s.bufferByteOffset), this.bufferLength = r, this.dataLength = e.dataLength ?? 1;
1080
+ k(this.firstBlock.data, E, s.bufferPosition, s.bufferByteOffset), this.bufferLength = r, this.dataLength = e.dataLength ?? 1;
1081
1081
  }
1082
1082
  if ("type" in e) {
1083
1083
  const r = e?.type ?? Uint32Array;
1084
1084
  r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2);
1085
1085
  }
1086
1086
  } else {
1087
- this.firstBlock = t.allocUI32(d.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + wt * Uint32Array.BYTES_PER_ELEMENT, 2);
1088
- let r = e?.dataLength ?? 1, s = e?.bufferLength ?? pt, o = t.allocUI32(s * r);
1089
- m(this.firstBlock.data, w, o.bufferPosition, o.bufferByteOffset), this.bufferLength = s;
1090
- const n = e?.type ?? Uint32Array;
1091
- n === Uint32Array ? this.type = 0 : n === Int32Array ? this.type = 1 : n === Float32Array && (this.type = 2), this.dataLength = r;
1087
+ this.firstBlock = t.allocUI32(m.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT, 2);
1088
+ let r = e?.dataLength ?? 1, s = e?.bufferLength ?? wt, o = t.allocUI32(s * r);
1089
+ k(this.firstBlock.data, E, o.bufferPosition, o.bufferByteOffset), this.bufferLength = s;
1090
+ const a = e?.type ?? Uint32Array;
1091
+ a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r;
1092
1092
  }
1093
1093
  this.cachedPointer = this.firstBlock.data[0], this.cachedFullDataBlock = this.getFullDataBlock();
1094
1094
  }
@@ -1107,40 +1107,49 @@ class d {
1107
1107
  return this.getFullDataBlock()[t * this.dataLength + e];
1108
1108
  }
1109
1109
  push(t) {
1110
- typeof t == "number" && (t = [t]);
1111
1110
  let e = this.dataLength;
1112
- if (t.length > e)
1111
+ const r = typeof t == "number";
1112
+ if (!r && t.length > e)
1113
1113
  throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
1114
- let r = this.getFullDataBlock(), s = this.length;
1115
- return r.set(t, e * s), Atomics.add(this.firstBlock.data, b, 1) + 1 >= this.bufferLength && this.growBuffer(), s;
1114
+ let s = this.getFullDataBlock(), o = this.length, a = e * o;
1115
+ return r ? s[a] = t : s.set(t, a), Atomics.add(this.firstBlock.data, d, 1) + 1 >= this.bufferLength && this.growBuffer(), o;
1116
1116
  }
1117
1117
  pop() {
1118
- let t = Atomics.sub(this.firstBlock.data, b, b), e = this.getFullDataBlock();
1118
+ let t = Atomics.sub(this.firstBlock.data, d, d), e = this.getFullDataBlock();
1119
1119
  return this.getDataBlock(e, t - 1);
1120
1120
  }
1121
+ // Returns the first number irregardless of dataLength - faster way to pop if you don't care about the rest of the data block
1122
+ popNumber() {
1123
+ const t = Atomics.sub(this.firstBlock.data, d, d);
1124
+ return this.getFullDataBlock()[(t - 1) * this.dataLength];
1125
+ }
1121
1126
  deleteIndex(t) {
1122
1127
  let e = this.length;
1123
1128
  if (t >= e || t < 0)
1124
1129
  throw new Error(`${t} is out of bounds ${e}`);
1125
1130
  let r = this.dataLength, s = this.getFullDataBlock();
1126
1131
  for (let o = t; o < e; o++)
1127
- for (let n = 0; n < r; n++)
1128
- s[o * r + n] = s[(o + 1) * r + n];
1129
- Atomics.sub(this.firstBlock.data, b, b);
1132
+ for (let a = 0; a < r; a++)
1133
+ s[o * r + a] = s[(o + 1) * r + a];
1134
+ Atomics.sub(this.firstBlock.data, d, d);
1130
1135
  }
1131
1136
  clear() {
1132
- this.firstBlock.data[b] = 0;
1137
+ this.firstBlock.data[d] = 0;
1133
1138
  }
1134
1139
  *[Symbol.iterator]() {
1135
- let t = this.getFullDataBlock();
1136
- for (let e = 0; e < this.length; e++)
1137
- yield this.getDataBlock(t, e);
1140
+ let t = this.getFullDataBlock(), e = this.dataLength;
1141
+ for (let r = 0; r < this.length; r += e)
1142
+ yield t.subarray(r, r + e);
1143
+ }
1144
+ // Significantly faster but won't be thread safe if anything is removing/adding to it during iteration
1145
+ getCurrentArray() {
1146
+ return this.getFullDataBlock().subarray(0, this.length * this.dataLength);
1138
1147
  }
1139
1148
  getFullDataBlock() {
1140
- let t = Atomics.load(this.firstBlock.data, w);
1149
+ let t = Atomics.load(this.firstBlock.data, E);
1141
1150
  if (this.cachedPointer === t && this.cachedFullDataBlock)
1142
1151
  return this.cachedFullDataBlock;
1143
- let e = g(t), r = new h(this.memory, e), s;
1152
+ let e = B(t), r = new h(this.memory, e), s;
1144
1153
  switch (this.type) {
1145
1154
  case 1:
1146
1155
  s = new Int32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
@@ -1161,24 +1170,26 @@ class d {
1161
1170
  return t.subarray(r, r + this.dataLength);
1162
1171
  }
1163
1172
  growBuffer() {
1164
- 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;
1173
+ let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, E), o = new h(this.memory, s), a = this.getFullDataBlock(), l = this.memory.allocUI32(e * r), n;
1165
1174
  switch (this.type) {
1166
1175
  case 1:
1167
- a = new Int32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1176
+ n = new Int32Array(l.data.buffer, l.bufferByteOffset, r * e);
1168
1177
  break;
1169
1178
  case 0:
1170
- a = new Uint32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1179
+ n = new Uint32Array(l.data.buffer, l.bufferByteOffset, r * e);
1171
1180
  break;
1172
1181
  case 2:
1173
- a = new Float32Array(f.data.buffer, f.bufferByteOffset, r * this.bufferLength);
1182
+ n = new Float32Array(l.data.buffer, l.bufferByteOffset, r * e);
1174
1183
  break;
1175
1184
  default:
1176
1185
  throw new Error(`Unknown data block type ${this.type}`);
1177
1186
  }
1178
- a.set(n), m(this.firstBlock.data, w, f.bufferPosition, f.bufferByteOffset), this.bufferLength = e, o.free();
1187
+ n.set(a);
1188
+ const f = l.pointer;
1189
+ x(this.firstBlock.data, E, f), this.bufferLength = e, o.free(), this.cachedPointer = f, this.cachedFullDataBlock = n;
1179
1190
  }
1180
1191
  free() {
1181
- let t = c(this.firstBlock.data, w);
1192
+ let t = c(this.firstBlock.data, E);
1182
1193
  new h(this.memory, t).free(), this.firstBlock.free();
1183
1194
  }
1184
1195
  getSharedMemory() {
@@ -1258,9 +1269,9 @@ class me {
1258
1269
  this.list.free(), this.cache.clear();
1259
1270
  }
1260
1271
  }
1261
- const F = 0, Tt = 1, Lt = 2, q = 3, St = q + d.ALLOCATE_COUNT;
1262
- class It {
1263
- static ALLOCATE_COUNT = 3 + d.ALLOCATE_COUNT * 2;
1272
+ const D = 0, Lt = 1, St = 2, q = 3, Tt = q + m.ALLOCATE_COUNT;
1273
+ class Ct {
1274
+ static ALLOCATE_COUNT = 3 + m.ALLOCATE_COUNT * 2;
1264
1275
  memory;
1265
1276
  // Current Length, Type/DataLength, MaxChunkLength, Pointer vector, Recycle vector
1266
1277
  firstBlock;
@@ -1269,13 +1280,13 @@ class It {
1269
1280
  recycleVector;
1270
1281
  cachedFullDataBlock = {};
1271
1282
  get length() {
1272
- return Atomics.load(this.firstBlock.data, F) - this.recycleVector.length;
1283
+ return Atomics.load(this.firstBlock.data, D) - this.recycleVector.length;
1273
1284
  }
1274
1285
  get maxChunkSize() {
1275
- return this.firstBlock.data[Lt];
1286
+ return this.firstBlock.data[St];
1276
1287
  }
1277
1288
  set maxChunkSize(t) {
1278
- Atomics.store(this.firstBlock.data, Lt, t);
1289
+ Atomics.store(this.firstBlock.data, St, t);
1279
1290
  }
1280
1291
  get type() {
1281
1292
  return this.uint16Array[0];
@@ -1300,38 +1311,38 @@ class It {
1300
1311
  }
1301
1312
  constructor(t, e) {
1302
1313
  if (this.memory = t, e && "firstBlock" in e)
1303
- 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, {
1314
+ this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Lt * Uint32Array.BYTES_PER_ELEMENT, 2), this.pointerVector = new m(t, {
1304
1315
  firstBlock: {
1305
1316
  bufferPosition: this.firstBlock.bufferPosition,
1306
1317
  bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
1307
1318
  }
1308
- }), this.recycleVector = new d(t, {
1319
+ }), this.recycleVector = new m(t, {
1309
1320
  firstBlock: {
1310
1321
  bufferPosition: this.firstBlock.bufferPosition,
1311
- bufferByteOffset: this.firstBlock.bufferByteOffset + St * Uint32Array.BYTES_PER_ELEMENT
1322
+ bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
1312
1323
  }
1313
1324
  });
1314
1325
  else {
1315
- this.firstBlock = t.allocUI32(It.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT, 2);
1326
+ this.firstBlock = t.allocUI32(Ct.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Lt * Uint32Array.BYTES_PER_ELEMENT, 2);
1316
1327
  let r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
1317
- this.pointerVector = new d(t, {
1328
+ this.pointerVector = new m(t, {
1318
1329
  type: Uint32Array,
1319
1330
  firstBlock: {
1320
1331
  bufferPosition: this.firstBlock.bufferPosition,
1321
1332
  bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
1322
1333
  }
1323
- }), this.recycleVector = new d(t, {
1334
+ }), this.recycleVector = new m(t, {
1324
1335
  type: Uint32Array,
1325
1336
  firstBlock: {
1326
1337
  bufferPosition: this.firstBlock.bufferPosition,
1327
- bufferByteOffset: this.firstBlock.bufferByteOffset + St * Uint32Array.BYTES_PER_ELEMENT
1338
+ bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
1328
1339
  },
1329
1340
  bufferLength: e?.recycleBufferLength
1330
1341
  });
1331
1342
  const o = e?.type ?? Uint32Array;
1332
1343
  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;
1333
- let n = t.allocUI32(s * r * this.byteMultipler);
1334
- this.pointerVector.push(n.pointer);
1344
+ let a = t.allocUI32(s * r * this.byteMultipler);
1345
+ this.pointerVector.push(a.pointer);
1335
1346
  }
1336
1347
  }
1337
1348
  at(t) {
@@ -1350,7 +1361,7 @@ class It {
1350
1361
  if (t.length > e)
1351
1362
  throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
1352
1363
  let r;
1353
- this.recycleVector.length ? r = this.recycleVector.pop()[0] : r = Atomics.add(this.firstBlock.data, F, 1);
1364
+ this.recycleVector.length ? r = this.recycleVector.popNumber() : r = Atomics.add(this.firstBlock.data, D, 1);
1354
1365
  let s = this.getFullDataBlock(r), o = r % this.maxChunkSize;
1355
1366
  return s.set(t, e * o), r;
1356
1367
  }
@@ -1358,14 +1369,14 @@ class It {
1358
1369
  this.recycleVector.push(t);
1359
1370
  }
1360
1371
  clear() {
1361
- this.firstBlock.data[F] = 0, this.recycleVector.clear();
1372
+ this.firstBlock.data[D] = 0, this.recycleVector.clear();
1362
1373
  }
1363
1374
  *[Symbol.iterator]() {
1364
1375
  const t = {};
1365
1376
  for (let s of this.recycleVector)
1366
1377
  t[s[0]] = !0;
1367
1378
  let e = this.getFullDataBlock(0), r = 0;
1368
- for (let s = 0; s < Atomics.load(this.firstBlock.data, F); s++)
1379
+ for (let s = 0; s < Atomics.load(this.firstBlock.data, D); s++)
1369
1380
  if (!t[s]) {
1370
1381
  let o = Math.floor(s / this.maxChunkSize);
1371
1382
  o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
@@ -1376,10 +1387,10 @@ class It {
1376
1387
  if (r)
1377
1388
  return r;
1378
1389
  if (e >= this.pointerVector.length) {
1379
- let n = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1380
- this.pointerVector.push(n.pointer);
1390
+ let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1391
+ this.pointerVector.push(a.pointer);
1381
1392
  }
1382
- let s = new h(this.memory, g(this.pointerVector.get(e))), o;
1393
+ let s = new h(this.memory, B(this.pointerVector.get(e))), o;
1383
1394
  switch (this.type) {
1384
1395
  case 1:
1385
1396
  o = new Int32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
@@ -1406,7 +1417,7 @@ class It {
1406
1417
  this.recycleVector.free();
1407
1418
  for (let t of this.pointerVector) {
1408
1419
  let e = t[0];
1409
- new h(this.memory, g(e)).free();
1420
+ new h(this.memory, B(e)).free();
1410
1421
  }
1411
1422
  this.pointerVector.free(), this.firstBlock.free();
1412
1423
  }
@@ -1416,158 +1427,248 @@ class It {
1416
1427
  };
1417
1428
  }
1418
1429
  }
1419
- const Pt = new ArrayBuffer(4), Nt = new Uint32Array(Pt), R = new Uint16Array(Pt);
1420
- function be(i, t) {
1421
- return fe(Atomics.load(i, t));
1430
+ class be {
1431
+ memory;
1432
+ pointers = [];
1433
+ recycledIndexes = [];
1434
+ totalLength = 0;
1435
+ maxChunkSize = 100;
1436
+ dataLength = 1;
1437
+ byteMultipler = 1;
1438
+ typeConstructor;
1439
+ fullDataBlocks = {};
1440
+ get length() {
1441
+ return this.totalLength - this.recycledIndexes.length;
1442
+ }
1443
+ get bufferLength() {
1444
+ return this.maxChunkSize * this.pointers.length;
1445
+ }
1446
+ constructor(t, e) {
1447
+ this.memory = t;
1448
+ const r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
1449
+ this.dataLength = r, this.maxChunkSize = s, this.typeConstructor = e.type, this.typeConstructor === Float64Array && (this.byteMultipler = 2);
1450
+ let o = t.allocUI32(s * r * this.byteMultipler);
1451
+ this.pointers.push(o.pointer);
1452
+ let a = new this.typeConstructor(o.data.buffer, o.bufferByteOffset, this.dataLength * this.maxChunkSize);
1453
+ this.fullDataBlocks[0] = a;
1454
+ }
1455
+ at(t) {
1456
+ let e = this.fullDataBlocks[Math.floor(t / this.maxChunkSize)];
1457
+ return this.getDataBlock(e, t % this.maxChunkSize);
1458
+ }
1459
+ get(t, e = 0) {
1460
+ const r = this.dataLength;
1461
+ if (e >= r)
1462
+ throw new Error(`${e} is out of dataLength bounds ${r}`);
1463
+ return this.fullDataBlocks[Math.floor(t / this.maxChunkSize)][t % this.maxChunkSize * r + e];
1464
+ }
1465
+ push(t) {
1466
+ const e = typeof t == "number";
1467
+ if (!e && t.length > this.dataLength)
1468
+ throw new Error(`Can't insert ${t.length} array into shared list of ${this.dataLength} dataLength`);
1469
+ let r = this.recycledIndexes.pop();
1470
+ r === void 0 && (r = this.totalLength++);
1471
+ let s = Math.floor(r / this.maxChunkSize);
1472
+ if (s >= this.pointers.length) {
1473
+ let n = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1474
+ this.pointers.push(n.pointer);
1475
+ let f = new this.typeConstructor(n.data.buffer, n.bufferByteOffset, this.dataLength * this.maxChunkSize);
1476
+ this.fullDataBlocks[s] = f;
1477
+ }
1478
+ let o = this.fullDataBlocks[s], a = r % this.maxChunkSize, l = this.dataLength * a;
1479
+ return e ? o[l] = t : o.set(t, l), r;
1480
+ }
1481
+ deleteIndex(t) {
1482
+ this.recycledIndexes.push(t);
1483
+ }
1484
+ clear() {
1485
+ this.totalLength = 0, this.recycledIndexes = [];
1486
+ }
1487
+ *[Symbol.iterator]() {
1488
+ const t = {};
1489
+ for (let s of this.recycledIndexes)
1490
+ t[s] = !0;
1491
+ let e = this.getFullDataBlock(0), r = 0;
1492
+ for (let s = 0; s < this.totalLength; s++)
1493
+ if (!t[s]) {
1494
+ let o = Math.floor(s / this.maxChunkSize);
1495
+ o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
1496
+ }
1497
+ }
1498
+ getFullDataBlock(t) {
1499
+ let e = Math.floor(t / this.maxChunkSize), r = this.fullDataBlocks[e];
1500
+ if (r)
1501
+ return r;
1502
+ if (e >= this.pointers.length) {
1503
+ let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1504
+ this.pointers.push(a.pointer);
1505
+ }
1506
+ let s = new h(this.memory, B(this.pointers[e])), o = new this.typeConstructor(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1507
+ return this.fullDataBlocks[e] = o, o;
1508
+ }
1509
+ getDataBlock(t, e) {
1510
+ const r = e * this.dataLength;
1511
+ return t.subarray(r, r + this.dataLength);
1512
+ }
1513
+ free() {
1514
+ for (let t of this.pointers)
1515
+ new h(this.memory, B(t)).free();
1516
+ this.pointers = [], this.recycledIndexes = [], this.totalLength = 0, this.fullDataBlocks = {};
1517
+ }
1518
+ }
1519
+ const It = new ArrayBuffer(4), Nt = new Uint32Array(It), R = new Uint16Array(It);
1520
+ function ge(i, t) {
1521
+ return le(Atomics.load(i, t));
1422
1522
  }
1423
- function Ae(i, t, e, r) {
1424
- Atomics.store(i, t, le(e, r));
1523
+ function ke(i, t, e, r) {
1524
+ Atomics.store(i, t, fe(e, r));
1425
1525
  }
1426
- function fe(i) {
1526
+ function le(i) {
1427
1527
  return Nt[0] = i, [R[0], R[1]];
1428
1528
  }
1429
- function le(i, t) {
1529
+ function fe(i, t) {
1430
1530
  return R[0] = i, R[1] = t, Nt[0];
1431
1531
  }
1432
- const Ct = new ArrayBuffer(8), Ut = new BigUint64Array(Ct), B = new Uint16Array(Ct);
1433
- function ge(i, t) {
1434
- return Ut[0] = Atomics.load(i, t), [B[0], B[1], B[2], B[3]];
1532
+ const Pt = new ArrayBuffer(8), Ut = new BigUint64Array(Pt), b = new Uint16Array(Pt);
1533
+ function Ae(i, t) {
1534
+ return Ut[0] = Atomics.load(i, t), [b[0], b[1], b[2], b[3]];
1435
1535
  }
1436
- function ke(i, t, e, r, s, o = 0) {
1437
- B[0] = e, B[1] = r, B[2] = s, B[3] = o, Atomics.store(i, t, Ut[0]);
1536
+ function pe(i, t, e, r, s, o = 0) {
1537
+ b[0] = e, b[1] = r, b[2] = s, b[3] = o, Atomics.store(i, t, Ut[0]);
1438
1538
  }
1439
- const Ft = new ArrayBuffer(4), Dt = new Float32Array(Ft), xt = new Int32Array(Ft);
1440
- function Rt(i, t) {
1539
+ const Dt = new ArrayBuffer(4), xt = new Float32Array(Dt), Ft = new Int32Array(Dt);
1540
+ function zt(i, t) {
1441
1541
  return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.load(i, t));
1442
1542
  }
1443
1543
  function Ee(i, t, e) {
1444
1544
  i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, $(e));
1445
1545
  }
1446
1546
  function Q(i) {
1447
- return xt[0] = i, Dt[0];
1547
+ return Ft[0] = i, xt[0];
1448
1548
  }
1449
1549
  function $(i) {
1450
- return Dt[0] = i, xt[0];
1550
+ return xt[0] = i, Ft[0];
1451
1551
  }
1452
1552
  function we(i, t, e) {
1453
1553
  return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.exchange(i, t, $(e)));
1454
1554
  }
1455
- function $t(i, t, e, r) {
1555
+ function Rt(i, t, e, r) {
1456
1556
  return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.compareExchange(i, t, $(e), $(r)));
1457
1557
  }
1458
- function pe(i, t, e, r) {
1558
+ function Le(i, t, e, r) {
1459
1559
  let s, o;
1460
1560
  do
1461
1561
  s = Atomics.load(i, t), o = Math.min(s + e, r);
1462
1562
  while (Atomics.compareExchange(i, t, s, o) !== s);
1463
1563
  }
1464
- function Te(i, t, e, r) {
1564
+ function Se(i, t, e, r) {
1465
1565
  let s, o;
1466
1566
  do
1467
1567
  s = Atomics.load(i, t), o = Math.max(s - e, r);
1468
1568
  while (Atomics.compareExchange(i, t, s, o) !== s);
1469
1569
  }
1470
- function Le(i, t, e, r) {
1570
+ function Te(i, t, e, r) {
1471
1571
  let s, o;
1472
1572
  do
1473
- s = Rt(i, t), o = Math.min(s + e, r);
1474
- while ($t(i, t, s, o) !== s);
1573
+ s = zt(i, t), o = Math.min(s + e, r);
1574
+ while (Rt(i, t, s, o) !== s);
1475
1575
  }
1476
- function Se(i, t, e, r) {
1576
+ function _e(i, t, e, r) {
1477
1577
  let s, o;
1478
1578
  do
1479
- s = Rt(i, t), o = Math.max(s - e, r);
1480
- while ($t(i, t, s, o) !== s);
1579
+ s = zt(i, t), o = Math.max(s - e, r);
1580
+ while (Rt(i, t, s, o) !== s);
1481
1581
  }
1482
- const zt = new ArrayBuffer(8), Yt = new Float64Array(zt), Ht = new BigInt64Array(zt);
1483
- function _e(i, t) {
1582
+ const $t = new ArrayBuffer(8), Yt = new Float64Array($t), Ht = new BigInt64Array($t);
1583
+ function Oe(i, t) {
1484
1584
  return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.load(i, t));
1485
1585
  }
1486
- function Oe(i, t, e) {
1487
- i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, z(e));
1586
+ function Me(i, t, e) {
1587
+ i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, Y(e));
1488
1588
  }
1489
1589
  function tt(i) {
1490
1590
  return Ht[0] = i, Yt[0];
1491
1591
  }
1492
- function z(i) {
1592
+ function Y(i) {
1493
1593
  return Yt[0] = i, Ht[0];
1494
1594
  }
1495
- function Me(i, t, e) {
1496
- return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.exchange(i, t, z(e)));
1595
+ function Ce(i, t, e) {
1596
+ return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.exchange(i, t, Y(e)));
1497
1597
  }
1498
1598
  function Ie(i, t, e, r) {
1499
- return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.compareExchange(i, t, z(e), z(r)));
1500
- }
1501
- const p = 0, J = 1, L = 2;
1502
- function Pe(i, t = 0) {
1503
- for (; Atomics.compareExchange(i, t, p, J) === L; )
1504
- Atomics.wait(i, t, L);
1505
- Atomics.add(i, t + 1, 1);
1599
+ return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.compareExchange(i, t, Y(e), Y(r)));
1506
1600
  }
1601
+ const w = 0, J = 1, S = 2;
1507
1602
  function Ne(i, t = 0) {
1508
- let e = Atomics.compareExchange(i, t, p, L);
1509
- for (; e !== p; )
1510
- Atomics.wait(i, t, e), e = Atomics.compareExchange(i, t, p, L);
1603
+ for (; Atomics.compareExchange(i, t, w, J) === S; )
1604
+ Atomics.wait(i, t, S);
1605
+ Atomics.add(i, t + 1, 1);
1511
1606
  }
1512
- function Ce(i, t = 0) {
1513
- Atomics.sub(i, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(i, t, J, p) !== J && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(i, t));
1607
+ function Pe(i, t = 0) {
1608
+ let e = Atomics.compareExchange(i, t, w, S);
1609
+ for (; e !== w; )
1610
+ Atomics.wait(i, t, e), e = Atomics.compareExchange(i, t, w, S);
1514
1611
  }
1515
1612
  function Ue(i, t = 0) {
1516
- Atomics.compareExchange(i, t, L, p) !== L && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(i, t);
1613
+ Atomics.sub(i, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(i, t, J, w) !== J && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(i, t));
1614
+ }
1615
+ function De(i, t = 0) {
1616
+ Atomics.compareExchange(i, t, S, w) !== S && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(i, t);
1517
1617
  }
1518
- const Fe = 2;
1618
+ const xe = 2;
1519
1619
  export {
1520
1620
  h as AllocatedMemory,
1521
1621
  he as BYTE_OFFSET_BIT_COUNT,
1522
1622
  me as CachedItemList,
1623
+ be as LocalPool,
1523
1624
  et as MAX_BYTE_OFFSET_LENGTH,
1524
1625
  rt as MAX_POSITION_LENGTH,
1525
- Z as MemoryBuffer,
1526
- de as MemoryHeap,
1626
+ W as MemoryBuffer,
1627
+ ye as MemoryHeap,
1527
1628
  ce as POSITION_BIT_COUNT,
1528
- Fe as READ_WRITE_LOCK_ALLOCATE_COUNT,
1529
- ye as SIMPLE_LOCK_ALLOCATE_COUNT,
1629
+ xe as READ_WRITE_LOCK_ALLOCATE_COUNT,
1630
+ de as SIMPLE_LOCK_ALLOCATE_COUNT,
1530
1631
  u as SharedList,
1531
1632
  Ot as SharedMap,
1532
1633
  Be as SharedPointerList,
1533
- It as SharedPool,
1634
+ Ct as SharedPool,
1534
1635
  Mt as SharedString,
1535
- d as SharedVector,
1536
- Le as addAtomicFloat32,
1537
- pe as addAtomicInt,
1538
- $t as compareExchangeFloat32,
1636
+ m as SharedVector,
1637
+ Te as addAtomicFloat32,
1638
+ Le as addAtomicInt,
1639
+ Rt as compareExchangeFloat32,
1539
1640
  Ie as compareExchangeFloat64,
1540
- le as convert16To32,
1541
- fe as convert32To16,
1641
+ fe as convert16To32,
1642
+ le as convert32To16,
1542
1643
  $ as convertFloat32ToInt32,
1543
- z as convertFloat64ToInt64,
1644
+ Y as convertFloat64ToInt64,
1544
1645
  Q as convertInt32ToFloat32,
1545
1646
  tt as convertInt64ToFloat64,
1546
- T as createPointer,
1647
+ L as createPointer,
1547
1648
  we as exchangeFloat32,
1548
- Me as exchangeFloat64,
1549
- g as getPointer,
1550
- be as load16From32,
1551
- ge as load16From64,
1552
- Rt as loadFloat32,
1553
- _e as loadFloat64,
1649
+ Ce as exchangeFloat64,
1650
+ B as getPointer,
1651
+ ge as load16From32,
1652
+ Ae as load16From64,
1653
+ zt as loadFloat32,
1654
+ Oe as loadFloat64,
1554
1655
  c as loadPointer,
1555
1656
  O as loadRawPointer,
1556
- x as lock,
1557
- Pe as readLock,
1558
- Ce as readUnlock,
1657
+ z as lock,
1658
+ Ne as readLock,
1659
+ Ue as readUnlock,
1559
1660
  ue as replacePointer,
1560
- H as replaceRawPointer,
1561
- Ae as store16In32,
1562
- ke as store16In64,
1661
+ V as replaceRawPointer,
1662
+ ke as store16In32,
1663
+ pe as store16In64,
1563
1664
  Ee as storeFloat32,
1564
- Oe as storeFloat64,
1565
- m as storePointer,
1566
- v as storeRawPointer,
1567
- Se as subtractAtomicFloat,
1568
- Te as subtractAtomicInt,
1569
- A as unlock,
1570
- Ne as writeLock,
1571
- Ue as writeUnlock
1665
+ Me as storeFloat64,
1666
+ k as storePointer,
1667
+ x as storeRawPointer,
1668
+ _e as subtractAtomicFloat,
1669
+ Se as subtractAtomicInt,
1670
+ g as unlock,
1671
+ Pe as writeLock,
1672
+ De as writeUnlock
1572
1673
  };
1573
1674
  //# sourceMappingURL=shared-memory-objects.js.map