@bnaya/objectbuffer
Advanced tools
Comparing version 0.0.0-7449ff0 to 0.0.0-7a3f3a1
@@ -1,2 +0,2 @@ | ||
import { ExternalArgsApi } from "./interfaces"; | ||
import { ExternalArgsApi, MemoryStats } from "./interfaces"; | ||
export interface CreateObjectBufferOptions { | ||
@@ -50,6 +50,3 @@ /** | ||
*/ | ||
export declare function memoryStats(objectBuffer: unknown): { | ||
available: number; | ||
used: number; | ||
}; | ||
export declare function memoryStats(objectBuffer: unknown): MemoryStats; | ||
export { disposeWrapperObject } from "./disposeWrapperObject"; | ||
@@ -56,0 +53,0 @@ /** |
@@ -129,7 +129,10 @@ import { initializeArrayBuffer } from "./store"; | ||
available, | ||
total | ||
total, | ||
top | ||
} = pool.stats(); | ||
return { | ||
available, | ||
used: total - available | ||
used: total - available, | ||
total, | ||
top | ||
}; | ||
@@ -136,0 +139,0 @@ } |
@@ -24,2 +24,5 @@ export declare enum ENTRY_TYPE { | ||
ARRAY = 9, | ||
/** | ||
* @deprecated | ||
*/ | ||
ARRAY_ITEM = 10, | ||
@@ -30,4 +33,2 @@ MAP = 11, | ||
} | ||
export declare const PRIMITIVE_TYPES: readonly [ENTRY_TYPE.NUMBER, ENTRY_TYPE.BIGINT_POSITIVE, ENTRY_TYPE.BIGINT_NEGATIVE, ENTRY_TYPE.STRING]; | ||
export declare const isPrimitiveEntryType: (v: unknown) => v is ENTRY_TYPE.NUMBER | ENTRY_TYPE.BIGINT_POSITIVE | ENTRY_TYPE.BIGINT_NEGATIVE | ENTRY_TYPE.STRING; | ||
//# sourceMappingURL=entry-types.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { createKnownTypeGuard } from "./utils"; | ||
export let ENTRY_TYPE; | ||
@@ -19,5 +18,2 @@ | ||
ENTRY_TYPE[ENTRY_TYPE["DATE"] = 13] = "DATE"; | ||
})(ENTRY_TYPE || (ENTRY_TYPE = {})); | ||
export const PRIMITIVE_TYPES = [ENTRY_TYPE.NUMBER, ENTRY_TYPE.BIGINT_POSITIVE, ENTRY_TYPE.BIGINT_NEGATIVE, ENTRY_TYPE.STRING]; | ||
export const isPrimitiveEntryType = createKnownTypeGuard(PRIMITIVE_TYPES); | ||
})(ENTRY_TYPE || (ENTRY_TYPE = {})); |
@@ -85,5 +85,2 @@ import { ENTRY_TYPE } from "./entry-types"; | ||
break; | ||
default: | ||
throw new Error(ENTRY_TYPE[entryType] + " Not implemented yet"); | ||
} | ||
@@ -90,0 +87,0 @@ } |
@@ -52,4 +52,4 @@ import { hashCodeInPlace, hashCodeExternalValue, getKeyStart, getKeyLength } from "./hashmapUtils"; | ||
const keyHashCode = hashCodeInPlace(heap.Uint8Array, hashmap_CAPACITY_get(heap, mapPointer), keyDataMemoryStart, keyDataMemoryLength); | ||
const bucketStartPointer = hashmap_ARRAY_POINTER_get(heap, mapPointer) + keyHashCode * Uint32Array.BYTES_PER_ELEMENT; | ||
const bucket = hashCodeInPlace(heap.Uint8Array, hashmap_CAPACITY_get(heap, mapPointer), keyDataMemoryStart, keyDataMemoryLength); | ||
const bucketStartPointer = hashmap_ARRAY_POINTER_get(heap, mapPointer) + bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
let ptrToPtrToSaveTheNodeTo = bucketStartPointer; | ||
@@ -98,4 +98,4 @@ let iteratedNodePointer = heap.Uint32Array[ptrToPtrToSaveTheNodeTo / Uint32Array.BYTES_PER_ELEMENT]; // todo: share code with hashMapNodeLookup? | ||
export function hashMapNodeLookup(heap, mapPointer, externalKeyValue) { | ||
const keyHashCode = hashCodeExternalValue(hashmap_CAPACITY_get(heap, mapPointer), externalKeyValue); | ||
const bucketStartPtrToPtr = hashmap_ARRAY_POINTER_get(heap, mapPointer) + keyHashCode * Uint32Array.BYTES_PER_ELEMENT; | ||
const bucket = hashCodeExternalValue(hashmap_CAPACITY_get(heap, mapPointer), externalKeyValue); | ||
const bucketStartPtrToPtr = hashmap_ARRAY_POINTER_get(heap, mapPointer) + bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
let ptrToPtr = bucketStartPtrToPtr; | ||
@@ -213,3 +213,3 @@ let iteratedNode = heap.Uint32Array[bucketStartPtrToPtr / Uint32Array.BYTES_PER_ELEMENT]; | ||
allocator | ||
} = carrier; // Why not realloc? | ||
} = carrier; // we don't use re alloc because we don't need the old values | ||
@@ -220,16 +220,22 @@ allocator.free(hashmap_ARRAY_POINTER_get(heap, hashmapPointer)); | ||
hashmap_CAPACITY_set(heap, hashmapPointer, newCapacity); | ||
hashmap_USED_CAPACITY_set(heap, hashmapPointer, 0); | ||
let pointerToNode = 0; | ||
while ((pointerToNode = hashMapLowLevelIterator(heap, hashmapPointer, pointerToNode)) !== 0) { | ||
hashMapRehashInsert(heap, biggerArray, newCapacity, pointerToNode); | ||
hashMapRehashInsert(heap, hashmapPointer, pointerToNode); | ||
} | ||
} | ||
function hashMapRehashInsert(heap, bucketsArrayPointer, arraySize, nodePointer) { | ||
const keyHashCode = hashCodeInPlace(heap.Uint8Array, arraySize, getKeyStart(heap, nodePointer), getKeyLength(heap, nodePointer)); | ||
const bucket = keyHashCode % arraySize; | ||
const bucketStartPointer = bucketsArrayPointer + bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
function hashMapRehashInsert(heap, hashmapPointer, nodePointer) { | ||
const bucket = hashCodeInPlace(heap.Uint8Array, hashmap_CAPACITY_get(heap, hashmapPointer), getKeyStart(heap, hashmapNode_KEY_POINTER_get(heap, nodePointer)), getKeyLength(heap, hashmapNode_KEY_POINTER_get(heap, nodePointer))); | ||
const bucketStartPointer = hashmap_ARRAY_POINTER_get(heap, hashmapPointer) + bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
const prevFirstNodeInBucket = heap.Uint32Array[bucketStartPointer / Uint32Array.BYTES_PER_ELEMENT]; | ||
heap.Uint32Array[bucketStartPointer / Uint32Array.BYTES_PER_ELEMENT] = nodePointer; | ||
hashmapNode_NEXT_NODE_POINTER_set(heap, nodePointer, prevFirstNodeInBucket); | ||
if (prevFirstNodeInBucket !== 0) { | ||
hashmapNode_NEXT_NODE_POINTER_set(heap, nodePointer, prevFirstNodeInBucket); | ||
} else { | ||
hashmapNode_NEXT_NODE_POINTER_set(heap, nodePointer, 0); | ||
hashmap_USED_CAPACITY_set(heap, hashmapPointer, hashmap_USED_CAPACITY_get(heap, hashmapPointer) + 1); | ||
} | ||
} | ||
@@ -236,0 +242,0 @@ |
import type { Heap } from "../structsGenerator/consts"; | ||
import type { IMemPool } from "@thi.ng/malloc"; | ||
export interface MemoryStats { | ||
available: number; | ||
used: number; | ||
total: number; | ||
top: number; | ||
} | ||
export interface GlobalCarrier { | ||
@@ -4,0 +10,0 @@ allocator: IMemPool; |
@@ -0,1 +1,33 @@ | ||
import { MemPool } from "@thi.ng/malloc"; | ||
import { OutOfMemoryError } from "./exceptions"; | ||
import { MEM_POOL_START } from "./consts"; | ||
import { createHeap } from "../structsGenerator/consts"; | ||
import { getInternalAPI } from "./utils"; | ||
import { memoryStats } from "./api"; | ||
export function getArrayBufferOnTopSize(ob) { | ||
const stats = memoryStats(ob); | ||
const carrier = getInternalAPI(ob).getCarrier(); | ||
return carrier.heap.Uint8Array.slice(0, stats.top); | ||
} | ||
export function makeAllocatorThrowOnOOM(allocator) { | ||
const origMalloc = allocator.malloc; | ||
allocator.malloc = function wrappedMalloc(memSize) { | ||
if (memSize === 0) { | ||
throw new Error("memSize can't be 0"); | ||
} | ||
const allocated = origMalloc.call(allocator, memSize); | ||
if (allocated === 0) { | ||
throw new Error("OOM memSize"); | ||
} | ||
return allocated; | ||
}; | ||
} | ||
export function makeThrowOnOOM(ob) { | ||
const allocator = getInternalAPI(ob).getCarrier().allocator; | ||
makeAllocatorThrowOnOOM(allocator); | ||
} | ||
export function arrayBuffer2HexArray(buffer, withByteNumber = false) { | ||
@@ -13,7 +45,3 @@ if (withByteNumber) { | ||
}); | ||
} | ||
import { MemPool } from "@thi.ng/malloc"; | ||
import { OutOfMemoryError } from "./exceptions"; | ||
import { MEM_POOL_START } from "./consts"; | ||
import { createHeap } from "../structsGenerator/consts"; // extend pool and not monkey patch? need to think about it | ||
} // extend pool and not monkey patch? need to think about it | ||
@@ -20,0 +48,0 @@ export function recordAllocations(operation, pool) { |
@@ -0,15 +1,23 @@ | ||
let t; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}); | ||
}), function(t) { | ||
t[t.UNDEFINED = 0] = "UNDEFINED", t[t.NULL = 1] = "NULL", t[t.NUMBER = 2] = "NUMBER", | ||
t[t.BIGINT_POSITIVE = 3] = "BIGINT_POSITIVE", t[t.BIGINT_NEGATIVE = 4] = "BIGINT_NEGATIVE", | ||
t[t.STRING = 5] = "STRING", t[t.BOOLEAN = 6] = "BOOLEAN", t[t.OBJECT = 7] = "OBJECT", | ||
t[t.OBJECT_PROP = 8] = "OBJECT_PROP", t[t.ARRAY = 9] = "ARRAY", t[t.ARRAY_ITEM = 10] = "ARRAY_ITEM", | ||
t[t.MAP = 11] = "MAP", t[t.SET = 12] = "SET", t[t.DATE = 13] = "DATE"; | ||
}(t || (t = {})); | ||
const t = Symbol("INTERNAL_API"), r = 0 + Uint32Array.BYTES_PER_ELEMENT, e = r + Uint32Array.BYTES_PER_ELEMENT, n = e + Uint32Array.BYTES_PER_ELEMENT, i = BigInt("0xFFFFFFFFFFFFFFFF"); | ||
const r = Symbol("INTERNAL_API"), e = 0 + Uint32Array.BYTES_PER_ELEMENT, n = e + Uint32Array.BYTES_PER_ELEMENT, i = n + Uint32Array.BYTES_PER_ELEMENT, o = BigInt("0xFFFFFFFFFFFFFFFF"); | ||
function o(r, e) { | ||
if (t in r) { | ||
const t = s(r); | ||
if (t.getCarrier().allocator === e) return t.getEntryPointer(); | ||
function a(t, e) { | ||
if (r in t) { | ||
const r = c(t); | ||
if (r.getCarrier().allocator === e) return r.getEntryPointer(); | ||
} | ||
} | ||
function a(t) { | ||
function s(t) { | ||
return { | ||
@@ -23,8 +31,8 @@ ...t, | ||
function s(r) { | ||
if (!r[t]) throw new RangeError("getInternalAPI not applicable"); | ||
return r[t]; | ||
function c(t) { | ||
if (!t[r]) throw new RangeError("getInternalAPI not applicable"); | ||
return t[r]; | ||
} | ||
function c(t) { | ||
function h(t) { | ||
let r = t.length; | ||
@@ -38,18 +46,6 @@ for (let e = t.length - 1; e >= 0; e--) { | ||
function h(t) { | ||
function l(t) { | ||
return 0 === t || 1 === t || 2 === t || 3 === t; | ||
} | ||
let l; | ||
!function(t) { | ||
t[t.UNDEFINED = 0] = "UNDEFINED", t[t.NULL = 1] = "NULL", t[t.NUMBER = 2] = "NUMBER", | ||
t[t.BIGINT_POSITIVE = 3] = "BIGINT_POSITIVE", t[t.BIGINT_NEGATIVE = 4] = "BIGINT_NEGATIVE", | ||
t[t.STRING = 5] = "STRING", t[t.BOOLEAN = 6] = "BOOLEAN", t[t.OBJECT = 7] = "OBJECT", | ||
t[t.OBJECT_PROP = 8] = "OBJECT_PROP", t[t.ARRAY = 9] = "ARRAY", t[t.ARRAY_ITEM = 10] = "ARRAY_ITEM", | ||
t[t.MAP = 11] = "MAP", t[t.SET = 12] = "SET", t[t.DATE = 13] = "DATE"; | ||
}(l || (l = {})); | ||
l.NUMBER, l.BIGINT_POSITIVE, l.BIGINT_NEGATIVE, l.STRING; | ||
function u(t, r, e) { | ||
@@ -98,3 +94,3 @@ const n = e.length; | ||
function T(t, r, e, n, i, o) { | ||
function U(t, r, e, n, i, o) { | ||
t.Float64Array[(r + 0) / 8] = e, t.Uint32Array[(r + 8) / 4] = n, t.Uint32Array[(r + 12) / 4] = i, | ||
@@ -104,3 +100,3 @@ t.Float64Array[(r + 16) / 8] = o; | ||
function U(t, r) { | ||
function T(t, r) { | ||
return t.Uint32Array[(r + 12) / 4]; | ||
@@ -138,15 +134,15 @@ } | ||
function N(t, r, e, n, i) { | ||
function M(t, r, e, n, i) { | ||
t.Float64Array[(r + 0) / 8] = e, t.Uint32Array[(r + 8) / 4] = n, t.Uint32Array[(r + 12) / 4] = i; | ||
} | ||
function M(t, r) { | ||
function N(t, r) { | ||
return t.Float64Array[(r + 0) / 8]; | ||
} | ||
function I(t, r) { | ||
function B(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
} | ||
function B(t, r, e) { | ||
function I(t, r, e) { | ||
return t.Uint32Array[(r + 8) / 4] = e; | ||
@@ -159,7 +155,7 @@ } | ||
function w(t, r) { | ||
function x(t, r) { | ||
return t.Uint32Array[(r + 4) / 4]; | ||
} | ||
function x(t, r) { | ||
function w(t, r) { | ||
return t.Uint32Array[(r + 0) / 4]; | ||
@@ -200,2 +196,6 @@ } | ||
function D(t, r, e) { | ||
return t.Uint8Array[(r + 13) / 1] = e; | ||
} | ||
function G(t, r) { | ||
@@ -205,11 +205,15 @@ return t.Uint32Array[(r + 4) / 4]; | ||
function D(t, r) { | ||
function j(t, r, e) { | ||
return t.Uint32Array[(r + 4) / 4] = e; | ||
} | ||
function W(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
} | ||
function j(t, r) { | ||
function V(t, r) { | ||
return t.Uint32Array[(r + 12) / 4]; | ||
} | ||
function W(t, r, e, n) { | ||
function J(t, r, e, n) { | ||
let i = 0; | ||
@@ -220,9 +224,9 @@ for (let r = 0; r < n; r++) i = Math.imul(31, i) + t[r + e] | 0; | ||
function V(t, r, e) { | ||
function q(t, r, e) { | ||
let n = e; | ||
return 0 === e ? (n = w(t, r), 0 === k(t, n) ? 0 : n) : 0 === k(t, n) ? 0 : (n = x(t, n), | ||
return 0 === e ? (n = x(t, r), 0 === k(t, n) ? 0 : n) : 0 === k(t, n) ? 0 : (n = w(t, n), | ||
0 === k(t, n) ? 0 : n); | ||
} | ||
function J(t, r = 10) { | ||
function H(t, r = 10) { | ||
const {heap: e, allocator: n} = t, i = n.calloc(14), o = n.calloc(r * Uint32Array.BYTES_PER_ELEMENT), a = function(t) { | ||
@@ -240,18 +244,16 @@ const {allocator: r, heap: e} = t, n = r.calloc(8), i = r.calloc(8); | ||
function q(t, r, e, n) { | ||
const {heap: i, allocator: o} = r, a = o.calloc(16); | ||
let s, h, f; | ||
"number" == typeof n ? (s = o.calloc(16), y(r.heap, s, l.NUMBER, n), h = s + 8, | ||
f = p.BYTES_PER_ELEMENT) : (s = o.calloc(16), f = c(n), h = o.calloc(f), u(r.heap.Uint8Array, h, n), | ||
N(r.heap, s, l.STRING, f, h)); | ||
const E = W(i.Uint8Array, v(i, e), h, f), A = F(i, e) + E * Uint32Array.BYTES_PER_ELEMENT; | ||
let T = A, U = i.Uint32Array[T / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== U && !Ut(r.heap, D(i, U), s); ) T = U + 4, U = G(i, U); | ||
return T === A && function(t, r, e) { | ||
t.Uint8Array[(r + 13) / 1] = e; | ||
}(i, e, z(i, e) + 1), 0 !== U ? (M(r.heap, s) === l.STRING && o.free(b(r.heap, s)), | ||
o.free(s), o.free(a), U + 0) : (U = a, function(t, r, e, n, i, o) { | ||
function $(r, e, n, i) { | ||
const {heap: o, allocator: a} = e, s = a.calloc(16); | ||
let c, l, f; | ||
"number" == typeof i ? (c = a.calloc(16), y(e.heap, c, t.NUMBER, i), l = c + 8, | ||
f = p.BYTES_PER_ELEMENT) : (c = a.calloc(16), f = h(i), l = a.calloc(f), u(e.heap.Uint8Array, l, i), | ||
M(e.heap, c, t.STRING, f, l)); | ||
const E = J(o.Uint8Array, v(o, n), l, f), A = F(o, n) + E * Uint32Array.BYTES_PER_ELEMENT; | ||
let U = A, T = o.Uint32Array[U / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== T && !gt(e.heap, W(o, T), c); ) U = T + 4, T = G(o, T); | ||
return U === A && D(o, n, z(o, n) + 1), 0 !== T ? (N(e.heap, c) === t.STRING && a.free(b(e.heap, c)), | ||
a.free(c), a.free(s), T + 0) : (T = s, function(t, r, e, n, i, o) { | ||
t.Uint32Array[(r + 0) / 4] = e, t.Uint32Array[(r + 4) / 4] = n, t.Uint32Array[(r + 8) / 4] = i, | ||
t.Uint32Array[(r + 12) / 4] = o; | ||
}(i, U, 0, 0, s, function(t, r, e) { | ||
}(o, T, 0, 0, c, function(t, r, e) { | ||
const {allocator: n, heap: i} = t, o = n.calloc(8); | ||
@@ -263,4 +265,4 @@ L(i, o, 0, 0); | ||
}(i, r, o), L(i, a, o, e), a; | ||
}(r, O(i, e), a)), i.Uint32Array[T / Uint32Array.BYTES_PER_ELEMENT] = a, C(i, e, Y(i, e) + 1), | ||
d = v(i, e), g = z(i, e), P = t.hashMapLoadFactor, g / d > P && function(t, r, e) { | ||
}(e, O(o, n), s)), o.Uint32Array[U / Uint32Array.BYTES_PER_ELEMENT] = s, C(o, n, Y(o, n) + 1), | ||
d = v(o, n), g = z(o, n), P = r.hashMapLoadFactor, g / d > P && function(t, r, e) { | ||
const {heap: n, allocator: i} = t; | ||
@@ -273,10 +275,10 @@ i.free(F(n, r)); | ||
t.Uint8Array[(r + 12) / 1] = e; | ||
}(n, r, e); | ||
}(n, r, e), D(n, r, 0); | ||
let a = 0; | ||
for (;0 !== (a = K(n, r, a)); ) tt(n, o, e, a); | ||
}(r, e, 2 * v(i, e)), U + 0); | ||
for (;0 !== (a = X(n, r, a)); ) et(n, r, a); | ||
}(e, n, 2 * v(o, n)), T + 0); | ||
var d, g, P; | ||
} | ||
function H(t, r, e) { | ||
function K(t, r, e) { | ||
const n = function(t, r) { | ||
@@ -286,7 +288,7 @@ const e = new ArrayBuffer("string" == typeof r ? 3 * r.length : 8), n = new Uint8Array(e); | ||
return "string" == typeof r ? i = u(new Uint8Array(e), 0, r) : new Float64Array(e)[0] = r, | ||
W(n, t, 0, i); | ||
J(n, t, 0, i); | ||
}(v(t, r), e), i = F(t, r) + n * Uint32Array.BYTES_PER_ELEMENT; | ||
let o = i, a = t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== a; ) { | ||
if (dt(t, D(t, a)) === e) return o; | ||
if (Pt(t, W(t, a)) === e) return o; | ||
o = a + 4, a = G(t, a); | ||
@@ -297,17 +299,17 @@ } | ||
function $(t, r, e) { | ||
const {heap: n, allocator: i} = t, o = H(n, r, e); | ||
if (0 === o) return 0; | ||
const a = n.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT], s = a + 0; | ||
function Q(r, e, n) { | ||
const {heap: i, allocator: o} = r, a = K(i, e, n); | ||
if (0 === a) return 0; | ||
const s = i.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT], c = s + 0; | ||
return function({heap: t, allocator: r}, e) { | ||
const n = x(t, e); | ||
L(t, e, x(t, n), k(t, n)), r.free(n); | ||
}(t, j(n, a)), n.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = G(n, a), M(n, D(n, a)) === l.STRING && i.free(b(n, D(n, a))), | ||
i.free(D(n, a)), i.free(a), C(n, r, Y(n, r) - 1), s; | ||
const n = w(t, e); | ||
L(t, e, w(t, n), k(t, n)), r.free(n); | ||
}(r, V(i, s)), i.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = G(i, s), N(i, W(i, s)) === t.STRING && o.free(b(i, W(i, s))), | ||
o.free(W(i, s)), o.free(s), C(i, e, Y(i, e) - 1), c; | ||
} | ||
function K(t, r, e) { | ||
function X(t, r, e) { | ||
let n = 0; | ||
0 !== e && (n = j(t, e)); | ||
const i = V(t, O(t, r), n); | ||
0 !== e && (n = V(t, e)); | ||
const i = q(t, O(t, r), n); | ||
return 0 === i ? 0 : function(t, r) { | ||
@@ -318,19 +320,19 @@ return k(t, r); | ||
function Q(t, r) { | ||
function Z(t, r) { | ||
return { | ||
valuePointer: r + 0, | ||
keyPointer: D(t, r) | ||
keyPointer: W(t, r) | ||
}; | ||
} | ||
function X(t, r) { | ||
function tt(t, r) { | ||
return Y(t, r); | ||
} | ||
function Z(t, r) { | ||
const e = [ r, F(t, r) ], n = [], i = function(t, r) { | ||
const e = [ r ], n = [], i = w(t, r); | ||
function rt(r, e) { | ||
const n = [ e, F(r, e) ], i = [], o = function(t, r) { | ||
const e = [ r ], n = [], i = x(t, r); | ||
i === R(t, r) && e.push(i); | ||
let o = V(t, r, 0); | ||
for (;0 !== o; ) e.push(o), 0 !== k(t, o) && n.push(k(t, o)), o = x(t, o); | ||
let o = q(t, r, 0); | ||
for (;0 !== o; ) e.push(o), 0 !== k(t, o) && n.push(k(t, o)), o = w(t, o); | ||
return { | ||
@@ -340,32 +342,31 @@ pointers: e, | ||
}; | ||
}(t, O(t, r)); | ||
e.push(...i.pointers); | ||
for (const r of i.valuePointers) n.push(r + 0), M(t, D(t, r)) === l.STRING && e.push(b(t, D(t, r))), | ||
e.push(r, D(t, r)); | ||
}(r, O(r, e)); | ||
n.push(...o.pointers); | ||
for (const e of o.valuePointers) i.push(e + 0), N(r, W(r, e)) === t.STRING && n.push(b(r, W(r, e))), | ||
n.push(e, W(r, e)); | ||
return { | ||
pointers: e, | ||
pointersToValuePointers: n | ||
pointers: n, | ||
pointersToValuePointers: i | ||
}; | ||
} | ||
function tt(t, r, e, n) { | ||
const i = r + W(t.Uint8Array, e, function(t, r) { | ||
return M(t, r) === l.NUMBER ? r + 8 : b(t, r); | ||
}(t, n), function(t, r) { | ||
return M(t, r) === l.NUMBER ? p.BYTES_PER_ELEMENT : S(t, r); | ||
}(t, n)) % e * Uint32Array.BYTES_PER_ELEMENT, o = t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]; | ||
t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = n, function(t, r, e) { | ||
t.Uint32Array[(r + 4) / 4] = e; | ||
}(t, n, o); | ||
function et(r, e, n) { | ||
const i = J(r.Uint8Array, v(r, e), function(r, e) { | ||
return N(r, e) === t.NUMBER ? e + 8 : b(r, e); | ||
}(r, W(r, n)), function(r, e) { | ||
return N(r, e) === t.NUMBER ? p.BYTES_PER_ELEMENT : S(r, e); | ||
}(r, W(r, n))), o = F(r, e) + i * Uint32Array.BYTES_PER_ELEMENT, a = r.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT]; | ||
r.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = n, 0 !== a ? j(r, n, a) : (j(r, n, 0), | ||
D(r, e, z(r, e) + 1)); | ||
} | ||
function* rt(t, r) { | ||
function* nt(t, r) { | ||
let e = 0; | ||
for (;0 !== (e = K(t, r, e)); ) yield e; | ||
for (;0 !== (e = X(t, r, e)); ) yield e; | ||
} | ||
function et(t, r, e) { | ||
function it(t, r, e) { | ||
const n = new Set, i = new Set, o = [ e ]; | ||
let a = void 0; | ||
for (;void 0 !== (a = o.shift()); ) 0 !== a && nt(t, r, a, n, i, o); | ||
for (;void 0 !== (a = o.shift()); ) 0 !== a && ot(t, r, a, n, i, o); | ||
return { | ||
@@ -377,51 +378,47 @@ leafAddresses: n, | ||
function nt(t, r, e, n, i, o) { | ||
if (h(e) || n.has(e) || i.has(e)) return; | ||
const a = M(t, e), s = I(t, e); | ||
switch (a) { | ||
case l.NUMBER: | ||
case l.BIGINT_NEGATIVE: | ||
case l.BIGINT_POSITIVE: | ||
n.add(e); | ||
function ot(r, e, n, i, o, a) { | ||
if (l(n) || i.has(n) || o.has(n)) return; | ||
const s = N(r, n), c = B(r, n); | ||
switch (s) { | ||
case t.NUMBER: | ||
case t.BIGINT_NEGATIVE: | ||
case t.BIGINT_POSITIVE: | ||
i.add(n); | ||
break; | ||
case l.STRING: | ||
n.add(b(t, e)), n.add(e); | ||
case t.STRING: | ||
i.add(b(r, n)), i.add(n); | ||
break; | ||
case l.OBJECT: | ||
case l.MAP: | ||
case l.SET: | ||
s <= 1 || r ? (n.add(e), function(t, r, e, n) { | ||
const {pointersToValuePointers: i, pointers: o} = Z(t, r); | ||
case t.OBJECT: | ||
case t.MAP: | ||
case t.SET: | ||
c <= 1 || e ? (i.add(n), function(t, r, e, n) { | ||
const {pointersToValuePointers: i, pointers: o} = rt(t, r); | ||
for (const t of o) e.add(t); | ||
for (const r of i) n.push(t.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
}(t, _(t, e), n, o)) : i.add(e); | ||
}(r, _(r, n), i, a)) : o.add(n); | ||
break; | ||
case l.ARRAY: | ||
if (s <= 1 || r) { | ||
n.add(e), n.add(U(t, e)); | ||
const r = d(t, e); | ||
for (let n = 0; n < r; n += 1) { | ||
const r = t.Uint32Array[(U(t, e) + n * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT]; | ||
o.push(r); | ||
case t.ARRAY: | ||
if (c <= 1 || e) { | ||
i.add(n), i.add(T(r, n)); | ||
const t = d(r, n); | ||
for (let e = 0; e < t; e += 1) { | ||
const t = r.Uint32Array[(T(r, n) + e * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT]; | ||
a.push(t); | ||
} | ||
} else i.add(e); | ||
} else o.add(n); | ||
break; | ||
case l.DATE: | ||
s <= 1 || r ? n.add(e) : i.add(e); | ||
break; | ||
default: | ||
throw new Error(l[a] + " Not implemented yet"); | ||
case t.DATE: | ||
c <= 1 || e ? i.add(n) : o.add(n); | ||
} | ||
} | ||
const it = Math.clz32, ot = String.fromCharCode; | ||
const at = Math.clz32, st = String.fromCharCode; | ||
function at(t) { | ||
function ct(t) { | ||
let r = t.charCodeAt(0) << 24; | ||
const e = 0 | it(~r); | ||
const e = 0 | at(~r); | ||
let n = 0; | ||
@@ -432,3 +429,3 @@ const i = 0 | t.length; | ||
for (r = r << e >>> 24 + e, n = 1; n < e; n = n + 1 | 0) r = r << 6 | 63 & t.charCodeAt(n); | ||
r <= 65535 ? o += ot(r) : r <= 1114111 ? (r = r - 65536 | 0, o += ot(55296 + (r >> 10) | 0, 56320 + (1023 & r) | 0)) : n = 0; | ||
r <= 65535 ? o += st(r) : r <= 1114111 ? (r = r - 65536 | 0, o += st(55296 + (r >> 10) | 0, 56320 + (1023 & r) | 0)) : n = 0; | ||
} | ||
@@ -439,78 +436,78 @@ for (;n < i; n = n + 1 | 0) o += "�"; | ||
function st(t, r) { | ||
function ht(t, r) { | ||
return function(t, r, e) { | ||
const n = t.subarray(r, r + e); | ||
let i = ""; | ||
for (let t = 0, r = 0 | n.length; t < r; t = t + 32768 | 0) i += ot.apply(0, n.subarray(t, t + 32768 | 0)); | ||
return i.replace(/[\xc0-\xff][\x80-\xbf]*/g, at); | ||
for (let t = 0, r = 0 | n.length; t < r; t = t + 32768 | 0) i += st.apply(0, n.subarray(t, t + 32768 | 0)); | ||
return i.replace(/[\xc0-\xff][\x80-\xbf]*/g, ct); | ||
}(t.Uint8Array, b(t, r), S(t, r)); | ||
} | ||
function ct(t, r, e, n, i) { | ||
const o = i.length, a = r.allocator.calloc(24), s = o + t > 0 ? r.allocator.calloc((o + t) * Uint32Array.BYTES_PER_ELEMENT) : 0; | ||
P(r.heap, a, l.ARRAY, 1, s, o, o + t); | ||
for (let t = 0; t < o; t += 1) e.push(i[t]), n.push(s + t * Uint32Array.BYTES_PER_ELEMENT); | ||
return a; | ||
function lt(r, e, n, i, o) { | ||
const a = o.length, s = e.allocator.calloc(24), c = a + r > 0 ? e.allocator.calloc((a + r) * Uint32Array.BYTES_PER_ELEMENT) : 0; | ||
P(e.heap, s, t.ARRAY, 1, c, a, a + r); | ||
for (let t = 0; t < a; t += 1) n.push(o[t]), i.push(c + t * Uint32Array.BYTES_PER_ELEMENT); | ||
return s; | ||
} | ||
function ht(t, r, e, n, i) { | ||
const o = r.allocator.malloc(16), a = Object.entries(i), s = a.length, c = J(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * s))); | ||
for (let i = 0; i < s; i += 1) { | ||
const o = q(t, r, c, a[i][0]); | ||
e.push(a[i][1]), n.push(o); | ||
function ut(r, e, n, i, o) { | ||
const a = e.allocator.malloc(16), s = Object.entries(o), c = s.length, h = H(e, Math.max(r.hashMapMinInitialCapacity, Math.ceil(1.3 * c))); | ||
for (let t = 0; t < c; t += 1) { | ||
const o = $(r, e, h, s[t][0]); | ||
n.push(s[t][1]), i.push(o); | ||
} | ||
return m(r.heap, o, l.OBJECT, 1, c), o; | ||
return m(e.heap, a, t.OBJECT, 1, h), a; | ||
} | ||
function lt(t, r, e, n, i) { | ||
const o = r.allocator.malloc(16), a = J(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * i.size))); | ||
for (const [o, s] of i) { | ||
const i = q(t, r, a, o); | ||
e.push(s), n.push(i); | ||
function ft(r, e, n, i, o) { | ||
const a = e.allocator.malloc(16), s = H(e, Math.max(r.hashMapMinInitialCapacity, Math.ceil(1.3 * o.size))); | ||
for (const [t, a] of o) { | ||
const o = $(r, e, s, t); | ||
n.push(a), i.push(o); | ||
} | ||
return m(r.heap, o, l.MAP, 1, a), o; | ||
return m(e.heap, a, t.MAP, 1, s), a; | ||
} | ||
function ut(t, r, e) { | ||
const n = r.allocator.malloc(16), i = J(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * e.size))); | ||
for (const n of e) q(t, r, i, n); | ||
return m(r.heap, n, l.SET, 1, i), n; | ||
function pt(r, e, n) { | ||
const i = e.allocator.malloc(16), o = H(e, Math.max(r.hashMapMinInitialCapacity, Math.ceil(1.3 * n.size))); | ||
for (const t of n) $(r, e, o, t); | ||
return m(e.heap, i, t.SET, 1, o), i; | ||
} | ||
function ft(t, r, e, n, a) { | ||
const s = [ a ], h = [ n ], {heap: {Uint32Array: f}, allocator: p, heap: E} = r; | ||
for (;0 !== s.length; ) { | ||
const n = s.pop(), a = h.pop(); | ||
if (void 0 === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
function yt(r, e, n, i, s) { | ||
const c = [ s ], l = [ i ], {heap: {Uint32Array: f}, allocator: p, heap: E} = e; | ||
for (;0 !== c.length; ) { | ||
const i = c.pop(), s = l.pop(); | ||
if (void 0 === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
if (null === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 1; | ||
if (null === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 1; | ||
continue; | ||
} | ||
if (!0 === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 2; | ||
if (!0 === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 2; | ||
continue; | ||
} | ||
if (!1 === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 3; | ||
if (!1 === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 3; | ||
continue; | ||
} | ||
switch (typeof n) { | ||
switch (typeof i) { | ||
case "number": | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), y(E, f[a / Uint32Array.BYTES_PER_ELEMENT], l.NUMBER, n); | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), y(E, f[s / Uint32Array.BYTES_PER_ELEMENT], t.NUMBER, i); | ||
continue; | ||
case "string": | ||
const t = c(n), r = p.calloc(t); | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), u(E.Uint8Array, r, n), N(E, f[a / Uint32Array.BYTES_PER_ELEMENT], l.STRING, t, r); | ||
const r = h(i), e = p.calloc(r); | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), u(E.Uint8Array, e, i), M(E, f[s / Uint32Array.BYTES_PER_ELEMENT], t.STRING, r, e); | ||
continue; | ||
case "bigint": | ||
if (n > i || n < -i) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
if (i > o || i < -o) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), A(E, f[a / Uint32Array.BYTES_PER_ELEMENT], n > 0 ? l.BIGINT_POSITIVE : l.BIGINT_NEGATIVE, n * (n > 0 ? BigInt("1") : BigInt("-1"))); | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), A(E, f[s / Uint32Array.BYTES_PER_ELEMENT], i > 0 ? t.BIGINT_POSITIVE : t.BIGINT_NEGATIVE, i * (i > 0 ? BigInt("1") : BigInt("-1"))); | ||
continue; | ||
@@ -520,69 +517,69 @@ | ||
case "symbol": | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
const U = o(n, r.allocator); | ||
U ? (e.push(U), E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = U) : Array.isArray(n) ? E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = ct(t.arrayAdditionalAllocation, r, s, h, n) : n instanceof Date ? (E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(24), | ||
T(E, E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT], l.DATE, 1, 0, n.getTime())) : n instanceof Map ? E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = lt(t, r, s, h, n) : n instanceof Set ? E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = ut(t, r, n) : E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = ht(t, r, s, h, n); | ||
const T = a(i, e.allocator); | ||
T ? (n.push(T), E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = T) : Array.isArray(i) ? E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = lt(r.arrayAdditionalAllocation, e, c, l, i) : i instanceof Date ? (E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(24), | ||
U(E, E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT], t.DATE, 1, 0, i.getTime())) : i instanceof Map ? E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = ft(r, e, c, l, i) : i instanceof Set ? E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = pt(r, e, i) : E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = ut(r, e, c, l, i); | ||
} | ||
} | ||
function pt(t, r, e, n) { | ||
function Et(t, r, e, n) { | ||
const i = []; | ||
return ft(t, r, i, e, n), i; | ||
return yt(t, r, i, e, n), i; | ||
} | ||
function yt(t, r, e, n) { | ||
const i = r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], o = pt(t, r, e, n); | ||
if (o.length > 0) for (const t of o) At(r.heap, t); | ||
Et(r, i); | ||
function At(t, r, e, n) { | ||
const i = r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], o = Et(t, r, e, n); | ||
if (o.length > 0) for (const t of o) Tt(r.heap, t); | ||
Ut(r, i); | ||
} | ||
function Et(t, r) { | ||
const {heap: e, allocator: n} = t; | ||
if (h(r)) return; | ||
const i = M(e, r); | ||
if ((o = i) !== l.OBJECT && o !== l.ARRAY && o !== l.DATE && o !== l.MAP && o !== l.SET) return i === l.STRING && n.free(b(t.heap, r)), | ||
void n.free(r); | ||
var o; | ||
if (Tt(e, r) > 0) return void n.free(r); | ||
const {leafAddresses: a, arcAddresses: s} = et(t.heap, !1, r); | ||
for (const t of a) n.free(t); | ||
for (const t of s) Tt(e, t); | ||
function Ut(r, e) { | ||
const {heap: n, allocator: i} = r; | ||
if (l(e)) return; | ||
const o = N(n, e); | ||
if ((a = o) !== t.OBJECT && a !== t.ARRAY && a !== t.DATE && a !== t.MAP && a !== t.SET) return o === t.STRING && i.free(b(r.heap, e)), | ||
void i.free(e); | ||
var a; | ||
if (dt(n, e) > 0) return void i.free(e); | ||
const {leafAddresses: s, arcAddresses: c} = it(r.heap, !1, e); | ||
for (const t of s) i.free(t); | ||
for (const t of c) dt(n, t); | ||
} | ||
function At(t, r) { | ||
return B(t, r, I(t, r) + 1), I(t, r); | ||
function Tt(t, r) { | ||
return I(t, r, B(t, r) + 1), B(t, r); | ||
} | ||
function Tt(t, r) { | ||
return B(t, r, I(t, r) - 1), I(t, r); | ||
function dt(t, r) { | ||
return I(t, r, B(t, r) - 1), B(t, r); | ||
} | ||
function Ut(t, r, e) { | ||
M(t, r); | ||
const n = M(t, r); | ||
if (n !== M(t, e)) return !1; | ||
if (n === l.STRING) { | ||
const n = S(t, r); | ||
return n === S(t, e) && function(t, r, e, n) { | ||
function gt(r, e, n) { | ||
N(r, e); | ||
const i = N(r, e); | ||
if (i !== N(r, n)) return !1; | ||
if (i === t.STRING) { | ||
const t = S(r, e); | ||
return t === S(r, n) && function(t, r, e, n) { | ||
if (t.byteLength < r + n || t.byteLength < e + n) return !1; | ||
for (let i = 0; i <= n - i; i += 1) if (t[r + i] !== t[e + i]) return !1; | ||
return !0; | ||
}(t.Uint8Array, b(t, r), b(t, e), n); | ||
}(r.Uint8Array, b(r, e), b(r, n), t); | ||
} | ||
return f(t, r) === f(t, e); | ||
return f(r, e) === f(r, n); | ||
} | ||
function dt(t, r) { | ||
return M(t, r) === l.NUMBER ? f(t, r) : st(t, r); | ||
function Pt(r, e) { | ||
return N(r, e) === t.NUMBER ? f(r, e) : ht(r, e); | ||
} | ||
function gt(t) { | ||
function _t(t) { | ||
if (null == t) throw new Error("assertNonNull"); | ||
} | ||
function Pt(t, r, e) { | ||
function mt(t, r, e) { | ||
if (e >= d(t.heap, r)) return; | ||
const n = U(t.heap, r) + e * Uint32Array.BYTES_PER_ELEMENT; | ||
const n = T(t.heap, r) + e * Uint32Array.BYTES_PER_ELEMENT; | ||
return { | ||
@@ -594,24 +591,24 @@ pointer: t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT], | ||
function _t(t, r, e, n) { | ||
const i = Pt(r, e, n); | ||
if (void 0 !== i) return Ft(t, r, i.pointer); | ||
function St(t, r, e, n) { | ||
const i = mt(r, e, n); | ||
if (void 0 !== i) return Yt(t, r, i.pointer); | ||
} | ||
function mt(t, r, e, n) { | ||
const i = Pt(t, r, e); | ||
gt(i), t.heap.Uint32Array[i.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
function bt(t, r, e, n) { | ||
const i = mt(t, r, e); | ||
_t(i), t.heap.Uint32Array[i.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
} | ||
function St(t, r, e, n) { | ||
var i, o; | ||
n > d(r.heap, e) && (n > (i = r.heap, o = e, i.Uint32Array[(o + 20) / 4]) ? function(t, r, e, n) { | ||
const i = U(t.heap, r), o = 0 !== i ? t.allocator.realloc(i, e * Uint32Array.BYTES_PER_ELEMENT) : t.allocator.calloc(e * Uint32Array.BYTES_PER_ELEMENT); | ||
P(t.heap, r, l.ARRAY, function(t, r) { | ||
function Mt(r, e, n, i) { | ||
var o, a; | ||
i > d(e.heap, n) && (i > (o = e.heap, a = n, o.Uint32Array[(a + 20) / 4]) ? function(r, e, n, i) { | ||
const o = T(r.heap, e), a = 0 !== o ? r.allocator.realloc(o, n * Uint32Array.BYTES_PER_ELEMENT) : r.allocator.calloc(n * Uint32Array.BYTES_PER_ELEMENT); | ||
P(r.heap, e, t.ARRAY, function(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
}(t.heap, r), o, n, e); | ||
}(r, e, n + t.arrayAdditionalAllocation, n) : g(r.heap, e, n)); | ||
}(r.heap, e), a, i, n); | ||
}(e, n, i + r.arrayAdditionalAllocation, i) : g(e.heap, n, i)); | ||
} | ||
function bt(t, r, e, n = Nt) { | ||
const i = U(r.heap, e), o = [ ...new Array(d(r.heap, e)).keys() ].map(t => i + t * Uint32Array.BYTES_PER_ELEMENT).map(t => r.heap.Uint32Array[t / Uint32Array.BYTES_PER_ELEMENT]).map(e => [ e, Ft(t, r, e) ]); | ||
function Nt(t, r, e, n = Bt) { | ||
const i = T(r.heap, e), o = [ ...new Array(d(r.heap, e)).keys() ].map(t => i + t * Uint32Array.BYTES_PER_ELEMENT).map(t => r.heap.Uint32Array[t / Uint32Array.BYTES_PER_ELEMENT]).map(e => [ e, Yt(t, r, e) ]); | ||
o.sort((t, r) => n(t[1], r[1])); | ||
@@ -621,11 +618,11 @@ for (let t = 0; t < o.length; t += 1) r.heap.Uint32Array[(i + t * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT] = o[t][0]; | ||
function Nt(t, r) { | ||
function Bt(t, r) { | ||
if (void 0 === t && void 0 === r) return 0; | ||
if (void 0 === t) return 1; | ||
if (void 0 === r) return -1; | ||
const e = Mt(t), n = Mt(r); | ||
const e = It(t), n = It(r); | ||
return e < n ? -1 : e > n ? 1 : 0; | ||
} | ||
function Mt(t) { | ||
function It(t) { | ||
if (null === t) return "null"; | ||
@@ -638,3 +635,3 @@ if ("boolean" == typeof t || "number" == typeof t) return t.toString(); | ||
function It(t, r, e, n, i, ...o) { | ||
function Rt(t, r, e, n, i, ...o) { | ||
const a = d(r.heap, e), s = function(t, r) { | ||
@@ -647,14 +644,14 @@ return r >= t ? t : r < 0 ? t + r : r; | ||
}(a, s, i), h = a + o.length - c; | ||
St(t, r, e, h); | ||
Mt(t, r, e, h); | ||
const l = [], u = h - a; | ||
for (let n = s; n < s + c; n += 1) l.push(_t(t, r, e, n)), Et(r, Pt(r, e, n).pointer); | ||
for (let n = s; n < s + c; n += 1) l.push(St(t, r, e, n)), Ut(r, mt(r, e, n).pointer); | ||
if (u > 0) for (let t = h - 1; t >= s + u; t -= 1) { | ||
const n = Pt(r, e, t - u); | ||
gt(n), mt(r, e, t, n.pointer), r.heap.Uint32Array[n.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
const n = mt(r, e, t - u); | ||
_t(n), bt(r, e, t, n.pointer), r.heap.Uint32Array[n.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
} else if (u < 0) for (let t = s + o.length; t < a + u; t += 1) { | ||
mt(r, e, t, Pt(r, e, t - u).pointer); | ||
bt(r, e, t, mt(r, e, t - u).pointer); | ||
} | ||
for (let n = 0; n < o.length; n += 1) { | ||
const i = Pt(r, e, s + n); | ||
gt(i), pt(t, r, i.pointerToThePointer, o[n]); | ||
const i = mt(r, e, s + n); | ||
_t(i), Et(t, r, i.pointerToThePointer, o[n]); | ||
} | ||
@@ -696,3 +693,3 @@ return h < a && function(t, r, e) { | ||
function Bt(t, r) { | ||
function xt(t, r) { | ||
const e = [], n = r.malloc, i = r.calloc, o = r.realloc; | ||
@@ -726,6 +723,6 @@ let a = !1; | ||
constructor(t, r, e) { | ||
this.externalArgs = t, this.carrier = r, this._entryPointer = e, At(this.carrier.heap, this.entryPointer); | ||
this.externalArgs = t, this.carrier = r, this._entryPointer = e, Tt(this.carrier.heap, this.entryPointer); | ||
} | ||
destroy() { | ||
const t = Tt(this.carrier.heap, this.entryPointer); | ||
const t = dt(this.carrier.heap, this.entryPointer); | ||
return this._entryPointer = 0, t; | ||
@@ -752,4 +749,4 @@ } | ||
class ArrayWrapper extends BaseProxyTrap { | ||
get(r, e) { | ||
if (e === t) return this; | ||
get(t, e) { | ||
if (e === r) return this; | ||
if (e in this && "constructor" !== e) return this[e]; | ||
@@ -759,5 +756,5 @@ if ("length" === e) return d(this.carrier.heap, this.entryPointer); | ||
const t = "string" == typeof e ? Number.parseInt(e, 10) : e; | ||
if (Number.isSafeInteger(t)) return _t(this.externalArgs, this.carrier, this.entryPointer, t); | ||
if (Number.isSafeInteger(t)) return St(this.externalArgs, this.carrier, this.entryPointer, t); | ||
} | ||
return r[e]; | ||
return t[e]; | ||
} | ||
@@ -785,4 +782,4 @@ deleteProperty(t, r) { | ||
} | ||
has(r, e) { | ||
if (e === t) return !0; | ||
has(t, e) { | ||
if (e === r) return !0; | ||
const n = d(this.carrier.heap, this.entryPointer); | ||
@@ -798,5 +795,5 @@ if ("number" == typeof e) return n - 1 >= e; | ||
const t = d(this.carrier.heap, this.entryPointer); | ||
return t === e || Bt(() => { | ||
return t === e || xt(() => { | ||
if (t > e) return this.splice(e, t - e), !0; | ||
St(this.externalArgs, this.carrier, this.entryPointer, e); | ||
Mt(this.externalArgs, this.carrier, this.entryPointer, e); | ||
}, this.carrier.allocator), !0; | ||
@@ -806,5 +803,5 @@ } | ||
if (!Number.isSafeInteger(n) || n < 0) throw new IllegalArrayIndexError; | ||
return Bt(() => { | ||
St(this.externalArgs, this.carrier, this.entryPointer, n + 1), function(t, r, e, n, i) { | ||
yt(t, r, Pt(r, e, n).pointerToThePointer, i); | ||
return xt(() => { | ||
Mt(this.externalArgs, this.carrier, this.entryPointer, n + 1), function(t, r, e, n, i) { | ||
At(t, r, mt(r, e, n).pointerToThePointer, i); | ||
}(this.externalArgs, this.carrier, this.entryPointer, n, e); | ||
@@ -816,3 +813,3 @@ }, this.carrier.allocator), !0; | ||
do { | ||
yield [ t, _t(this.externalArgs, this.carrier, this.entryPointer, t) ], t += 1, | ||
yield [ t, St(this.externalArgs, this.carrier, this.entryPointer, t) ], t += 1, | ||
r = d(this.carrier.heap, this.entryPointer); | ||
@@ -830,3 +827,3 @@ } while (t < r); | ||
do { | ||
yield _t(this.externalArgs, this.carrier, this.entryPointer, t), t += 1, r = d(this.carrier.heap, this.entryPointer); | ||
yield St(this.externalArgs, this.carrier, this.entryPointer, t), t += 1, r = d(this.carrier.heap, this.entryPointer); | ||
} while (t < r); | ||
@@ -838,6 +835,6 @@ } | ||
sort(t) { | ||
bt(this.externalArgs, this.carrier, this.entryPointer, t); | ||
Nt(this.externalArgs, this.carrier, this.entryPointer, t); | ||
} | ||
splice(t, r, ...e) { | ||
return Bt(() => It(this.externalArgs, this.carrier, this.entryPointer, t, r, ...e), this.carrier.allocator); | ||
return xt(() => Rt(this.externalArgs, this.carrier, this.entryPointer, t, r, ...e), this.carrier.allocator); | ||
} | ||
@@ -847,4 +844,4 @@ reverse() { | ||
for (let e = 0; e < Math.floor(d(t.heap, r) / 2); e += 1) { | ||
const n = d(t.heap, r) - e - 1, i = Pt(t, r, e); | ||
mt(t, r, e, Pt(t, r, n).pointer), mt(t, r, n, i.pointer); | ||
const n = d(t.heap, r) - e - 1, i = mt(t, r, e); | ||
bt(t, r, e, mt(t, r, n).pointer), bt(t, r, n, i.pointer); | ||
} | ||
@@ -876,3 +873,3 @@ }(this.carrier, this.entryPointer), this; | ||
const Rt = [ "toString", "toDateString", "toTimeString", "toISOString", "toUTCString", "getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds", "getTime", "getTimezoneOffset", "getUTCDate", "getUTCDay", "getUTCFullYear", "getUTCHours", "getUTCMilliseconds", "getUTCMinutes", "getUTCMonth", "getUTCSeconds", "toJSON", "toLocaleString", "toLocaleDateString", "toLocaleTimeString" ], wt = [ "setDate", "setFullYear", "setHours", "setMilliseconds", "setMinutes", "setMonth", "setSeconds", "setTime", "getTimezoneOffset", "setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds" ]; | ||
const wt = [ "toString", "toDateString", "toTimeString", "toISOString", "toUTCString", "getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds", "getTime", "getTimezoneOffset", "getUTCDate", "getUTCDay", "getUTCFullYear", "getUTCHours", "getUTCMilliseconds", "getUTCMinutes", "getUTCMonth", "getUTCSeconds", "toJSON", "toLocaleString", "toLocaleDateString", "toLocaleTimeString" ], kt = [ "setDate", "setFullYear", "setHours", "setMilliseconds", "setMinutes", "setMonth", "setSeconds", "setTime", "getTimezoneOffset", "setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds" ]; | ||
@@ -883,9 +880,9 @@ class DateWrapper extends BaseProxyTrap { | ||
} | ||
get(r, e) { | ||
return e === t ? this : Rt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = () => (this.updateDateObjectForReuse(), | ||
this.dateObjectForReuse[e]())), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : wt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = (...t) => { | ||
get(t, e) { | ||
return e === r ? this : wt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = () => (this.updateDateObjectForReuse(), | ||
this.dateObjectForReuse[e]())), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : kt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = (...t) => { | ||
this.updateDateObjectForReuse(); | ||
const r = this.dateObjectForReuse[e](...t); | ||
return this.persistDateObject(), r; | ||
}), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : r[e]; | ||
}), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : t[e]; | ||
} | ||
@@ -897,5 +894,5 @@ updateDateObjectForReuse() { | ||
persistDateObject() { | ||
var t, r; | ||
T(this.carrier.heap, this.entryPointer, l.DATE, (t = this.carrier.heap, r = this.entryPointer, | ||
t.Uint32Array[(r + 8) / 4]), 0, this.dateObjectForReuse.getTime()); | ||
var r, e; | ||
U(this.carrier.heap, this.entryPointer, t.DATE, (r = this.carrier.heap, e = this.entryPointer, | ||
r.Uint32Array[(e + 8) / 4]), 0, this.dateObjectForReuse.getTime()); | ||
} | ||
@@ -974,8 +971,8 @@ defineProperty() { | ||
const xt = new WeakMap; | ||
const Lt = new WeakMap; | ||
function kt(t, r) { | ||
let e = xt.get(t); | ||
function Ft(t, r) { | ||
let e = Lt.get(t); | ||
return e || (e = "undefined" != typeof WeakRef && 1 ? new WeakValueMap(void 0, r) : new Map, | ||
xt.set(t, e)), e; | ||
Lt.set(t, e)), e; | ||
} | ||
@@ -985,3 +982,3 @@ | ||
clear() { | ||
zt(this.externalArgs, this.carrier, this.entryPointer); | ||
Gt(this.externalArgs, this.carrier, this.entryPointer); | ||
} | ||
@@ -992,3 +989,3 @@ forEach(t, r) { | ||
get size() { | ||
return X(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
return tt(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
} | ||
@@ -999,17 +996,17 @@ [Symbol.iterator]() { | ||
* entries() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r, keyPointer: e} = Q(this.carrier.heap, t); | ||
yield [ Ft(this.externalArgs, this.carrier, e), Ft(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]) ]; | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r, keyPointer: e} = Z(this.carrier.heap, t); | ||
yield [ Yt(this.externalArgs, this.carrier, e), Yt(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]) ]; | ||
} | ||
} | ||
* keys() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t); | ||
yield Yt(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
} | ||
* values() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r} = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r} = Z(this.carrier.heap, t); | ||
yield Yt(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
@@ -1020,3 +1017,3 @@ } | ||
} | ||
get [t]() { | ||
get [r]() { | ||
return this; | ||
@@ -1028,13 +1025,13 @@ } | ||
get(t) { | ||
if ("string" == typeof t || "number" == typeof t) return vt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
if ("string" == typeof t || "number" == typeof t) return Dt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
delete(t) { | ||
return ("string" == typeof t || "number" == typeof t) && Ot(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && Ct(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
has(t) { | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== H(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== K(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
set(t, r) { | ||
return "string" != typeof t && "number" != typeof t || Bt(() => { | ||
Ct(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, r); | ||
return "string" != typeof t && "number" != typeof t || xt(() => { | ||
zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, r); | ||
}, this.carrier.allocator), this; | ||
@@ -1046,3 +1043,3 @@ } | ||
clear() { | ||
zt(this.externalArgs, this.carrier, this.entryPointer); | ||
Gt(this.externalArgs, this.carrier, this.entryPointer); | ||
} | ||
@@ -1053,3 +1050,3 @@ forEach(t, r) { | ||
get size() { | ||
return X(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
return tt(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
} | ||
@@ -1060,4 +1057,4 @@ [Symbol.iterator]() { | ||
* entries() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t), e = Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t), e = Yt(this.externalArgs, this.carrier, r.keyPointer); | ||
yield [ e, e ]; | ||
@@ -1067,11 +1064,11 @@ } | ||
* keys() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t); | ||
yield Yt(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
} | ||
* values() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t); | ||
yield Yt(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
@@ -1082,3 +1079,3 @@ } | ||
} | ||
get [t]() { | ||
get [r]() { | ||
return this; | ||
@@ -1090,26 +1087,26 @@ } | ||
has(t) { | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== H(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== K(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
add(t) { | ||
return "string" != typeof t && "number" != typeof t || Bt(() => { | ||
Ct(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, void 0); | ||
return "string" != typeof t && "number" != typeof t || xt(() => { | ||
zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, void 0); | ||
}, this.carrier.allocator), this; | ||
} | ||
delete(t) { | ||
return ("string" == typeof t || "number" == typeof t) && Ot(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && Ct(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
} | ||
const Lt = { | ||
[l.OBJECT]: Gt, | ||
[l.DATE]: function(t, r, e) { | ||
const Ot = { | ||
[t.OBJECT]: jt, | ||
[t.DATE]: function(t, r, e) { | ||
return new Proxy(new Date(0), new DateWrapper(t, r, e)); | ||
}, | ||
[l.ARRAY]: function(t, r, e) { | ||
[t.ARRAY]: function(t, r, e) { | ||
return new Proxy([], new ArrayWrapper(t, r, e)); | ||
}, | ||
[l.MAP]: function(t, r, e) { | ||
[t.MAP]: function(t, r, e) { | ||
return new MapWrapper(t, r, e); | ||
}, | ||
[l.SET]: function(t, r, e) { | ||
[t.SET]: function(t, r, e) { | ||
return new SetWrapper(t, r, e); | ||
@@ -1119,88 +1116,88 @@ } | ||
function Ft(t, r, e) { | ||
if (0 === e) return; | ||
if (1 === e) return null; | ||
if (2 === e) return !0; | ||
if (3 === e) return !1; | ||
const n = M(r.heap, e); | ||
switch (n) { | ||
case l.NUMBER: | ||
return f(r.heap, e); | ||
function Yt(r, e, n) { | ||
if (0 === n) return; | ||
if (1 === n) return null; | ||
if (2 === n) return !0; | ||
if (3 === n) return !1; | ||
const i = N(e.heap, n); | ||
switch (i) { | ||
case t.NUMBER: | ||
return f(e.heap, n); | ||
case l.STRING: | ||
return st(r.heap, e); | ||
case t.STRING: | ||
return ht(e.heap, n); | ||
case l.BIGINT_POSITIVE: | ||
return E(r.heap, e); | ||
case t.BIGINT_POSITIVE: | ||
return E(e.heap, n); | ||
case l.BIGINT_NEGATIVE: | ||
return E(r.heap, e) * BigInt("-1"); | ||
case t.BIGINT_NEGATIVE: | ||
return E(e.heap, n) * BigInt("-1"); | ||
} | ||
if (n !== l.OBJECT && n !== l.DATE && n !== l.ARRAY && n !== l.MAP && n !== l.SET) throw new Error("Nope Nope Nope"); | ||
const i = kt(r, t => { | ||
if (i !== t.OBJECT && i !== t.DATE && i !== t.ARRAY && i !== t.MAP && i !== t.SET) throw new Error("Nope Nope Nope"); | ||
const o = Ft(e, t => { | ||
!function(t, r) { | ||
if (0 === Tt(r.heap, t)) { | ||
const e = et(r.heap, !1, t); | ||
if (0 === dt(r.heap, t)) { | ||
const e = it(r.heap, !1, t); | ||
for (const t of e.leafAddresses) r.allocator.free(t); | ||
for (const t of e.arcAddresses) Tt(r.heap, t); | ||
for (const t of e.arcAddresses) dt(r.heap, t); | ||
} | ||
}(t, r); | ||
}(t, e); | ||
}); | ||
let o = i.get(e); | ||
return o || (o = Lt[n](t, r, e), i.set(e, o)), o; | ||
let a = o.get(n); | ||
return a || (a = Ot[i](r, e, n), o.set(n, a)), a; | ||
} | ||
function Ot(t, r, e) { | ||
const n = $(t, r, e); | ||
function Ct(t, r, e) { | ||
const n = Q(t, r, e); | ||
if (0 === n) return !1; | ||
return Et(t, t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]), !0; | ||
return Ut(t, t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]), !0; | ||
} | ||
function Yt(t, r) { | ||
let e = 0; | ||
const n = []; | ||
for (;e = K(t.heap, r, e); ) { | ||
const {valuePointer: r, keyPointer: i} = Q(t.heap, e), o = M(t.heap, i) === l.NUMBER ? f(t.heap, i) : st(t.heap, i); | ||
n.push({ | ||
valuePointer: t.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT], | ||
key: o | ||
function vt(r, e) { | ||
let n = 0; | ||
const i = []; | ||
for (;n = X(r.heap, e, n); ) { | ||
const {valuePointer: e, keyPointer: o} = Z(r.heap, n), a = N(r.heap, o) === t.NUMBER ? f(r.heap, o) : ht(r.heap, o); | ||
i.push({ | ||
valuePointer: r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], | ||
key: a | ||
}); | ||
} | ||
return n; | ||
return i; | ||
} | ||
function Ct(t, r, e, n, i) { | ||
yt(t, r, q(t, r, e, n), i); | ||
function zt(t, r, e, n, i) { | ||
At(t, r, $(t, r, e, n), i); | ||
} | ||
function vt(t, r, e, n) { | ||
function Dt(t, r, e, n) { | ||
const i = function(t, r, e) { | ||
const n = H(t, r, e); | ||
const n = K(t, r, e); | ||
return 0 === n ? 0 : t.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT] + 0; | ||
}(r.heap, e, n); | ||
return Ft(t, r, r.heap.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]); | ||
return Yt(t, r, r.heap.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
function zt(t, r, e) { | ||
const n = I(r.heap, e); | ||
B(r.heap, e, 0); | ||
const {leafAddresses: i, arcAddresses: o} = et(r.heap, !1, e); | ||
function Gt(t, r, e) { | ||
const n = B(r.heap, e); | ||
I(r.heap, e, 0); | ||
const {leafAddresses: i, arcAddresses: o} = it(r.heap, !1, e); | ||
for (const t of i) t !== e && r.allocator.free(t); | ||
for (const t of o) t !== e && Tt(r.heap, t); | ||
for (const t of o) t !== e && dt(r.heap, t); | ||
var a, s, c; | ||
B(r.heap, e, n), a = r.heap, s = e, c = J(r, t.hashMapMinInitialCapacity), a.Uint32Array[(s + 12) / 4] = c; | ||
I(r.heap, e, n), a = r.heap, s = e, c = H(r, t.hashMapMinInitialCapacity), a.Uint32Array[(s + 12) / 4] = c; | ||
} | ||
class ObjectWrapper extends BaseProxyTrap { | ||
get(r, e) { | ||
return e === t ? this : "symbol" != typeof e ? vt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), e) : void 0; | ||
get(t, e) { | ||
return e === r ? this : "symbol" != typeof e ? Dt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), e) : void 0; | ||
} | ||
deleteProperty(t, r) { | ||
return "symbol" != typeof r && Ot(this.carrier, _(this.carrier.heap, this.entryPointer), r); | ||
return "symbol" != typeof r && Ct(this.carrier, _(this.carrier.heap, this.entryPointer), r); | ||
} | ||
enumerate() { | ||
return Yt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
return vt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
} | ||
ownKeys() { | ||
return Yt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
return vt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
} | ||
@@ -1213,9 +1210,9 @@ getOwnPropertyDescriptor(t, r) { | ||
} | ||
has(r, e) { | ||
return e === t || "symbol" != typeof e && 0 !== H(this.carrier.heap, _(this.carrier.heap, this.entryPointer), e); | ||
has(t, e) { | ||
return e === r || "symbol" != typeof e && 0 !== K(this.carrier.heap, _(this.carrier.heap, this.entryPointer), e); | ||
} | ||
set(t, r, e) { | ||
if ("symbol" == typeof r) throw new IllegalObjectPropConfigError; | ||
return Bt(() => { | ||
Ct(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), r, e); | ||
return xt(() => { | ||
zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), r, e); | ||
}, this.carrier.allocator), !0; | ||
@@ -1237,3 +1234,3 @@ } | ||
function Gt(t, r, e) { | ||
function jt(t, r, e) { | ||
return new Proxy({ | ||
@@ -1244,3 +1241,3 @@ objectBufferWrapper: "objectBufferWrapper" | ||
var Dt, jt; | ||
var Wt, Vt; | ||
@@ -1251,44 +1248,44 @@ !function(t) { | ||
t[t.F64 = 8] = "F64"; | ||
}(Dt || (Dt = {})), function(t) { | ||
}(Wt || (Wt = {})), function(t) { | ||
t[t.I8 = 5120] = "I8", t[t.U8 = 5121] = "U8", t[t.I16 = 5122] = "I16", t[t.U16 = 5123] = "U16", | ||
t[t.I32 = 5124] = "I32", t[t.U32 = 5125] = "U32", t[t.F32 = 5126] = "F32"; | ||
}(jt || (jt = {})); | ||
}(Vt || (Vt = {})); | ||
jt.I8, Dt.I8, jt.U8, Dt.U8, jt.I16, Dt.I16, jt.U16, Dt.U16, jt.I32, Dt.I32, jt.U32, | ||
Dt.U32, jt.F32, Dt.F32, Dt.I8, jt.I8, Dt.U8, jt.U8, Dt.U8C, jt.U8, Dt.I16, jt.I16, | ||
Dt.U16, jt.U16, Dt.I32, jt.I32, Dt.I32, jt.I32, Dt.U32, jt.U32, Dt.F32, jt.F32, | ||
Dt.F64; | ||
Vt.I8, Wt.I8, Vt.U8, Wt.U8, Vt.I16, Wt.I16, Vt.U16, Wt.U16, Vt.I32, Wt.I32, Vt.U32, | ||
Wt.U32, Vt.F32, Wt.F32, Wt.I8, Vt.I8, Wt.U8, Vt.U8, Wt.U8C, Vt.U8, Wt.I16, Vt.I16, | ||
Wt.U16, Vt.U16, Wt.I32, Vt.I32, Wt.I32, Vt.I32, Wt.U32, Vt.U32, Wt.F32, Vt.F32, | ||
Wt.F64; | ||
const Wt = { | ||
[Dt.U8]: 1, | ||
[Dt.U8C]: 1, | ||
[Dt.I8]: 1, | ||
[Dt.U16]: 2, | ||
[Dt.I16]: 2, | ||
[Dt.U32]: 4, | ||
[Dt.I32]: 4, | ||
[Dt.F32]: 4, | ||
[Dt.F64]: 8 | ||
}, Vt = { | ||
[Dt.U8]: Uint8Array, | ||
[Dt.U8C]: Uint8ClampedArray, | ||
[Dt.I8]: Int8Array, | ||
[Dt.U16]: Uint16Array, | ||
[Dt.I16]: Int16Array, | ||
[Dt.U32]: Uint32Array, | ||
[Dt.I32]: Int32Array, | ||
[Dt.F32]: Float32Array, | ||
[Dt.F64]: Float64Array, | ||
[jt.U8]: Uint8Array, | ||
[jt.I8]: Int8Array, | ||
[jt.U16]: Uint16Array, | ||
[jt.I16]: Int16Array, | ||
[jt.U32]: Uint32Array, | ||
[jt.I32]: Int32Array, | ||
[jt.F32]: Float32Array | ||
const Jt = { | ||
[Wt.U8]: 1, | ||
[Wt.U8C]: 1, | ||
[Wt.I8]: 1, | ||
[Wt.U16]: 2, | ||
[Wt.I16]: 2, | ||
[Wt.U32]: 4, | ||
[Wt.I32]: 4, | ||
[Wt.F32]: 4, | ||
[Wt.F64]: 8 | ||
}, qt = { | ||
[Wt.U8]: Uint8Array, | ||
[Wt.U8C]: Uint8ClampedArray, | ||
[Wt.I8]: Int8Array, | ||
[Wt.U16]: Uint16Array, | ||
[Wt.I16]: Int16Array, | ||
[Wt.U32]: Uint32Array, | ||
[Wt.I32]: Int32Array, | ||
[Wt.F32]: Float32Array, | ||
[Wt.F64]: Float64Array, | ||
[Vt.U8]: Uint8Array, | ||
[Vt.I8]: Int8Array, | ||
[Vt.U16]: Uint16Array, | ||
[Vt.I16]: Int16Array, | ||
[Vt.U32]: Uint32Array, | ||
[Vt.I32]: Int32Array, | ||
[Vt.F32]: Float32Array | ||
}; | ||
const Jt = "undefined" == typeof process || "production" !== process.env.NODE_ENV || "1" === process.env.UMBRELLA_ASSERTS ? (t, r = "assertion failed") => { | ||
const Ht = "undefined" == typeof process || "production" !== process.env.NODE_ENV || "1" === process.env.UMBRELLA_ASSERTS ? (t, r = "assertion failed") => { | ||
if ("function" == typeof t && !t() || !t) throw new Error("function" == typeof r ? r() : r); | ||
} : () => {}, qt = (t, r) => t + --r & ~r, Ht = ((t, r = (t => void 0 !== t ? ": " + t : "")) => class extends Error { | ||
} : () => {}, $t = (t, r) => t + --r & ~r, Kt = ((t, r = (t => void 0 !== t ? ": " + t : "")) => class extends Error { | ||
constructor(e) { | ||
@@ -1301,10 +1298,10 @@ super(t(e) + r(e)); | ||
constructor(t = {}) { | ||
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = null != t.start ? qt(Math.max(t.start, 0), 4) : 0, | ||
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = null != t.start ? $t(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, 7), | ||
!t.skipInitialization) { | ||
const r = t.align || 8; | ||
Jt(r >= 8, `invalid alignment: ${r}, must be a pow2 and >= 8`); | ||
Ht(r >= 8, `invalid alignment: ${r}, must be a pow2 and >= 8`); | ||
const e = this.initialTop(r), n = null != t.end ? Math.min(t.end, this.buf.byteLength) : this.buf.byteLength; | ||
e >= n && (t => { | ||
throw new Ht(t); | ||
throw new Kt(t); | ||
})(`insufficient address range (0x${this.start.toString(16)} - 0x${n.toString(16)})`), | ||
@@ -1337,5 +1334,5 @@ this.align = r, this.doCompact = !1 !== t.compact, this.doSplit = !1 !== t.split, | ||
mallocAs(t, r) { | ||
const e = this.malloc(r * Wt[t]); | ||
const e = this.malloc(r * Jt[t]); | ||
return e ? function(t, ...r) { | ||
return new Vt[t](...r); | ||
return new qt[t](...r); | ||
}(t, this.buf, e, r) : void 0; | ||
@@ -1349,3 +1346,3 @@ } | ||
if (t <= 0) return 0; | ||
const r = qt(t + 8, this.align), e = this.end; | ||
const r = $t(t + 8, this.align), e = this.end; | ||
let n = this.top, i = this._free, o = 0; | ||
@@ -1361,3 +1358,3 @@ for (;i; ) { | ||
} | ||
return $t(i); | ||
return Qt(i); | ||
} | ||
@@ -1367,7 +1364,7 @@ o = i, i = this.blockNext(i); | ||
return i = n, n = i + r, n <= e ? (this.initBlock(i, r, this._used), this._used = i, | ||
this.top = n, $t(i)) : 0; | ||
this.top = n, Qt(i)) : 0; | ||
} | ||
realloc(t, r) { | ||
if (r <= 0) return 0; | ||
const e = Kt(t); | ||
const e = Xt(t); | ||
let n = 0, i = this._used, o = 0; | ||
@@ -1378,3 +1375,3 @@ for (;i; ) { | ||
o = e + t; | ||
const a = o >= this.top, s = qt(r + 8, this.align); | ||
const a = o >= this.top, s = $t(r + 8, this.align); | ||
if (s <= t) { | ||
@@ -1392,3 +1389,3 @@ if (this.doSplit) { | ||
} | ||
this.free(e), n = Kt(this.malloc(r)); | ||
this.free(e), n = Xt(this.malloc(r)); | ||
break; | ||
@@ -1398,3 +1395,3 @@ } | ||
} | ||
return n && n !== e && this.u8.copyWithin($t(n), $t(e), o), $t(n); | ||
return n && n !== e && this.u8.copyWithin(Qt(n), Qt(e), o), Qt(n); | ||
} | ||
@@ -1412,3 +1409,3 @@ reallocArray(t, r) { | ||
} else r = t; | ||
r = Kt(r); | ||
r = Xt(r); | ||
let e = this._used, n = 0; | ||
@@ -1474,3 +1471,3 @@ for (;e; ) { | ||
set minSplit(t) { | ||
Jt(t > 8, `illegal min split threshold: ${t}, require at least 9`), this.state[6] = t; | ||
Ht(t > 8, `illegal min split threshold: ${t}, require at least 9`), this.state[6] = t; | ||
} | ||
@@ -1500,3 +1497,3 @@ blockSize(t) { | ||
initialTop(t = this.align) { | ||
return qt(this.start + 28 + 8, t) - 8; | ||
return $t(this.start + 28 + 8, t) - 8; | ||
} | ||
@@ -1530,3 +1527,3 @@ compact() { | ||
const $t = t => t + 8, Kt = t => t - 8, Qt = { | ||
const Qt = t => t + 8, Xt = t => t - 8, Zt = { | ||
Uint8Array: Uint8Array, | ||
@@ -1545,27 +1542,27 @@ Uint8ClampedArray: Uint8ClampedArray, | ||
function Xt(t) { | ||
return Object.fromEntries(Object.entries(Qt).map(([r, e]) => [ r, new e(t) ])); | ||
function tr(t) { | ||
return Object.fromEntries(Object.entries(Zt).map(([r, e]) => [ r, new e(t) ])); | ||
} | ||
function Zt(t) { | ||
return s(t).getCarrier().heap.Uint8Array.buffer; | ||
function rr(t) { | ||
return c(t).getCarrier().heap.Uint8Array.buffer; | ||
} | ||
function tr(t, r) { | ||
const e = kt(Zt(t)), i = kt(r); | ||
for (const t of e) i.set(t[0], t[1]), e.delete(t[0]); | ||
function er(t, r) { | ||
const e = Ft(rr(t)), n = Ft(r); | ||
for (const t of e) n.set(t[0], t[1]), e.delete(t[0]); | ||
const o = new MemPool({ | ||
align: 8, | ||
buf: r, | ||
start: n, | ||
start: i, | ||
skipInitialization: !0 | ||
}), a = { | ||
allocator: o, | ||
heap: Xt(r) | ||
heap: tr(r) | ||
}; | ||
o.end = r.byteLength, s(t).replaceCarrierContent(a); | ||
o.end = r.byteLength, c(t).replaceCarrierContent(a); | ||
} | ||
exports.acquireLock = function(t, r) { | ||
const e = Zt(r); | ||
const e = rr(r); | ||
!function(t, r) { | ||
@@ -1577,13 +1574,13 @@ if (!t) throw new Error(r); | ||
}, exports.acquireLockWait = function(t, r, e) { | ||
const n = Zt(r), i = new Int32Array(n), o = Atomics.compareExchange(i, 0, 0, t); | ||
const n = rr(r), i = new Int32Array(n), o = Atomics.compareExchange(i, 0, 0, t); | ||
if (0 === o) return "have-lock"; | ||
const a = Atomics.wait(i, 0, o, e); | ||
return "not-equal" === a ? 0 === Atomics.compareExchange(i, 0, 0, t) ? "have-lock" : "miss-lock" : "timed-out" === a ? "timed-out" : "no-lock"; | ||
}, exports.createObjectBuffer = function(t, i, o, s = {}) { | ||
}, exports.createObjectBuffer = function(t, r, o, a = {}) { | ||
if (c = o, Array.isArray(c) || c instanceof Date || c instanceof Map || c instanceof Set || "object" != typeof c || null === typeof c || "Object" !== c.constructor.name) throw new UnsupportedOperationError; | ||
var c; | ||
const h = new (s.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer)(i); | ||
const h = new (a.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer)(r); | ||
!function(t) { | ||
const n = new Uint32Array(t); | ||
n[0] = 0, n[r / Uint32Array.BYTES_PER_ELEMENT] = e; | ||
const r = new Uint32Array(t); | ||
r[0] = 0, r[e / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
}(h); | ||
@@ -1593,56 +1590,58 @@ const l = new MemPool({ | ||
buf: h, | ||
start: n | ||
start: i | ||
}), u = { | ||
allocator: l, | ||
heap: Xt(h) | ||
heap: tr(h) | ||
}; | ||
return Bt(() => { | ||
ft(a(t), u, [], r, o); | ||
}, l), Gt(a(t), u, u.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
return xt(() => { | ||
yt(s(t), u, [], e, o); | ||
}, l), jt(s(t), u, u.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT]); | ||
}, exports.disposeWrapperObject = function(t) { | ||
const r = s(t), e = r.getEntryPointer(), n = r.destroy(); | ||
if (kt(r.getCarrier()).delete(e), 0 === n) { | ||
const t = et(r.getCarrier().heap, !1, e), {allocator: n, heap: i} = r.getCarrier(); | ||
const r = c(t), e = r.getEntryPointer(), n = r.destroy(); | ||
if (Ft(r.getCarrier()).delete(e), 0 === n) { | ||
const t = it(r.getCarrier().heap, !1, e), {allocator: n, heap: i} = r.getCarrier(); | ||
for (const r of t.leafAddresses) n.free(r); | ||
for (const r of t.arcAddresses) Tt(i, r); | ||
for (const r of t.arcAddresses) dt(i, r); | ||
return !0; | ||
} | ||
return !1; | ||
}, exports.getUnderlyingArrayBuffer = Zt, exports.loadObjectBuffer = function(t, e) { | ||
const i = { | ||
}, exports.getUnderlyingArrayBuffer = rr, exports.loadObjectBuffer = function(t, r) { | ||
const n = { | ||
allocator: new MemPool({ | ||
align: 8, | ||
buf: e, | ||
start: n, | ||
buf: r, | ||
start: i, | ||
skipInitialization: !0 | ||
}), | ||
heap: Xt(e) | ||
heap: tr(r) | ||
}; | ||
return Gt(a(t), i, i.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
return jt(s(t), n, n.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT]); | ||
}, exports.memoryStats = function(t) { | ||
const r = Zt(t), e = new MemPool({ | ||
const r = rr(t), e = new MemPool({ | ||
align: 8, | ||
buf: r, | ||
skipInitialization: !0, | ||
start: n | ||
}), {available: i, total: o} = e.stats(); | ||
start: i | ||
}), {available: n, total: o, top: a} = e.stats(); | ||
return { | ||
available: i, | ||
used: o - i | ||
available: n, | ||
used: o - n, | ||
total: o, | ||
top: a | ||
}; | ||
}, exports.releaseLock = function(t, r) { | ||
const e = Zt(r), n = new Int32Array(e); | ||
const e = rr(r), n = new Int32Array(e); | ||
return Atomics.compareExchange(n, 0, t, 0) === t && (Atomics.notify(n, 0, 1 / 0), | ||
!0); | ||
}, exports.replaceUnderlyingArrayBuffer = tr, exports.resizeObjectBuffer = function(t, r) { | ||
const e = Zt(t), n = new ArrayBuffer(r); | ||
}, exports.replaceUnderlyingArrayBuffer = er, exports.resizeObjectBuffer = function(t, r) { | ||
const e = rr(t), n = new ArrayBuffer(r); | ||
return function(t, r, e, n, i) { | ||
const o = new Uint8Array(t); | ||
new Uint8Array(n).set(o.subarray(r, r + e), i); | ||
}(e, 0, Math.min(r, e.byteLength), n, 0), tr(t, n), n; | ||
}(e, 0, Math.min(r, e.byteLength), n, 0), er(t, n), n; | ||
}, exports.unreliable_sizeOf = function() { | ||
return console.warn("FAKE VALUE"), Math.pow(2, 24); | ||
}, exports.updateExternalArgs = function(t, r) { | ||
Object.assign(s(t).getExternalArgs(), r); | ||
Object.assign(c(t).getExternalArgs(), r); | ||
}; | ||
//# sourceMappingURL=objectbuffer.cjs.js.map |
@@ -1,11 +0,21 @@ | ||
const t = Symbol("INTERNAL_API"), r = 0 + Uint32Array.BYTES_PER_ELEMENT, e = r + Uint32Array.BYTES_PER_ELEMENT, n = e + Uint32Array.BYTES_PER_ELEMENT, i = BigInt("0xFFFFFFFFFFFFFFFF"); | ||
let t; | ||
function o(r, e) { | ||
if (t in r) { | ||
const t = s(r); | ||
if (t.getCarrier().allocator === e) return t.getEntryPointer(); | ||
!function(t) { | ||
t[t.UNDEFINED = 0] = "UNDEFINED", t[t.NULL = 1] = "NULL", t[t.NUMBER = 2] = "NUMBER", | ||
t[t.BIGINT_POSITIVE = 3] = "BIGINT_POSITIVE", t[t.BIGINT_NEGATIVE = 4] = "BIGINT_NEGATIVE", | ||
t[t.STRING = 5] = "STRING", t[t.BOOLEAN = 6] = "BOOLEAN", t[t.OBJECT = 7] = "OBJECT", | ||
t[t.OBJECT_PROP = 8] = "OBJECT_PROP", t[t.ARRAY = 9] = "ARRAY", t[t.ARRAY_ITEM = 10] = "ARRAY_ITEM", | ||
t[t.MAP = 11] = "MAP", t[t.SET = 12] = "SET", t[t.DATE = 13] = "DATE"; | ||
}(t || (t = {})); | ||
const r = Symbol("INTERNAL_API"), e = 0 + Uint32Array.BYTES_PER_ELEMENT, n = e + Uint32Array.BYTES_PER_ELEMENT, i = n + Uint32Array.BYTES_PER_ELEMENT, o = BigInt("0xFFFFFFFFFFFFFFFF"); | ||
function a(t, e) { | ||
if (r in t) { | ||
const r = c(t); | ||
if (r.getCarrier().allocator === e) return r.getEntryPointer(); | ||
} | ||
} | ||
function a(t) { | ||
function s(t) { | ||
return { | ||
@@ -19,8 +29,8 @@ ...t, | ||
function s(r) { | ||
if (!r[t]) throw new RangeError("getInternalAPI not applicable"); | ||
return r[t]; | ||
function c(t) { | ||
if (!t[r]) throw new RangeError("getInternalAPI not applicable"); | ||
return t[r]; | ||
} | ||
function c(t) { | ||
function h(t) { | ||
let r = t.length; | ||
@@ -34,18 +44,6 @@ for (let e = t.length - 1; e >= 0; e--) { | ||
function h(t) { | ||
function l(t) { | ||
return 0 === t || 1 === t || 2 === t || 3 === t; | ||
} | ||
let l; | ||
!function(t) { | ||
t[t.UNDEFINED = 0] = "UNDEFINED", t[t.NULL = 1] = "NULL", t[t.NUMBER = 2] = "NUMBER", | ||
t[t.BIGINT_POSITIVE = 3] = "BIGINT_POSITIVE", t[t.BIGINT_NEGATIVE = 4] = "BIGINT_NEGATIVE", | ||
t[t.STRING = 5] = "STRING", t[t.BOOLEAN = 6] = "BOOLEAN", t[t.OBJECT = 7] = "OBJECT", | ||
t[t.OBJECT_PROP = 8] = "OBJECT_PROP", t[t.ARRAY = 9] = "ARRAY", t[t.ARRAY_ITEM = 10] = "ARRAY_ITEM", | ||
t[t.MAP = 11] = "MAP", t[t.SET = 12] = "SET", t[t.DATE = 13] = "DATE"; | ||
}(l || (l = {})); | ||
l.NUMBER, l.BIGINT_POSITIVE, l.BIGINT_NEGATIVE, l.STRING; | ||
function u(t, r, e) { | ||
@@ -94,3 +92,3 @@ const n = e.length; | ||
function T(t, r, e, n, i, o) { | ||
function U(t, r, e, n, i, o) { | ||
t.Float64Array[(r + 0) / 8] = e, t.Uint32Array[(r + 8) / 4] = n, t.Uint32Array[(r + 12) / 4] = i, | ||
@@ -100,3 +98,3 @@ t.Float64Array[(r + 16) / 8] = o; | ||
function U(t, r) { | ||
function T(t, r) { | ||
return t.Uint32Array[(r + 12) / 4]; | ||
@@ -130,11 +128,11 @@ } | ||
function N(t, r) { | ||
function M(t, r) { | ||
return t.Uint32Array[(r + 12) / 4]; | ||
} | ||
function M(t, r, e, n, i) { | ||
function b(t, r, e, n, i) { | ||
t.Float64Array[(r + 0) / 8] = e, t.Uint32Array[(r + 8) / 4] = n, t.Uint32Array[(r + 12) / 4] = i; | ||
} | ||
function b(t, r) { | ||
function N(t, r) { | ||
return t.Float64Array[(r + 0) / 8]; | ||
@@ -175,7 +173,7 @@ } | ||
function O(t, r) { | ||
function Y(t, r) { | ||
return t.Uint32Array[(r + 4) / 4]; | ||
} | ||
function Y(t, r) { | ||
function O(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
@@ -192,19 +190,27 @@ } | ||
function G(t, r) { | ||
function z(t, r) { | ||
return t.Uint8Array[(r + 13) / 1]; | ||
} | ||
function z(t, r) { | ||
function D(t, r, e) { | ||
return t.Uint8Array[(r + 13) / 1] = e; | ||
} | ||
function G(t, r) { | ||
return t.Uint32Array[(r + 4) / 4]; | ||
} | ||
function D(t, r) { | ||
function j(t, r, e) { | ||
return t.Uint32Array[(r + 4) / 4] = e; | ||
} | ||
function W(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
} | ||
function j(t, r) { | ||
function V(t, r) { | ||
return t.Uint32Array[(r + 12) / 4]; | ||
} | ||
function W(t, r, e, n) { | ||
function J(t, r, e, n) { | ||
let i = 0; | ||
@@ -215,3 +221,3 @@ for (let r = 0; r < n; r++) i = Math.imul(31, i) + t[r + e] | 0; | ||
function V(t, r, e) { | ||
function H(t, r, e) { | ||
let n = e; | ||
@@ -222,3 +228,3 @@ return 0 === e ? (n = w(t, r), 0 === k(t, n) ? 0 : n) : 0 === k(t, n) ? 0 : (n = x(t, n), | ||
function J(t, r = 10) { | ||
function $(t, r = 10) { | ||
const {heap: e, allocator: n} = t, i = n.calloc(14), o = n.calloc(r * Uint32Array.BYTES_PER_ELEMENT), a = function(t) { | ||
@@ -236,18 +242,16 @@ const {allocator: r, heap: e} = t, n = r.calloc(8), i = r.calloc(8); | ||
function H(t, r, e, n) { | ||
const {heap: i, allocator: o} = r, a = o.calloc(16); | ||
let s, h, f; | ||
"number" == typeof n ? (s = o.calloc(16), y(r.heap, s, l.NUMBER, n), h = s + 8, | ||
f = p.BYTES_PER_ELEMENT) : (s = o.calloc(16), f = c(n), h = o.calloc(f), u(r.heap.Uint8Array, h, n), | ||
M(r.heap, s, l.STRING, f, h)); | ||
const E = W(i.Uint8Array, v(i, e), h, f), A = F(i, e) + E * Uint32Array.BYTES_PER_ELEMENT; | ||
let T = A, U = i.Uint32Array[T / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== U && !Ut(r.heap, D(i, U), s); ) T = U + 4, U = z(i, U); | ||
return T === A && function(t, r, e) { | ||
t.Uint8Array[(r + 13) / 1] = e; | ||
}(i, e, G(i, e) + 1), 0 !== U ? (b(r.heap, s) === l.STRING && o.free(N(r.heap, s)), | ||
o.free(s), o.free(a), U + 0) : (U = a, function(t, r, e, n, i, o) { | ||
function K(r, e, n, i) { | ||
const {heap: o, allocator: a} = e, s = a.calloc(16); | ||
let c, l, f; | ||
"number" == typeof i ? (c = a.calloc(16), y(e.heap, c, t.NUMBER, i), l = c + 8, | ||
f = p.BYTES_PER_ELEMENT) : (c = a.calloc(16), f = h(i), l = a.calloc(f), u(e.heap.Uint8Array, l, i), | ||
b(e.heap, c, t.STRING, f, l)); | ||
const E = J(o.Uint8Array, v(o, n), l, f), A = F(o, n) + E * Uint32Array.BYTES_PER_ELEMENT; | ||
let U = A, T = o.Uint32Array[U / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== T && !gt(e.heap, W(o, T), c); ) U = T + 4, T = G(o, T); | ||
return U === A && D(o, n, z(o, n) + 1), 0 !== T ? (N(e.heap, c) === t.STRING && a.free(M(e.heap, c)), | ||
a.free(c), a.free(s), T + 0) : (T = s, function(t, r, e, n, i, o) { | ||
t.Uint32Array[(r + 0) / 4] = e, t.Uint32Array[(r + 4) / 4] = n, t.Uint32Array[(r + 8) / 4] = i, | ||
t.Uint32Array[(r + 12) / 4] = o; | ||
}(i, U, 0, 0, s, function(t, r, e) { | ||
}(o, T, 0, 0, c, function(t, r, e) { | ||
const {allocator: n, heap: i} = t, o = n.calloc(8); | ||
@@ -259,4 +263,4 @@ L(i, o, 0, 0); | ||
}(i, r, o), L(i, a, o, e), a; | ||
}(r, O(i, e), a)), i.Uint32Array[T / Uint32Array.BYTES_PER_ELEMENT] = a, C(i, e, Y(i, e) + 1), | ||
d = v(i, e), g = G(i, e), P = t.hashMapLoadFactor, g / d > P && function(t, r, e) { | ||
}(e, Y(o, n), s)), o.Uint32Array[U / Uint32Array.BYTES_PER_ELEMENT] = s, C(o, n, O(o, n) + 1), | ||
d = v(o, n), g = z(o, n), P = r.hashMapLoadFactor, g / d > P && function(t, r, e) { | ||
const {heap: n, allocator: i} = t; | ||
@@ -269,10 +273,10 @@ i.free(F(n, r)); | ||
t.Uint8Array[(r + 12) / 1] = e; | ||
}(n, r, e); | ||
}(n, r, e), D(n, r, 0); | ||
let a = 0; | ||
for (;0 !== (a = q(n, r, a)); ) tt(n, o, e, a); | ||
}(r, e, 2 * v(i, e)), U + 0); | ||
for (;0 !== (a = X(n, r, a)); ) et(n, r, a); | ||
}(e, n, 2 * v(o, n)), T + 0); | ||
var d, g, P; | ||
} | ||
function $(t, r, e) { | ||
function q(t, r, e) { | ||
const n = function(t, r) { | ||
@@ -282,8 +286,8 @@ const e = new ArrayBuffer("string" == typeof r ? 3 * r.length : 8), n = new Uint8Array(e); | ||
return "string" == typeof r ? i = u(new Uint8Array(e), 0, r) : new Float64Array(e)[0] = r, | ||
W(n, t, 0, i); | ||
J(n, t, 0, i); | ||
}(v(t, r), e), i = F(t, r) + n * Uint32Array.BYTES_PER_ELEMENT; | ||
let o = i, a = t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== a; ) { | ||
if (dt(t, D(t, a)) === e) return o; | ||
o = a + 4, a = z(t, a); | ||
if (Pt(t, W(t, a)) === e) return o; | ||
o = a + 4, a = G(t, a); | ||
} | ||
@@ -293,17 +297,17 @@ return 0; | ||
function K(t, r, e) { | ||
const {heap: n, allocator: i} = t, o = $(n, r, e); | ||
if (0 === o) return 0; | ||
const a = n.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT], s = a + 0; | ||
function Q(r, e, n) { | ||
const {heap: i, allocator: o} = r, a = q(i, e, n); | ||
if (0 === a) return 0; | ||
const s = i.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT], c = s + 0; | ||
return function({heap: t, allocator: r}, e) { | ||
const n = x(t, e); | ||
L(t, e, x(t, n), k(t, n)), r.free(n); | ||
}(t, j(n, a)), n.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = z(n, a), b(n, D(n, a)) === l.STRING && i.free(N(n, D(n, a))), | ||
i.free(D(n, a)), i.free(a), C(n, r, Y(n, r) - 1), s; | ||
}(r, V(i, s)), i.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = G(i, s), N(i, W(i, s)) === t.STRING && o.free(M(i, W(i, s))), | ||
o.free(W(i, s)), o.free(s), C(i, e, O(i, e) - 1), c; | ||
} | ||
function q(t, r, e) { | ||
function X(t, r, e) { | ||
let n = 0; | ||
0 !== e && (n = j(t, e)); | ||
const i = V(t, O(t, r), n); | ||
0 !== e && (n = V(t, e)); | ||
const i = H(t, Y(t, r), n); | ||
return 0 === i ? 0 : function(t, r) { | ||
@@ -314,18 +318,18 @@ return k(t, r); | ||
function Q(t, r) { | ||
function Z(t, r) { | ||
return { | ||
valuePointer: r + 0, | ||
keyPointer: D(t, r) | ||
keyPointer: W(t, r) | ||
}; | ||
} | ||
function X(t, r) { | ||
return Y(t, r); | ||
function tt(t, r) { | ||
return O(t, r); | ||
} | ||
function Z(t, r) { | ||
const e = [ r, F(t, r) ], n = [], i = function(t, r) { | ||
function rt(r, e) { | ||
const n = [ e, F(r, e) ], i = [], o = function(t, r) { | ||
const e = [ r ], n = [], i = w(t, r); | ||
i === R(t, r) && e.push(i); | ||
let o = V(t, r, 0); | ||
let o = H(t, r, 0); | ||
for (;0 !== o; ) e.push(o), 0 !== k(t, o) && n.push(k(t, o)), o = x(t, o); | ||
@@ -336,32 +340,31 @@ return { | ||
}; | ||
}(t, O(t, r)); | ||
e.push(...i.pointers); | ||
for (const r of i.valuePointers) n.push(r + 0), b(t, D(t, r)) === l.STRING && e.push(N(t, D(t, r))), | ||
e.push(r, D(t, r)); | ||
}(r, Y(r, e)); | ||
n.push(...o.pointers); | ||
for (const e of o.valuePointers) i.push(e + 0), N(r, W(r, e)) === t.STRING && n.push(M(r, W(r, e))), | ||
n.push(e, W(r, e)); | ||
return { | ||
pointers: e, | ||
pointersToValuePointers: n | ||
pointers: n, | ||
pointersToValuePointers: i | ||
}; | ||
} | ||
function tt(t, r, e, n) { | ||
const i = r + W(t.Uint8Array, e, function(t, r) { | ||
return b(t, r) === l.NUMBER ? r + 8 : N(t, r); | ||
}(t, n), function(t, r) { | ||
return b(t, r) === l.NUMBER ? p.BYTES_PER_ELEMENT : S(t, r); | ||
}(t, n)) % e * Uint32Array.BYTES_PER_ELEMENT, o = t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]; | ||
t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = n, function(t, r, e) { | ||
t.Uint32Array[(r + 4) / 4] = e; | ||
}(t, n, o); | ||
function et(r, e, n) { | ||
const i = J(r.Uint8Array, v(r, e), function(r, e) { | ||
return N(r, e) === t.NUMBER ? e + 8 : M(r, e); | ||
}(r, W(r, n)), function(r, e) { | ||
return N(r, e) === t.NUMBER ? p.BYTES_PER_ELEMENT : S(r, e); | ||
}(r, W(r, n))), o = F(r, e) + i * Uint32Array.BYTES_PER_ELEMENT, a = r.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT]; | ||
r.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = n, 0 !== a ? j(r, n, a) : (j(r, n, 0), | ||
D(r, e, z(r, e) + 1)); | ||
} | ||
function* rt(t, r) { | ||
function* nt(t, r) { | ||
let e = 0; | ||
for (;0 !== (e = q(t, r, e)); ) yield e; | ||
for (;0 !== (e = X(t, r, e)); ) yield e; | ||
} | ||
function et(t, r, e) { | ||
function it(t, r, e) { | ||
const n = new Set, i = new Set, o = [ e ]; | ||
let a = void 0; | ||
for (;void 0 !== (a = o.shift()); ) 0 !== a && nt(t, r, a, n, i, o); | ||
for (;void 0 !== (a = o.shift()); ) 0 !== a && ot(t, r, a, n, i, o); | ||
return { | ||
@@ -373,51 +376,47 @@ leafAddresses: n, | ||
function nt(t, r, e, n, i, o) { | ||
if (h(e) || n.has(e) || i.has(e)) return; | ||
const a = b(t, e), s = I(t, e); | ||
switch (a) { | ||
case l.NUMBER: | ||
case l.BIGINT_NEGATIVE: | ||
case l.BIGINT_POSITIVE: | ||
n.add(e); | ||
function ot(r, e, n, i, o, a) { | ||
if (l(n) || i.has(n) || o.has(n)) return; | ||
const s = N(r, n), c = I(r, n); | ||
switch (s) { | ||
case t.NUMBER: | ||
case t.BIGINT_NEGATIVE: | ||
case t.BIGINT_POSITIVE: | ||
i.add(n); | ||
break; | ||
case l.STRING: | ||
n.add(N(t, e)), n.add(e); | ||
case t.STRING: | ||
i.add(M(r, n)), i.add(n); | ||
break; | ||
case l.OBJECT: | ||
case l.MAP: | ||
case l.SET: | ||
s <= 1 || r ? (n.add(e), function(t, r, e, n) { | ||
const {pointersToValuePointers: i, pointers: o} = Z(t, r); | ||
case t.OBJECT: | ||
case t.MAP: | ||
case t.SET: | ||
c <= 1 || e ? (i.add(n), function(t, r, e, n) { | ||
const {pointersToValuePointers: i, pointers: o} = rt(t, r); | ||
for (const t of o) e.add(t); | ||
for (const r of i) n.push(t.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
}(t, _(t, e), n, o)) : i.add(e); | ||
}(r, _(r, n), i, a)) : o.add(n); | ||
break; | ||
case l.ARRAY: | ||
if (s <= 1 || r) { | ||
n.add(e), n.add(U(t, e)); | ||
const r = d(t, e); | ||
for (let n = 0; n < r; n += 1) { | ||
const r = t.Uint32Array[(U(t, e) + n * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT]; | ||
o.push(r); | ||
case t.ARRAY: | ||
if (c <= 1 || e) { | ||
i.add(n), i.add(T(r, n)); | ||
const t = d(r, n); | ||
for (let e = 0; e < t; e += 1) { | ||
const t = r.Uint32Array[(T(r, n) + e * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT]; | ||
a.push(t); | ||
} | ||
} else i.add(e); | ||
} else o.add(n); | ||
break; | ||
case l.DATE: | ||
s <= 1 || r ? n.add(e) : i.add(e); | ||
break; | ||
default: | ||
throw new Error(l[a] + " Not implemented yet"); | ||
case t.DATE: | ||
c <= 1 || e ? i.add(n) : o.add(n); | ||
} | ||
} | ||
const it = Math.clz32, ot = String.fromCharCode; | ||
const at = Math.clz32, st = String.fromCharCode; | ||
function at(t) { | ||
function ct(t) { | ||
let r = t.charCodeAt(0) << 24; | ||
const e = 0 | it(~r); | ||
const e = 0 | at(~r); | ||
let n = 0; | ||
@@ -428,3 +427,3 @@ const i = 0 | t.length; | ||
for (r = r << e >>> 24 + e, n = 1; n < e; n = n + 1 | 0) r = r << 6 | 63 & t.charCodeAt(n); | ||
r <= 65535 ? o += ot(r) : r <= 1114111 ? (r = r - 65536 | 0, o += ot(55296 + (r >> 10) | 0, 56320 + (1023 & r) | 0)) : n = 0; | ||
r <= 65535 ? o += st(r) : r <= 1114111 ? (r = r - 65536 | 0, o += st(55296 + (r >> 10) | 0, 56320 + (1023 & r) | 0)) : n = 0; | ||
} | ||
@@ -435,78 +434,78 @@ for (;n < i; n = n + 1 | 0) o += "�"; | ||
function st(t, r) { | ||
function ht(t, r) { | ||
return function(t, r, e) { | ||
const n = t.subarray(r, r + e); | ||
let i = ""; | ||
for (let t = 0, r = 0 | n.length; t < r; t = t + 32768 | 0) i += ot.apply(0, n.subarray(t, t + 32768 | 0)); | ||
return i.replace(/[\xc0-\xff][\x80-\xbf]*/g, at); | ||
}(t.Uint8Array, N(t, r), S(t, r)); | ||
for (let t = 0, r = 0 | n.length; t < r; t = t + 32768 | 0) i += st.apply(0, n.subarray(t, t + 32768 | 0)); | ||
return i.replace(/[\xc0-\xff][\x80-\xbf]*/g, ct); | ||
}(t.Uint8Array, M(t, r), S(t, r)); | ||
} | ||
function ct(t, r, e, n, i) { | ||
const o = i.length, a = r.allocator.calloc(24), s = o + t > 0 ? r.allocator.calloc((o + t) * Uint32Array.BYTES_PER_ELEMENT) : 0; | ||
P(r.heap, a, l.ARRAY, 1, s, o, o + t); | ||
for (let t = 0; t < o; t += 1) e.push(i[t]), n.push(s + t * Uint32Array.BYTES_PER_ELEMENT); | ||
return a; | ||
function lt(r, e, n, i, o) { | ||
const a = o.length, s = e.allocator.calloc(24), c = a + r > 0 ? e.allocator.calloc((a + r) * Uint32Array.BYTES_PER_ELEMENT) : 0; | ||
P(e.heap, s, t.ARRAY, 1, c, a, a + r); | ||
for (let t = 0; t < a; t += 1) n.push(o[t]), i.push(c + t * Uint32Array.BYTES_PER_ELEMENT); | ||
return s; | ||
} | ||
function ht(t, r, e, n, i) { | ||
const o = r.allocator.malloc(16), a = Object.entries(i), s = a.length, c = J(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * s))); | ||
for (let i = 0; i < s; i += 1) { | ||
const o = H(t, r, c, a[i][0]); | ||
e.push(a[i][1]), n.push(o); | ||
function ut(r, e, n, i, o) { | ||
const a = e.allocator.malloc(16), s = Object.entries(o), c = s.length, h = $(e, Math.max(r.hashMapMinInitialCapacity, Math.ceil(1.3 * c))); | ||
for (let t = 0; t < c; t += 1) { | ||
const o = K(r, e, h, s[t][0]); | ||
n.push(s[t][1]), i.push(o); | ||
} | ||
return m(r.heap, o, l.OBJECT, 1, c), o; | ||
return m(e.heap, a, t.OBJECT, 1, h), a; | ||
} | ||
function lt(t, r, e, n, i) { | ||
const o = r.allocator.malloc(16), a = J(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * i.size))); | ||
for (const [o, s] of i) { | ||
const i = H(t, r, a, o); | ||
e.push(s), n.push(i); | ||
function ft(r, e, n, i, o) { | ||
const a = e.allocator.malloc(16), s = $(e, Math.max(r.hashMapMinInitialCapacity, Math.ceil(1.3 * o.size))); | ||
for (const [t, a] of o) { | ||
const o = K(r, e, s, t); | ||
n.push(a), i.push(o); | ||
} | ||
return m(r.heap, o, l.MAP, 1, a), o; | ||
return m(e.heap, a, t.MAP, 1, s), a; | ||
} | ||
function ut(t, r, e) { | ||
const n = r.allocator.malloc(16), i = J(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * e.size))); | ||
for (const n of e) H(t, r, i, n); | ||
return m(r.heap, n, l.SET, 1, i), n; | ||
function pt(r, e, n) { | ||
const i = e.allocator.malloc(16), o = $(e, Math.max(r.hashMapMinInitialCapacity, Math.ceil(1.3 * n.size))); | ||
for (const t of n) K(r, e, o, t); | ||
return m(e.heap, i, t.SET, 1, o), i; | ||
} | ||
function ft(t, r, e, n, a) { | ||
const s = [ a ], h = [ n ], {heap: {Uint32Array: f}, allocator: p, heap: E} = r; | ||
for (;0 !== s.length; ) { | ||
const n = s.pop(), a = h.pop(); | ||
if (void 0 === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
function yt(r, e, n, i, s) { | ||
const c = [ s ], l = [ i ], {heap: {Uint32Array: f}, allocator: p, heap: E} = e; | ||
for (;0 !== c.length; ) { | ||
const i = c.pop(), s = l.pop(); | ||
if (void 0 === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
if (null === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 1; | ||
if (null === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 1; | ||
continue; | ||
} | ||
if (!0 === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 2; | ||
if (!0 === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 2; | ||
continue; | ||
} | ||
if (!1 === n) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 3; | ||
if (!1 === i) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 3; | ||
continue; | ||
} | ||
switch (typeof n) { | ||
switch (typeof i) { | ||
case "number": | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), y(E, f[a / Uint32Array.BYTES_PER_ELEMENT], l.NUMBER, n); | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), y(E, f[s / Uint32Array.BYTES_PER_ELEMENT], t.NUMBER, i); | ||
continue; | ||
case "string": | ||
const t = c(n), r = p.calloc(t); | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), u(E.Uint8Array, r, n), M(E, f[a / Uint32Array.BYTES_PER_ELEMENT], l.STRING, t, r); | ||
const r = h(i), e = p.calloc(r); | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), u(E.Uint8Array, e, i), b(E, f[s / Uint32Array.BYTES_PER_ELEMENT], t.STRING, r, e); | ||
continue; | ||
case "bigint": | ||
if (n > i || n < -i) { | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
if (i > o || i < -o) { | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), A(E, f[a / Uint32Array.BYTES_PER_ELEMENT], n > 0 ? l.BIGINT_POSITIVE : l.BIGINT_NEGATIVE, n * (n > 0 ? BigInt("1") : BigInt("-1"))); | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), A(E, f[s / Uint32Array.BYTES_PER_ELEMENT], i > 0 ? t.BIGINT_POSITIVE : t.BIGINT_NEGATIVE, i * (i > 0 ? BigInt("1") : BigInt("-1"))); | ||
continue; | ||
@@ -516,69 +515,69 @@ | ||
case "symbol": | ||
f[a / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
f[s / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
const U = o(n, r.allocator); | ||
U ? (e.push(U), E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = U) : Array.isArray(n) ? E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = ct(t.arrayAdditionalAllocation, r, s, h, n) : n instanceof Date ? (E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(24), | ||
T(E, E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT], l.DATE, 1, 0, n.getTime())) : n instanceof Map ? E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = lt(t, r, s, h, n) : n instanceof Set ? E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = ut(t, r, n) : E.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = ht(t, r, s, h, n); | ||
const T = a(i, e.allocator); | ||
T ? (n.push(T), E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = T) : Array.isArray(i) ? E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = lt(r.arrayAdditionalAllocation, e, c, l, i) : i instanceof Date ? (E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(24), | ||
U(E, E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT], t.DATE, 1, 0, i.getTime())) : i instanceof Map ? E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = ft(r, e, c, l, i) : i instanceof Set ? E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = pt(r, e, i) : E.Uint32Array[s / Uint32Array.BYTES_PER_ELEMENT] = ut(r, e, c, l, i); | ||
} | ||
} | ||
function pt(t, r, e, n) { | ||
function Et(t, r, e, n) { | ||
const i = []; | ||
return ft(t, r, i, e, n), i; | ||
return yt(t, r, i, e, n), i; | ||
} | ||
function yt(t, r, e, n) { | ||
const i = r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], o = pt(t, r, e, n); | ||
if (o.length > 0) for (const t of o) At(r.heap, t); | ||
Et(r, i); | ||
function At(t, r, e, n) { | ||
const i = r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], o = Et(t, r, e, n); | ||
if (o.length > 0) for (const t of o) Tt(r.heap, t); | ||
Ut(r, i); | ||
} | ||
function Et(t, r) { | ||
const {heap: e, allocator: n} = t; | ||
if (h(r)) return; | ||
const i = b(e, r); | ||
if ((o = i) !== l.OBJECT && o !== l.ARRAY && o !== l.DATE && o !== l.MAP && o !== l.SET) return i === l.STRING && n.free(N(t.heap, r)), | ||
void n.free(r); | ||
var o; | ||
if (Tt(e, r) > 0) return void n.free(r); | ||
const {leafAddresses: a, arcAddresses: s} = et(t.heap, !1, r); | ||
for (const t of a) n.free(t); | ||
for (const t of s) Tt(e, t); | ||
function Ut(r, e) { | ||
const {heap: n, allocator: i} = r; | ||
if (l(e)) return; | ||
const o = N(n, e); | ||
if ((a = o) !== t.OBJECT && a !== t.ARRAY && a !== t.DATE && a !== t.MAP && a !== t.SET) return o === t.STRING && i.free(M(r.heap, e)), | ||
void i.free(e); | ||
var a; | ||
if (dt(n, e) > 0) return void i.free(e); | ||
const {leafAddresses: s, arcAddresses: c} = it(r.heap, !1, e); | ||
for (const t of s) i.free(t); | ||
for (const t of c) dt(n, t); | ||
} | ||
function At(t, r) { | ||
function Tt(t, r) { | ||
return B(t, r, I(t, r) + 1), I(t, r); | ||
} | ||
function Tt(t, r) { | ||
function dt(t, r) { | ||
return B(t, r, I(t, r) - 1), I(t, r); | ||
} | ||
function Ut(t, r, e) { | ||
b(t, r); | ||
const n = b(t, r); | ||
if (n !== b(t, e)) return !1; | ||
if (n === l.STRING) { | ||
const n = S(t, r); | ||
return n === S(t, e) && function(t, r, e, n) { | ||
function gt(r, e, n) { | ||
N(r, e); | ||
const i = N(r, e); | ||
if (i !== N(r, n)) return !1; | ||
if (i === t.STRING) { | ||
const t = S(r, e); | ||
return t === S(r, n) && function(t, r, e, n) { | ||
if (t.byteLength < r + n || t.byteLength < e + n) return !1; | ||
for (let i = 0; i <= n - i; i += 1) if (t[r + i] !== t[e + i]) return !1; | ||
return !0; | ||
}(t.Uint8Array, N(t, r), N(t, e), n); | ||
}(r.Uint8Array, M(r, e), M(r, n), t); | ||
} | ||
return f(t, r) === f(t, e); | ||
return f(r, e) === f(r, n); | ||
} | ||
function dt(t, r) { | ||
return b(t, r) === l.NUMBER ? f(t, r) : st(t, r); | ||
function Pt(r, e) { | ||
return N(r, e) === t.NUMBER ? f(r, e) : ht(r, e); | ||
} | ||
function gt(t) { | ||
function _t(t) { | ||
if (null == t) throw new Error("assertNonNull"); | ||
} | ||
function Pt(t, r, e) { | ||
function mt(t, r, e) { | ||
if (e >= d(t.heap, r)) return; | ||
const n = U(t.heap, r) + e * Uint32Array.BYTES_PER_ELEMENT; | ||
const n = T(t.heap, r) + e * Uint32Array.BYTES_PER_ELEMENT; | ||
return { | ||
@@ -590,24 +589,24 @@ pointer: t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT], | ||
function _t(t, r, e, n) { | ||
const i = Pt(r, e, n); | ||
if (void 0 !== i) return Ft(t, r, i.pointer); | ||
function St(t, r, e, n) { | ||
const i = mt(r, e, n); | ||
if (void 0 !== i) return Ot(t, r, i.pointer); | ||
} | ||
function mt(t, r, e, n) { | ||
const i = Pt(t, r, e); | ||
gt(i), t.heap.Uint32Array[i.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
function Mt(t, r, e, n) { | ||
const i = mt(t, r, e); | ||
_t(i), t.heap.Uint32Array[i.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
} | ||
function St(t, r, e, n) { | ||
var i, o; | ||
n > d(r.heap, e) && (n > (i = r.heap, o = e, i.Uint32Array[(o + 20) / 4]) ? function(t, r, e, n) { | ||
const i = U(t.heap, r), o = 0 !== i ? t.allocator.realloc(i, e * Uint32Array.BYTES_PER_ELEMENT) : t.allocator.calloc(e * Uint32Array.BYTES_PER_ELEMENT); | ||
P(t.heap, r, l.ARRAY, function(t, r) { | ||
function bt(r, e, n, i) { | ||
var o, a; | ||
i > d(e.heap, n) && (i > (o = e.heap, a = n, o.Uint32Array[(a + 20) / 4]) ? function(r, e, n, i) { | ||
const o = T(r.heap, e), a = 0 !== o ? r.allocator.realloc(o, n * Uint32Array.BYTES_PER_ELEMENT) : r.allocator.calloc(n * Uint32Array.BYTES_PER_ELEMENT); | ||
P(r.heap, e, t.ARRAY, function(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
}(t.heap, r), o, n, e); | ||
}(r, e, n + t.arrayAdditionalAllocation, n) : g(r.heap, e, n)); | ||
}(r.heap, e), a, i, n); | ||
}(e, n, i + r.arrayAdditionalAllocation, i) : g(e.heap, n, i)); | ||
} | ||
function Nt(t, r, e, n = Mt) { | ||
const i = U(r.heap, e), o = [ ...new Array(d(r.heap, e)).keys() ].map(t => i + t * Uint32Array.BYTES_PER_ELEMENT).map(t => r.heap.Uint32Array[t / Uint32Array.BYTES_PER_ELEMENT]).map(e => [ e, Ft(t, r, e) ]); | ||
function Nt(t, r, e, n = It) { | ||
const i = T(r.heap, e), o = [ ...new Array(d(r.heap, e)).keys() ].map(t => i + t * Uint32Array.BYTES_PER_ELEMENT).map(t => r.heap.Uint32Array[t / Uint32Array.BYTES_PER_ELEMENT]).map(e => [ e, Ot(t, r, e) ]); | ||
o.sort((t, r) => n(t[1], r[1])); | ||
@@ -617,11 +616,11 @@ for (let t = 0; t < o.length; t += 1) r.heap.Uint32Array[(i + t * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT] = o[t][0]; | ||
function Mt(t, r) { | ||
function It(t, r) { | ||
if (void 0 === t && void 0 === r) return 0; | ||
if (void 0 === t) return 1; | ||
if (void 0 === r) return -1; | ||
const e = bt(t), n = bt(r); | ||
const e = Bt(t), n = Bt(r); | ||
return e < n ? -1 : e > n ? 1 : 0; | ||
} | ||
function bt(t) { | ||
function Bt(t) { | ||
if (null === t) return "null"; | ||
@@ -634,3 +633,3 @@ if ("boolean" == typeof t || "number" == typeof t) return t.toString(); | ||
function It(t, r, e, n, i, ...o) { | ||
function Rt(t, r, e, n, i, ...o) { | ||
const a = d(r.heap, e), s = function(t, r) { | ||
@@ -643,14 +642,14 @@ return r >= t ? t : r < 0 ? t + r : r; | ||
}(a, s, i), h = a + o.length - c; | ||
St(t, r, e, h); | ||
bt(t, r, e, h); | ||
const l = [], u = h - a; | ||
for (let n = s; n < s + c; n += 1) l.push(_t(t, r, e, n)), Et(r, Pt(r, e, n).pointer); | ||
for (let n = s; n < s + c; n += 1) l.push(St(t, r, e, n)), Ut(r, mt(r, e, n).pointer); | ||
if (u > 0) for (let t = h - 1; t >= s + u; t -= 1) { | ||
const n = Pt(r, e, t - u); | ||
gt(n), mt(r, e, t, n.pointer), r.heap.Uint32Array[n.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
const n = mt(r, e, t - u); | ||
_t(n), Mt(r, e, t, n.pointer), r.heap.Uint32Array[n.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
} else if (u < 0) for (let t = s + o.length; t < a + u; t += 1) { | ||
mt(r, e, t, Pt(r, e, t - u).pointer); | ||
Mt(r, e, t, mt(r, e, t - u).pointer); | ||
} | ||
for (let n = 0; n < o.length; n += 1) { | ||
const i = Pt(r, e, s + n); | ||
gt(i), pt(t, r, i.pointerToThePointer, o[n]); | ||
const i = mt(r, e, s + n); | ||
_t(i), Et(t, r, i.pointerToThePointer, o[n]); | ||
} | ||
@@ -692,3 +691,3 @@ return h < a && function(t, r, e) { | ||
function Bt(t, r) { | ||
function wt(t, r) { | ||
const e = [], n = r.malloc, i = r.calloc, o = r.realloc; | ||
@@ -722,6 +721,6 @@ let a = !1; | ||
constructor(t, r, e) { | ||
this.externalArgs = t, this.carrier = r, this._entryPointer = e, At(this.carrier.heap, this.entryPointer); | ||
this.externalArgs = t, this.carrier = r, this._entryPointer = e, Tt(this.carrier.heap, this.entryPointer); | ||
} | ||
destroy() { | ||
const t = Tt(this.carrier.heap, this.entryPointer); | ||
const t = dt(this.carrier.heap, this.entryPointer); | ||
return this._entryPointer = 0, t; | ||
@@ -748,4 +747,4 @@ } | ||
class ArrayWrapper extends BaseProxyTrap { | ||
get(r, e) { | ||
if (e === t) return this; | ||
get(t, e) { | ||
if (e === r) return this; | ||
if (e in this && "constructor" !== e) return this[e]; | ||
@@ -755,5 +754,5 @@ if ("length" === e) return d(this.carrier.heap, this.entryPointer); | ||
const t = "string" == typeof e ? Number.parseInt(e, 10) : e; | ||
if (Number.isSafeInteger(t)) return _t(this.externalArgs, this.carrier, this.entryPointer, t); | ||
if (Number.isSafeInteger(t)) return St(this.externalArgs, this.carrier, this.entryPointer, t); | ||
} | ||
return r[e]; | ||
return t[e]; | ||
} | ||
@@ -781,4 +780,4 @@ deleteProperty(t, r) { | ||
} | ||
has(r, e) { | ||
if (e === t) return !0; | ||
has(t, e) { | ||
if (e === r) return !0; | ||
const n = d(this.carrier.heap, this.entryPointer); | ||
@@ -794,5 +793,5 @@ if ("number" == typeof e) return n - 1 >= e; | ||
const t = d(this.carrier.heap, this.entryPointer); | ||
return t === e || Bt(() => { | ||
return t === e || wt(() => { | ||
if (t > e) return this.splice(e, t - e), !0; | ||
St(this.externalArgs, this.carrier, this.entryPointer, e); | ||
bt(this.externalArgs, this.carrier, this.entryPointer, e); | ||
}, this.carrier.allocator), !0; | ||
@@ -802,5 +801,5 @@ } | ||
if (!Number.isSafeInteger(n) || n < 0) throw new IllegalArrayIndexError; | ||
return Bt(() => { | ||
St(this.externalArgs, this.carrier, this.entryPointer, n + 1), function(t, r, e, n, i) { | ||
yt(t, r, Pt(r, e, n).pointerToThePointer, i); | ||
return wt(() => { | ||
bt(this.externalArgs, this.carrier, this.entryPointer, n + 1), function(t, r, e, n, i) { | ||
At(t, r, mt(r, e, n).pointerToThePointer, i); | ||
}(this.externalArgs, this.carrier, this.entryPointer, n, e); | ||
@@ -812,3 +811,3 @@ }, this.carrier.allocator), !0; | ||
do { | ||
yield [ t, _t(this.externalArgs, this.carrier, this.entryPointer, t) ], t += 1, | ||
yield [ t, St(this.externalArgs, this.carrier, this.entryPointer, t) ], t += 1, | ||
r = d(this.carrier.heap, this.entryPointer); | ||
@@ -826,3 +825,3 @@ } while (t < r); | ||
do { | ||
yield _t(this.externalArgs, this.carrier, this.entryPointer, t), t += 1, r = d(this.carrier.heap, this.entryPointer); | ||
yield St(this.externalArgs, this.carrier, this.entryPointer, t), t += 1, r = d(this.carrier.heap, this.entryPointer); | ||
} while (t < r); | ||
@@ -837,3 +836,3 @@ } | ||
splice(t, r, ...e) { | ||
return Bt(() => It(this.externalArgs, this.carrier, this.entryPointer, t, r, ...e), this.carrier.allocator); | ||
return wt(() => Rt(this.externalArgs, this.carrier, this.entryPointer, t, r, ...e), this.carrier.allocator); | ||
} | ||
@@ -843,4 +842,4 @@ reverse() { | ||
for (let e = 0; e < Math.floor(d(t.heap, r) / 2); e += 1) { | ||
const n = d(t.heap, r) - e - 1, i = Pt(t, r, e); | ||
mt(t, r, e, Pt(t, r, n).pointer), mt(t, r, n, i.pointer); | ||
const n = d(t.heap, r) - e - 1, i = mt(t, r, e); | ||
Mt(t, r, e, mt(t, r, n).pointer), Mt(t, r, n, i.pointer); | ||
} | ||
@@ -872,3 +871,3 @@ }(this.carrier, this.entryPointer), this; | ||
const Rt = [ "toString", "toDateString", "toTimeString", "toISOString", "toUTCString", "getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds", "getTime", "getTimezoneOffset", "getUTCDate", "getUTCDay", "getUTCFullYear", "getUTCHours", "getUTCMilliseconds", "getUTCMinutes", "getUTCMonth", "getUTCSeconds", "toJSON", "toLocaleString", "toLocaleDateString", "toLocaleTimeString" ], wt = [ "setDate", "setFullYear", "setHours", "setMilliseconds", "setMinutes", "setMonth", "setSeconds", "setTime", "getTimezoneOffset", "setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds" ]; | ||
const xt = [ "toString", "toDateString", "toTimeString", "toISOString", "toUTCString", "getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds", "getTime", "getTimezoneOffset", "getUTCDate", "getUTCDay", "getUTCFullYear", "getUTCHours", "getUTCMilliseconds", "getUTCMinutes", "getUTCMonth", "getUTCSeconds", "toJSON", "toLocaleString", "toLocaleDateString", "toLocaleTimeString" ], kt = [ "setDate", "setFullYear", "setHours", "setMilliseconds", "setMinutes", "setMonth", "setSeconds", "setTime", "getTimezoneOffset", "setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds" ]; | ||
@@ -879,9 +878,9 @@ class DateWrapper extends BaseProxyTrap { | ||
} | ||
get(r, e) { | ||
return e === t ? this : Rt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = () => (this.updateDateObjectForReuse(), | ||
this.dateObjectForReuse[e]())), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : wt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = (...t) => { | ||
get(t, e) { | ||
return e === r ? this : xt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = () => (this.updateDateObjectForReuse(), | ||
this.dateObjectForReuse[e]())), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : kt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = (...t) => { | ||
this.updateDateObjectForReuse(); | ||
const r = this.dateObjectForReuse[e](...t); | ||
return this.persistDateObject(), r; | ||
}), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : r[e]; | ||
}), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : t[e]; | ||
} | ||
@@ -893,5 +892,5 @@ updateDateObjectForReuse() { | ||
persistDateObject() { | ||
var t, r; | ||
T(this.carrier.heap, this.entryPointer, l.DATE, (t = this.carrier.heap, r = this.entryPointer, | ||
t.Uint32Array[(r + 8) / 4]), 0, this.dateObjectForReuse.getTime()); | ||
var r, e; | ||
U(this.carrier.heap, this.entryPointer, t.DATE, (r = this.carrier.heap, e = this.entryPointer, | ||
r.Uint32Array[(e + 8) / 4]), 0, this.dateObjectForReuse.getTime()); | ||
} | ||
@@ -970,8 +969,8 @@ defineProperty() { | ||
const xt = new WeakMap; | ||
const Lt = new WeakMap; | ||
function kt(t, r) { | ||
let e = xt.get(t); | ||
function Ft(t, r) { | ||
let e = Lt.get(t); | ||
return e || (e = "undefined" != typeof WeakRef && 1 ? new WeakValueMap(void 0, r) : new Map, | ||
xt.set(t, e)), e; | ||
Lt.set(t, e)), e; | ||
} | ||
@@ -987,3 +986,3 @@ | ||
get size() { | ||
return X(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
return tt(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
} | ||
@@ -994,17 +993,17 @@ [Symbol.iterator]() { | ||
* entries() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r, keyPointer: e} = Q(this.carrier.heap, t); | ||
yield [ Ft(this.externalArgs, this.carrier, e), Ft(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]) ]; | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r, keyPointer: e} = Z(this.carrier.heap, t); | ||
yield [ Ot(this.externalArgs, this.carrier, e), Ot(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]) ]; | ||
} | ||
} | ||
* keys() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
} | ||
* values() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r} = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r} = Z(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
@@ -1015,3 +1014,3 @@ } | ||
} | ||
get [t]() { | ||
get [r]() { | ||
return this; | ||
@@ -1023,13 +1022,13 @@ } | ||
get(t) { | ||
if ("string" == typeof t || "number" == typeof t) return vt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
if ("string" == typeof t || "number" == typeof t) return Dt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
delete(t) { | ||
return ("string" == typeof t || "number" == typeof t) && Ot(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && Ct(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
has(t) { | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== $(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== q(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
set(t, r) { | ||
return "string" != typeof t && "number" != typeof t || Bt(() => { | ||
Ct(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, r); | ||
return "string" != typeof t && "number" != typeof t || wt(() => { | ||
zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, r); | ||
}, this.carrier.allocator), this; | ||
@@ -1047,3 +1046,3 @@ } | ||
get size() { | ||
return X(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
return tt(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
} | ||
@@ -1054,4 +1053,4 @@ [Symbol.iterator]() { | ||
* entries() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t), e = Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t), e = Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
yield [ e, e ]; | ||
@@ -1061,11 +1060,11 @@ } | ||
* keys() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
} | ||
* values() { | ||
for (const t of rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Q(this.carrier.heap, t); | ||
yield Ft(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of nt(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = Z(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
@@ -1076,3 +1075,3 @@ } | ||
} | ||
get [t]() { | ||
get [r]() { | ||
return this; | ||
@@ -1084,26 +1083,26 @@ } | ||
has(t) { | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== $(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== q(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
add(t) { | ||
return "string" != typeof t && "number" != typeof t || Bt(() => { | ||
Ct(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, void 0); | ||
return "string" != typeof t && "number" != typeof t || wt(() => { | ||
zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, void 0); | ||
}, this.carrier.allocator), this; | ||
} | ||
delete(t) { | ||
return ("string" == typeof t || "number" == typeof t) && Ot(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && Ct(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
} | ||
const Lt = { | ||
[l.OBJECT]: zt, | ||
[l.DATE]: function(t, r, e) { | ||
const Yt = { | ||
[t.OBJECT]: jt, | ||
[t.DATE]: function(t, r, e) { | ||
return new Proxy(new Date(0), new DateWrapper(t, r, e)); | ||
}, | ||
[l.ARRAY]: function(t, r, e) { | ||
[t.ARRAY]: function(t, r, e) { | ||
return new Proxy([], new ArrayWrapper(t, r, e)); | ||
}, | ||
[l.MAP]: function(t, r, e) { | ||
[t.MAP]: function(t, r, e) { | ||
return new MapWrapper(t, r, e); | ||
}, | ||
[l.SET]: function(t, r, e) { | ||
[t.SET]: function(t, r, e) { | ||
return new SetWrapper(t, r, e); | ||
@@ -1113,64 +1112,64 @@ } | ||
function Ft(t, r, e) { | ||
if (0 === e) return; | ||
if (1 === e) return null; | ||
if (2 === e) return !0; | ||
if (3 === e) return !1; | ||
const n = b(r.heap, e); | ||
switch (n) { | ||
case l.NUMBER: | ||
return f(r.heap, e); | ||
function Ot(r, e, n) { | ||
if (0 === n) return; | ||
if (1 === n) return null; | ||
if (2 === n) return !0; | ||
if (3 === n) return !1; | ||
const i = N(e.heap, n); | ||
switch (i) { | ||
case t.NUMBER: | ||
return f(e.heap, n); | ||
case l.STRING: | ||
return st(r.heap, e); | ||
case t.STRING: | ||
return ht(e.heap, n); | ||
case l.BIGINT_POSITIVE: | ||
return E(r.heap, e); | ||
case t.BIGINT_POSITIVE: | ||
return E(e.heap, n); | ||
case l.BIGINT_NEGATIVE: | ||
return E(r.heap, e) * BigInt("-1"); | ||
case t.BIGINT_NEGATIVE: | ||
return E(e.heap, n) * BigInt("-1"); | ||
} | ||
if (n !== l.OBJECT && n !== l.DATE && n !== l.ARRAY && n !== l.MAP && n !== l.SET) throw new Error("Nope Nope Nope"); | ||
const i = kt(r, t => { | ||
if (i !== t.OBJECT && i !== t.DATE && i !== t.ARRAY && i !== t.MAP && i !== t.SET) throw new Error("Nope Nope Nope"); | ||
const o = Ft(e, t => { | ||
!function(t, r) { | ||
if (0 === Tt(r.heap, t)) { | ||
const e = et(r.heap, !1, t); | ||
if (0 === dt(r.heap, t)) { | ||
const e = it(r.heap, !1, t); | ||
for (const t of e.leafAddresses) r.allocator.free(t); | ||
for (const t of e.arcAddresses) Tt(r.heap, t); | ||
for (const t of e.arcAddresses) dt(r.heap, t); | ||
} | ||
}(t, r); | ||
}(t, e); | ||
}); | ||
let o = i.get(e); | ||
return o || (o = Lt[n](t, r, e), i.set(e, o)), o; | ||
let a = o.get(n); | ||
return a || (a = Yt[i](r, e, n), o.set(n, a)), a; | ||
} | ||
function Ot(t, r, e) { | ||
const n = K(t, r, e); | ||
function Ct(t, r, e) { | ||
const n = Q(t, r, e); | ||
if (0 === n) return !1; | ||
return Et(t, t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]), !0; | ||
return Ut(t, t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]), !0; | ||
} | ||
function Yt(t, r) { | ||
let e = 0; | ||
const n = []; | ||
for (;e = q(t.heap, r, e); ) { | ||
const {valuePointer: r, keyPointer: i} = Q(t.heap, e), o = b(t.heap, i) === l.NUMBER ? f(t.heap, i) : st(t.heap, i); | ||
n.push({ | ||
valuePointer: t.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT], | ||
key: o | ||
function vt(r, e) { | ||
let n = 0; | ||
const i = []; | ||
for (;n = X(r.heap, e, n); ) { | ||
const {valuePointer: e, keyPointer: o} = Z(r.heap, n), a = N(r.heap, o) === t.NUMBER ? f(r.heap, o) : ht(r.heap, o); | ||
i.push({ | ||
valuePointer: r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], | ||
key: a | ||
}); | ||
} | ||
return n; | ||
return i; | ||
} | ||
function Ct(t, r, e, n, i) { | ||
yt(t, r, H(t, r, e, n), i); | ||
function zt(t, r, e, n, i) { | ||
At(t, r, K(t, r, e, n), i); | ||
} | ||
function vt(t, r, e, n) { | ||
function Dt(t, r, e, n) { | ||
const i = function(t, r, e) { | ||
const n = $(t, r, e); | ||
const n = q(t, r, e); | ||
return 0 === n ? 0 : t.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT] + 0; | ||
}(r.heap, e, n); | ||
return Ft(t, r, r.heap.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]); | ||
return Ot(t, r, r.heap.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
@@ -1181,21 +1180,21 @@ | ||
B(r.heap, e, 0); | ||
const {leafAddresses: i, arcAddresses: o} = et(r.heap, !1, e); | ||
const {leafAddresses: i, arcAddresses: o} = it(r.heap, !1, e); | ||
for (const t of i) t !== e && r.allocator.free(t); | ||
for (const t of o) t !== e && Tt(r.heap, t); | ||
for (const t of o) t !== e && dt(r.heap, t); | ||
var a, s, c; | ||
B(r.heap, e, n), a = r.heap, s = e, c = J(r, t.hashMapMinInitialCapacity), a.Uint32Array[(s + 12) / 4] = c; | ||
B(r.heap, e, n), a = r.heap, s = e, c = $(r, t.hashMapMinInitialCapacity), a.Uint32Array[(s + 12) / 4] = c; | ||
} | ||
class ObjectWrapper extends BaseProxyTrap { | ||
get(r, e) { | ||
return e === t ? this : "symbol" != typeof e ? vt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), e) : void 0; | ||
get(t, e) { | ||
return e === r ? this : "symbol" != typeof e ? Dt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), e) : void 0; | ||
} | ||
deleteProperty(t, r) { | ||
return "symbol" != typeof r && Ot(this.carrier, _(this.carrier.heap, this.entryPointer), r); | ||
return "symbol" != typeof r && Ct(this.carrier, _(this.carrier.heap, this.entryPointer), r); | ||
} | ||
enumerate() { | ||
return Yt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
return vt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
} | ||
ownKeys() { | ||
return Yt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
return vt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
} | ||
@@ -1208,9 +1207,9 @@ getOwnPropertyDescriptor(t, r) { | ||
} | ||
has(r, e) { | ||
return e === t || "symbol" != typeof e && 0 !== $(this.carrier.heap, _(this.carrier.heap, this.entryPointer), e); | ||
has(t, e) { | ||
return e === r || "symbol" != typeof e && 0 !== q(this.carrier.heap, _(this.carrier.heap, this.entryPointer), e); | ||
} | ||
set(t, r, e) { | ||
if ("symbol" == typeof r) throw new IllegalObjectPropConfigError; | ||
return Bt(() => { | ||
Ct(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), r, e); | ||
return wt(() => { | ||
zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), r, e); | ||
}, this.carrier.allocator), !0; | ||
@@ -1232,3 +1231,3 @@ } | ||
function zt(t, r, e) { | ||
function jt(t, r, e) { | ||
return new Proxy({ | ||
@@ -1239,3 +1238,3 @@ objectBufferWrapper: "objectBufferWrapper" | ||
var Dt, jt; | ||
var Wt, Vt; | ||
@@ -1246,44 +1245,44 @@ !function(t) { | ||
t[t.F64 = 8] = "F64"; | ||
}(Dt || (Dt = {})), function(t) { | ||
}(Wt || (Wt = {})), function(t) { | ||
t[t.I8 = 5120] = "I8", t[t.U8 = 5121] = "U8", t[t.I16 = 5122] = "I16", t[t.U16 = 5123] = "U16", | ||
t[t.I32 = 5124] = "I32", t[t.U32 = 5125] = "U32", t[t.F32 = 5126] = "F32"; | ||
}(jt || (jt = {})); | ||
}(Vt || (Vt = {})); | ||
jt.I8, Dt.I8, jt.U8, Dt.U8, jt.I16, Dt.I16, jt.U16, Dt.U16, jt.I32, Dt.I32, jt.U32, | ||
Dt.U32, jt.F32, Dt.F32, Dt.I8, jt.I8, Dt.U8, jt.U8, Dt.U8C, jt.U8, Dt.I16, jt.I16, | ||
Dt.U16, jt.U16, Dt.I32, jt.I32, Dt.I32, jt.I32, Dt.U32, jt.U32, Dt.F32, jt.F32, | ||
Dt.F64; | ||
Vt.I8, Wt.I8, Vt.U8, Wt.U8, Vt.I16, Wt.I16, Vt.U16, Wt.U16, Vt.I32, Wt.I32, Vt.U32, | ||
Wt.U32, Vt.F32, Wt.F32, Wt.I8, Vt.I8, Wt.U8, Vt.U8, Wt.U8C, Vt.U8, Wt.I16, Vt.I16, | ||
Wt.U16, Vt.U16, Wt.I32, Vt.I32, Wt.I32, Vt.I32, Wt.U32, Vt.U32, Wt.F32, Vt.F32, | ||
Wt.F64; | ||
const Wt = { | ||
[Dt.U8]: 1, | ||
[Dt.U8C]: 1, | ||
[Dt.I8]: 1, | ||
[Dt.U16]: 2, | ||
[Dt.I16]: 2, | ||
[Dt.U32]: 4, | ||
[Dt.I32]: 4, | ||
[Dt.F32]: 4, | ||
[Dt.F64]: 8 | ||
}, Vt = { | ||
[Dt.U8]: Uint8Array, | ||
[Dt.U8C]: Uint8ClampedArray, | ||
[Dt.I8]: Int8Array, | ||
[Dt.U16]: Uint16Array, | ||
[Dt.I16]: Int16Array, | ||
[Dt.U32]: Uint32Array, | ||
[Dt.I32]: Int32Array, | ||
[Dt.F32]: Float32Array, | ||
[Dt.F64]: Float64Array, | ||
[jt.U8]: Uint8Array, | ||
[jt.I8]: Int8Array, | ||
[jt.U16]: Uint16Array, | ||
[jt.I16]: Int16Array, | ||
[jt.U32]: Uint32Array, | ||
[jt.I32]: Int32Array, | ||
[jt.F32]: Float32Array | ||
const Jt = { | ||
[Wt.U8]: 1, | ||
[Wt.U8C]: 1, | ||
[Wt.I8]: 1, | ||
[Wt.U16]: 2, | ||
[Wt.I16]: 2, | ||
[Wt.U32]: 4, | ||
[Wt.I32]: 4, | ||
[Wt.F32]: 4, | ||
[Wt.F64]: 8 | ||
}, Ht = { | ||
[Wt.U8]: Uint8Array, | ||
[Wt.U8C]: Uint8ClampedArray, | ||
[Wt.I8]: Int8Array, | ||
[Wt.U16]: Uint16Array, | ||
[Wt.I16]: Int16Array, | ||
[Wt.U32]: Uint32Array, | ||
[Wt.I32]: Int32Array, | ||
[Wt.F32]: Float32Array, | ||
[Wt.F64]: Float64Array, | ||
[Vt.U8]: Uint8Array, | ||
[Vt.I8]: Int8Array, | ||
[Vt.U16]: Uint16Array, | ||
[Vt.I16]: Int16Array, | ||
[Vt.U32]: Uint32Array, | ||
[Vt.I32]: Int32Array, | ||
[Vt.F32]: Float32Array | ||
}; | ||
const Jt = "undefined" == typeof process || "production" !== process.env.NODE_ENV || "1" === process.env.UMBRELLA_ASSERTS ? (t, r = "assertion failed") => { | ||
const $t = "undefined" == typeof process || "production" !== process.env.NODE_ENV || "1" === process.env.UMBRELLA_ASSERTS ? (t, r = "assertion failed") => { | ||
if ("function" == typeof t && !t() || !t) throw new Error("function" == typeof r ? r() : r); | ||
} : () => {}, Ht = (t, r) => t + --r & ~r, $t = ((t, r = (t => void 0 !== t ? ": " + t : "")) => class extends Error { | ||
} : () => {}, Kt = (t, r) => t + --r & ~r, qt = ((t, r = (t => void 0 !== t ? ": " + t : "")) => class extends Error { | ||
constructor(e) { | ||
@@ -1296,10 +1295,10 @@ super(t(e) + r(e)); | ||
constructor(t = {}) { | ||
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = null != t.start ? Ht(Math.max(t.start, 0), 4) : 0, | ||
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = null != t.start ? Kt(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, 7), | ||
!t.skipInitialization) { | ||
const r = t.align || 8; | ||
Jt(r >= 8, `invalid alignment: ${r}, must be a pow2 and >= 8`); | ||
$t(r >= 8, `invalid alignment: ${r}, must be a pow2 and >= 8`); | ||
const e = this.initialTop(r), n = null != t.end ? Math.min(t.end, this.buf.byteLength) : this.buf.byteLength; | ||
e >= n && (t => { | ||
throw new $t(t); | ||
throw new qt(t); | ||
})(`insufficient address range (0x${this.start.toString(16)} - 0x${n.toString(16)})`), | ||
@@ -1332,5 +1331,5 @@ this.align = r, this.doCompact = !1 !== t.compact, this.doSplit = !1 !== t.split, | ||
mallocAs(t, r) { | ||
const e = this.malloc(r * Wt[t]); | ||
const e = this.malloc(r * Jt[t]); | ||
return e ? function(t, ...r) { | ||
return new Vt[t](...r); | ||
return new Ht[t](...r); | ||
}(t, this.buf, e, r) : void 0; | ||
@@ -1344,3 +1343,3 @@ } | ||
if (t <= 0) return 0; | ||
const r = Ht(t + 8, this.align), e = this.end; | ||
const r = Kt(t + 8, this.align), e = this.end; | ||
let n = this.top, i = this._free, o = 0; | ||
@@ -1356,3 +1355,3 @@ for (;i; ) { | ||
} | ||
return Kt(i); | ||
return Qt(i); | ||
} | ||
@@ -1362,7 +1361,7 @@ o = i, i = this.blockNext(i); | ||
return i = n, n = i + r, n <= e ? (this.initBlock(i, r, this._used), this._used = i, | ||
this.top = n, Kt(i)) : 0; | ||
this.top = n, Qt(i)) : 0; | ||
} | ||
realloc(t, r) { | ||
if (r <= 0) return 0; | ||
const e = qt(t); | ||
const e = Xt(t); | ||
let n = 0, i = this._used, o = 0; | ||
@@ -1373,3 +1372,3 @@ for (;i; ) { | ||
o = e + t; | ||
const a = o >= this.top, s = Ht(r + 8, this.align); | ||
const a = o >= this.top, s = Kt(r + 8, this.align); | ||
if (s <= t) { | ||
@@ -1387,3 +1386,3 @@ if (this.doSplit) { | ||
} | ||
this.free(e), n = qt(this.malloc(r)); | ||
this.free(e), n = Xt(this.malloc(r)); | ||
break; | ||
@@ -1393,3 +1392,3 @@ } | ||
} | ||
return n && n !== e && this.u8.copyWithin(Kt(n), Kt(e), o), Kt(n); | ||
return n && n !== e && this.u8.copyWithin(Qt(n), Qt(e), o), Qt(n); | ||
} | ||
@@ -1407,3 +1406,3 @@ reallocArray(t, r) { | ||
} else r = t; | ||
r = qt(r); | ||
r = Xt(r); | ||
let e = this._used, n = 0; | ||
@@ -1469,3 +1468,3 @@ for (;e; ) { | ||
set minSplit(t) { | ||
Jt(t > 8, `illegal min split threshold: ${t}, require at least 9`), this.state[6] = t; | ||
$t(t > 8, `illegal min split threshold: ${t}, require at least 9`), this.state[6] = t; | ||
} | ||
@@ -1495,3 +1494,3 @@ blockSize(t) { | ||
initialTop(t = this.align) { | ||
return Ht(this.start + 28 + 8, t) - 8; | ||
return Kt(this.start + 28 + 8, t) - 8; | ||
} | ||
@@ -1525,3 +1524,3 @@ compact() { | ||
const Kt = t => t + 8, qt = t => t - 8, Qt = { | ||
const Qt = t => t + 8, Xt = t => t - 8, Zt = { | ||
Uint8Array: Uint8Array, | ||
@@ -1540,16 +1539,16 @@ Uint8ClampedArray: Uint8ClampedArray, | ||
function Xt(t) { | ||
return Object.fromEntries(Object.entries(Qt).map(([r, e]) => [ r, new e(t) ])); | ||
function tr(t) { | ||
return Object.fromEntries(Object.entries(Zt).map(([r, e]) => [ r, new e(t) ])); | ||
} | ||
function Zt() { | ||
function rr() { | ||
return console.warn("FAKE VALUE"), Math.pow(2, 24); | ||
} | ||
function tr(t) { | ||
const r = s(t), e = r.getEntryPointer(), n = r.destroy(); | ||
if (kt(r.getCarrier()).delete(e), 0 === n) { | ||
const t = et(r.getCarrier().heap, !1, e), {allocator: n, heap: i} = r.getCarrier(); | ||
function er(t) { | ||
const r = c(t), e = r.getEntryPointer(), n = r.destroy(); | ||
if (Ft(r.getCarrier()).delete(e), 0 === n) { | ||
const t = it(r.getCarrier().heap, !1, e), {allocator: n, heap: i} = r.getCarrier(); | ||
for (const r of t.leafAddresses) n.free(r); | ||
for (const r of t.arcAddresses) Tt(i, r); | ||
for (const r of t.arcAddresses) dt(i, r); | ||
return !0; | ||
@@ -1560,9 +1559,9 @@ } | ||
function rr(t, i, o, s = {}) { | ||
function nr(t, r, o, a = {}) { | ||
if (c = o, Array.isArray(c) || c instanceof Date || c instanceof Map || c instanceof Set || "object" != typeof c || null === typeof c || "Object" !== c.constructor.name) throw new UnsupportedOperationError; | ||
var c; | ||
const h = new (s.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer)(i); | ||
const h = new (a.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer)(r); | ||
!function(t) { | ||
const n = new Uint32Array(t); | ||
n[0] = 0, n[r / Uint32Array.BYTES_PER_ELEMENT] = e; | ||
const r = new Uint32Array(t); | ||
r[0] = 0, r[e / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
}(h); | ||
@@ -1572,71 +1571,73 @@ const l = new MemPool({ | ||
buf: h, | ||
start: n | ||
start: i | ||
}), u = { | ||
allocator: l, | ||
heap: Xt(h) | ||
heap: tr(h) | ||
}; | ||
return Bt(() => { | ||
ft(a(t), u, [], r, o); | ||
}, l), zt(a(t), u, u.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
return wt(() => { | ||
yt(s(t), u, [], e, o); | ||
}, l), jt(s(t), u, u.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
function er(t, r) { | ||
const e = nr(t), n = new ArrayBuffer(r); | ||
function ir(t, r) { | ||
const e = or(t), n = new ArrayBuffer(r); | ||
return function(t, r, e, n, i) { | ||
const o = new Uint8Array(t); | ||
new Uint8Array(n).set(o.subarray(r, r + e), i); | ||
}(e, 0, Math.min(r, e.byteLength), n, 0), or(t, n), n; | ||
}(e, 0, Math.min(r, e.byteLength), n, 0), sr(t, n), n; | ||
} | ||
function nr(t) { | ||
return s(t).getCarrier().heap.Uint8Array.buffer; | ||
function or(t) { | ||
return c(t).getCarrier().heap.Uint8Array.buffer; | ||
} | ||
function ir(t, e) { | ||
const i = { | ||
function ar(t, r) { | ||
const n = { | ||
allocator: new MemPool({ | ||
align: 8, | ||
buf: e, | ||
start: n, | ||
buf: r, | ||
start: i, | ||
skipInitialization: !0 | ||
}), | ||
heap: Xt(e) | ||
heap: tr(r) | ||
}; | ||
return zt(a(t), i, i.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
return jt(s(t), n, n.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
function or(t, r) { | ||
const e = kt(nr(t)), i = kt(r); | ||
for (const t of e) i.set(t[0], t[1]), e.delete(t[0]); | ||
function sr(t, r) { | ||
const e = Ft(or(t)), n = Ft(r); | ||
for (const t of e) n.set(t[0], t[1]), e.delete(t[0]); | ||
const o = new MemPool({ | ||
align: 8, | ||
buf: r, | ||
start: n, | ||
start: i, | ||
skipInitialization: !0 | ||
}), a = { | ||
allocator: o, | ||
heap: Xt(r) | ||
heap: tr(r) | ||
}; | ||
o.end = r.byteLength, s(t).replaceCarrierContent(a); | ||
o.end = r.byteLength, c(t).replaceCarrierContent(a); | ||
} | ||
function ar(t) { | ||
const r = nr(t), e = new MemPool({ | ||
function cr(t) { | ||
const r = or(t), e = new MemPool({ | ||
align: 8, | ||
buf: r, | ||
skipInitialization: !0, | ||
start: n | ||
}), {available: i, total: o} = e.stats(); | ||
start: i | ||
}), {available: n, total: o, top: a} = e.stats(); | ||
return { | ||
available: i, | ||
used: o - i | ||
available: n, | ||
used: o - n, | ||
total: o, | ||
top: a | ||
}; | ||
} | ||
function sr(t, r) { | ||
Object.assign(s(t).getExternalArgs(), r); | ||
function hr(t, r) { | ||
Object.assign(c(t).getExternalArgs(), r); | ||
} | ||
function cr(t, r) { | ||
const e = nr(r); | ||
function lr(t, r) { | ||
const e = or(r); | ||
!function(t, r) { | ||
@@ -1649,4 +1650,4 @@ if (!t) throw new Error(r); | ||
function hr(t, r) { | ||
const e = nr(r), n = new Int32Array(e); | ||
function ur(t, r) { | ||
const e = or(r), n = new Int32Array(e); | ||
return Atomics.compareExchange(n, 0, t, 0) === t && (Atomics.notify(n, 0, 1 / 0), | ||
@@ -1656,4 +1657,4 @@ !0); | ||
function lr(t, r, e) { | ||
const n = nr(r), i = new Int32Array(n), o = Atomics.compareExchange(i, 0, 0, t); | ||
function fr(t, r, e) { | ||
const n = or(r), i = new Int32Array(n), o = Atomics.compareExchange(i, 0, 0, t); | ||
if (0 === o) return "have-lock"; | ||
@@ -1664,3 +1665,3 @@ const a = Atomics.wait(i, 0, o, e); | ||
export { cr as acquireLock, lr as acquireLockWait, rr as createObjectBuffer, tr as disposeWrapperObject, nr as getUnderlyingArrayBuffer, ir as loadObjectBuffer, ar as memoryStats, hr as releaseLock, or as replaceUnderlyingArrayBuffer, er as resizeObjectBuffer, Zt as unreliable_sizeOf, sr as updateExternalArgs }; | ||
export { lr as acquireLock, fr as acquireLockWait, nr as createObjectBuffer, er as disposeWrapperObject, or as getUnderlyingArrayBuffer, ar as loadObjectBuffer, cr as memoryStats, ur as releaseLock, sr as replaceUnderlyingArrayBuffer, ir as resizeObjectBuffer, rr as unreliable_sizeOf, hr as updateExternalArgs }; | ||
//# sourceMappingURL=objectbuffer.esm.js.map |
var t, r; | ||
t = this, r = function(t) { | ||
const r = Symbol("INTERNAL_API"), e = 0 + Uint32Array.BYTES_PER_ELEMENT, n = e + Uint32Array.BYTES_PER_ELEMENT, i = n + Uint32Array.BYTES_PER_ELEMENT, o = BigInt("0xFFFFFFFFFFFFFFFF"); | ||
function a(t, e) { | ||
if (r in t) { | ||
const r = c(t); | ||
if (r.getCarrier().allocator === e) return r.getEntryPointer(); | ||
let r; | ||
!function(t) { | ||
t[t.UNDEFINED = 0] = "UNDEFINED", t[t.NULL = 1] = "NULL", t[t.NUMBER = 2] = "NUMBER", | ||
t[t.BIGINT_POSITIVE = 3] = "BIGINT_POSITIVE", t[t.BIGINT_NEGATIVE = 4] = "BIGINT_NEGATIVE", | ||
t[t.STRING = 5] = "STRING", t[t.BOOLEAN = 6] = "BOOLEAN", t[t.OBJECT = 7] = "OBJECT", | ||
t[t.OBJECT_PROP = 8] = "OBJECT_PROP", t[t.ARRAY = 9] = "ARRAY", t[t.ARRAY_ITEM = 10] = "ARRAY_ITEM", | ||
t[t.MAP = 11] = "MAP", t[t.SET = 12] = "SET", t[t.DATE = 13] = "DATE"; | ||
}(r || (r = {})); | ||
const e = Symbol("INTERNAL_API"), n = 0 + Uint32Array.BYTES_PER_ELEMENT, i = n + Uint32Array.BYTES_PER_ELEMENT, o = i + Uint32Array.BYTES_PER_ELEMENT, a = BigInt("0xFFFFFFFFFFFFFFFF"); | ||
function s(t, r) { | ||
if (e in t) { | ||
const e = h(t); | ||
if (e.getCarrier().allocator === r) return e.getEntryPointer(); | ||
} | ||
} | ||
function s(t) { | ||
function c(t) { | ||
return { | ||
@@ -19,7 +27,7 @@ ...t, | ||
} | ||
function c(t) { | ||
if (!t[r]) throw new RangeError("getInternalAPI not applicable"); | ||
return t[r]; | ||
function h(t) { | ||
if (!t[e]) throw new RangeError("getInternalAPI not applicable"); | ||
return t[e]; | ||
} | ||
function h(t) { | ||
function l(t) { | ||
let r = t.length; | ||
@@ -32,6 +40,5 @@ for (let e = t.length - 1; e >= 0; e--) { | ||
} | ||
function l(t) { | ||
function u(t) { | ||
return 0 === t || 1 === t || 2 === t || 3 === t; | ||
} | ||
let u; | ||
function f(t, r, e) { | ||
@@ -64,9 +71,2 @@ const n = e.length; | ||
} | ||
!function(t) { | ||
t[t.UNDEFINED = 0] = "UNDEFINED", t[t.NULL = 1] = "NULL", t[t.NUMBER = 2] = "NUMBER", | ||
t[t.BIGINT_POSITIVE = 3] = "BIGINT_POSITIVE", t[t.BIGINT_NEGATIVE = 4] = "BIGINT_NEGATIVE", | ||
t[t.STRING = 5] = "STRING", t[t.BOOLEAN = 6] = "BOOLEAN", t[t.OBJECT = 7] = "OBJECT", | ||
t[t.OBJECT_PROP = 8] = "OBJECT_PROP", t[t.ARRAY = 9] = "ARRAY", t[t.ARRAY_ITEM = 10] = "ARRAY_ITEM", | ||
t[t.MAP = 11] = "MAP", t[t.SET = 12] = "SET", t[t.DATE = 13] = "DATE"; | ||
}(u || (u = {})), u.NUMBER, u.BIGINT_POSITIVE, u.BIGINT_NEGATIVE, u.STRING; | ||
const y = Float64Array; | ||
@@ -79,6 +79,6 @@ function E(t, r, e, n) { | ||
} | ||
function T(t, r, e, n) { | ||
function U(t, r, e, n) { | ||
t.Float64Array[(r + 0) / 8] = e, t.BigUint64Array[(r + 8) / 8] = n; | ||
} | ||
function U(t, r, e, n, i, o) { | ||
function T(t, r, e, n, i, o) { | ||
t.Float64Array[(r + 0) / 8] = e, t.Uint32Array[(r + 8) / 4] = n, t.Uint32Array[(r + 12) / 4] = i, | ||
@@ -109,12 +109,12 @@ t.Float64Array[(r + 16) / 8] = o; | ||
} | ||
function N(t, r) { | ||
function M(t, r) { | ||
return t.Uint32Array[(r + 12) / 4]; | ||
} | ||
function M(t, r, e, n, i) { | ||
function N(t, r, e, n, i) { | ||
t.Float64Array[(r + 0) / 8] = e, t.Uint32Array[(r + 8) / 4] = n, t.Uint32Array[(r + 12) / 4] = i; | ||
} | ||
function I(t, r) { | ||
function B(t, r) { | ||
return t.Float64Array[(r + 0) / 8]; | ||
} | ||
function B(t, r) { | ||
function I(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
@@ -155,15 +155,21 @@ } | ||
} | ||
function G(t, r) { | ||
function D(t, r) { | ||
return t.Uint8Array[(r + 13) / 1]; | ||
} | ||
function D(t, r) { | ||
function G(t, r, e) { | ||
return t.Uint8Array[(r + 13) / 1] = e; | ||
} | ||
function j(t, r) { | ||
return t.Uint32Array[(r + 4) / 4]; | ||
} | ||
function j(t, r) { | ||
function W(t, r, e) { | ||
return t.Uint32Array[(r + 4) / 4] = e; | ||
} | ||
function V(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
} | ||
function W(t, r) { | ||
function J(t, r) { | ||
return t.Uint32Array[(r + 12) / 4]; | ||
} | ||
function V(t, r, e, n) { | ||
function q(t, r, e, n) { | ||
let i = 0; | ||
@@ -173,3 +179,3 @@ for (let r = 0; r < n; r++) i = Math.imul(31, i) + t[r + e] | 0; | ||
} | ||
function J(t, r, e) { | ||
function H(t, r, e) { | ||
let n = e; | ||
@@ -179,3 +185,3 @@ return 0 === e ? (n = x(t, r), 0 === L(t, n) ? 0 : n) : 0 === L(t, n) ? 0 : (n = k(t, n), | ||
} | ||
function q(t, r = 10) { | ||
function $(t, r = 10) { | ||
const {heap: e, allocator: n} = t, i = n.calloc(14), o = n.calloc(r * Uint32Array.BYTES_PER_ELEMENT), a = function(t) { | ||
@@ -192,18 +198,16 @@ const {allocator: r, heap: e} = t, n = r.calloc(8), i = r.calloc(8); | ||
} | ||
function H(t, r, e, n) { | ||
const {heap: i, allocator: o} = r, a = o.calloc(16); | ||
let s, c, l; | ||
"number" == typeof n ? (s = o.calloc(16), E(r.heap, s, u.NUMBER, n), c = s + 8, | ||
l = y.BYTES_PER_ELEMENT) : (s = o.calloc(16), l = h(n), c = o.calloc(l), f(r.heap.Uint8Array, c, n), | ||
M(r.heap, s, u.STRING, l, c)); | ||
const p = V(i.Uint8Array, z(i, e), c, l), A = O(i, e) + p * Uint32Array.BYTES_PER_ELEMENT; | ||
let T = A, U = i.Uint32Array[T / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== U && !dt(r.heap, j(i, U), s); ) T = U + 4, U = D(i, U); | ||
return T === A && function(t, r, e) { | ||
t.Uint8Array[(r + 13) / 1] = e; | ||
}(i, e, G(i, e) + 1), 0 !== U ? (I(r.heap, s) === u.STRING && o.free(N(r.heap, s)), | ||
o.free(s), o.free(a), U + 0) : (U = a, function(t, r, e, n, i, o) { | ||
function K(t, e, n, i) { | ||
const {heap: o, allocator: a} = e, s = a.calloc(16); | ||
let c, h, u; | ||
"number" == typeof i ? (c = a.calloc(16), E(e.heap, c, r.NUMBER, i), h = c + 8, | ||
u = y.BYTES_PER_ELEMENT) : (c = a.calloc(16), u = l(i), h = a.calloc(u), f(e.heap.Uint8Array, h, i), | ||
N(e.heap, c, r.STRING, u, h)); | ||
const p = q(o.Uint8Array, z(o, n), h, u), A = O(o, n) + p * Uint32Array.BYTES_PER_ELEMENT; | ||
let U = A, T = o.Uint32Array[U / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== T && !Pt(e.heap, V(o, T), c); ) U = T + 4, T = j(o, T); | ||
return U === A && G(o, n, D(o, n) + 1), 0 !== T ? (B(e.heap, c) === r.STRING && a.free(M(e.heap, c)), | ||
a.free(c), a.free(s), T + 0) : (T = s, function(t, r, e, n, i, o) { | ||
t.Uint32Array[(r + 0) / 4] = e, t.Uint32Array[(r + 4) / 4] = n, t.Uint32Array[(r + 8) / 4] = i, | ||
t.Uint32Array[(r + 12) / 4] = o; | ||
}(i, U, 0, 0, s, function(t, r, e) { | ||
}(o, T, 0, 0, c, function(t, r, e) { | ||
const {allocator: n, heap: i} = t, o = n.calloc(8); | ||
@@ -215,4 +219,4 @@ F(i, o, 0, 0); | ||
}(i, r, o), F(i, a, o, e), a; | ||
}(r, Y(i, e), a)), i.Uint32Array[T / Uint32Array.BYTES_PER_ELEMENT] = a, v(i, e, C(i, e) + 1), | ||
d = z(i, e), g = G(i, e), P = t.hashMapLoadFactor, g / d > P && function(t, r, e) { | ||
}(e, Y(o, n), s)), o.Uint32Array[U / Uint32Array.BYTES_PER_ELEMENT] = s, v(o, n, C(o, n) + 1), | ||
d = z(o, n), g = D(o, n), P = t.hashMapLoadFactor, g / d > P && function(t, r, e) { | ||
const {heap: n, allocator: i} = t; | ||
@@ -225,9 +229,9 @@ i.free(O(n, r)); | ||
t.Uint8Array[(r + 12) / 1] = e; | ||
}(n, r, e); | ||
}(n, r, e), G(n, r, 0); | ||
let a = 0; | ||
for (;0 !== (a = Q(n, r, a)); ) rt(n, o, e, a); | ||
}(r, e, 2 * z(i, e)), U + 0); | ||
for (;0 !== (a = Z(n, r, a)); ) nt(n, r, a); | ||
}(e, n, 2 * z(o, n)), T + 0); | ||
var d, g, P; | ||
} | ||
function $(t, r, e) { | ||
function Q(t, r, e) { | ||
const n = function(t, r) { | ||
@@ -237,25 +241,25 @@ const e = new ArrayBuffer("string" == typeof r ? 3 * r.length : 8), n = new Uint8Array(e); | ||
return "string" == typeof r ? i = f(new Uint8Array(e), 0, r) : new Float64Array(e)[0] = r, | ||
V(n, t, 0, i); | ||
q(n, t, 0, i); | ||
}(z(t, r), e), i = O(t, r) + n * Uint32Array.BYTES_PER_ELEMENT; | ||
let o = i, a = t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]; | ||
for (;0 !== a; ) { | ||
if (gt(t, j(t, a)) === e) return o; | ||
o = a + 4, a = D(t, a); | ||
if (mt(t, V(t, a)) === e) return o; | ||
o = a + 4, a = j(t, a); | ||
} | ||
return 0; | ||
} | ||
function K(t, r, e) { | ||
const {heap: n, allocator: i} = t, o = $(n, r, e); | ||
if (0 === o) return 0; | ||
const a = n.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT], s = a + 0; | ||
function X(t, e, n) { | ||
const {heap: i, allocator: o} = t, a = Q(i, e, n); | ||
if (0 === a) return 0; | ||
const s = i.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT], c = s + 0; | ||
return function({heap: t, allocator: r}, e) { | ||
const n = k(t, e); | ||
F(t, e, k(t, n), L(t, n)), r.free(n); | ||
}(t, W(n, a)), n.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = D(n, a), I(n, j(n, a)) === u.STRING && i.free(N(n, j(n, a))), | ||
i.free(j(n, a)), i.free(a), v(n, r, C(n, r) - 1), s; | ||
}(t, J(i, s)), i.Uint32Array[a / Uint32Array.BYTES_PER_ELEMENT] = j(i, s), B(i, V(i, s)) === r.STRING && o.free(M(i, V(i, s))), | ||
o.free(V(i, s)), o.free(s), v(i, e, C(i, e) - 1), c; | ||
} | ||
function Q(t, r, e) { | ||
function Z(t, r, e) { | ||
let n = 0; | ||
0 !== e && (n = W(t, e)); | ||
const i = J(t, Y(t, r), n); | ||
0 !== e && (n = J(t, e)); | ||
const i = H(t, Y(t, r), n); | ||
return 0 === i ? 0 : function(t, r) { | ||
@@ -265,16 +269,16 @@ return L(t, r); | ||
} | ||
function X(t, r) { | ||
function tt(t, r) { | ||
return { | ||
valuePointer: r + 0, | ||
keyPointer: j(t, r) | ||
keyPointer: V(t, r) | ||
}; | ||
} | ||
function Z(t, r) { | ||
function rt(t, r) { | ||
return C(t, r); | ||
} | ||
function tt(t, r) { | ||
const e = [ r, O(t, r) ], n = [], i = function(t, r) { | ||
function et(t, e) { | ||
const n = [ e, O(t, e) ], i = [], o = function(t, r) { | ||
const e = [ r ], n = [], i = x(t, r); | ||
i === w(t, r) && e.push(i); | ||
let o = J(t, r, 0); | ||
let o = H(t, r, 0); | ||
for (;0 !== o; ) e.push(o), 0 !== L(t, o) && n.push(L(t, o)), o = k(t, o); | ||
@@ -285,29 +289,28 @@ return { | ||
}; | ||
}(t, Y(t, r)); | ||
e.push(...i.pointers); | ||
for (const r of i.valuePointers) n.push(r + 0), I(t, j(t, r)) === u.STRING && e.push(N(t, j(t, r))), | ||
e.push(r, j(t, r)); | ||
}(t, Y(t, e)); | ||
n.push(...o.pointers); | ||
for (const e of o.valuePointers) i.push(e + 0), B(t, V(t, e)) === r.STRING && n.push(M(t, V(t, e))), | ||
n.push(e, V(t, e)); | ||
return { | ||
pointers: e, | ||
pointersToValuePointers: n | ||
pointers: n, | ||
pointersToValuePointers: i | ||
}; | ||
} | ||
function rt(t, r, e, n) { | ||
const i = r + V(t.Uint8Array, e, function(t, r) { | ||
return I(t, r) === u.NUMBER ? r + 8 : N(t, r); | ||
}(t, n), function(t, r) { | ||
return I(t, r) === u.NUMBER ? y.BYTES_PER_ELEMENT : b(t, r); | ||
}(t, n)) % e * Uint32Array.BYTES_PER_ELEMENT, o = t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]; | ||
t.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = n, function(t, r, e) { | ||
t.Uint32Array[(r + 4) / 4] = e; | ||
}(t, n, o); | ||
function nt(t, e, n) { | ||
const i = q(t.Uint8Array, z(t, e), function(t, e) { | ||
return B(t, e) === r.NUMBER ? e + 8 : M(t, e); | ||
}(t, V(t, n)), function(t, e) { | ||
return B(t, e) === r.NUMBER ? y.BYTES_PER_ELEMENT : b(t, e); | ||
}(t, V(t, n))), o = O(t, e) + i * Uint32Array.BYTES_PER_ELEMENT, a = t.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT]; | ||
t.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = n, 0 !== a ? W(t, n, a) : (W(t, n, 0), | ||
G(t, e, D(t, e) + 1)); | ||
} | ||
function* et(t, r) { | ||
function* it(t, r) { | ||
let e = 0; | ||
for (;0 !== (e = Q(t, r, e)); ) yield e; | ||
for (;0 !== (e = Z(t, r, e)); ) yield e; | ||
} | ||
function nt(t, r, e) { | ||
function ot(t, r, e) { | ||
const n = new Set, i = new Set, o = [ e ]; | ||
let a = void 0; | ||
for (;void 0 !== (a = o.shift()); ) 0 !== a && it(t, r, a, n, i, o); | ||
for (;void 0 !== (a = o.shift()); ) 0 !== a && at(t, r, a, n, i, o); | ||
return { | ||
@@ -318,49 +321,45 @@ leafAddresses: n, | ||
} | ||
function it(t, r, e, n, i, o) { | ||
if (l(e) || n.has(e) || i.has(e)) return; | ||
const a = I(t, e), s = B(t, e); | ||
switch (a) { | ||
case u.NUMBER: | ||
case u.BIGINT_NEGATIVE: | ||
case u.BIGINT_POSITIVE: | ||
n.add(e); | ||
function at(t, e, n, i, o, a) { | ||
if (u(n) || i.has(n) || o.has(n)) return; | ||
const s = B(t, n), c = I(t, n); | ||
switch (s) { | ||
case r.NUMBER: | ||
case r.BIGINT_NEGATIVE: | ||
case r.BIGINT_POSITIVE: | ||
i.add(n); | ||
break; | ||
case u.STRING: | ||
n.add(N(t, e)), n.add(e); | ||
case r.STRING: | ||
i.add(M(t, n)), i.add(n); | ||
break; | ||
case u.OBJECT: | ||
case u.MAP: | ||
case u.SET: | ||
s <= 1 || r ? (n.add(e), function(t, r, e, n) { | ||
const {pointersToValuePointers: i, pointers: o} = tt(t, r); | ||
case r.OBJECT: | ||
case r.MAP: | ||
case r.SET: | ||
c <= 1 || e ? (i.add(n), function(t, r, e, n) { | ||
const {pointersToValuePointers: i, pointers: o} = et(t, r); | ||
for (const t of o) e.add(t); | ||
for (const r of i) n.push(t.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
}(t, _(t, e), n, o)) : i.add(e); | ||
}(t, _(t, n), i, a)) : o.add(n); | ||
break; | ||
case u.ARRAY: | ||
if (s <= 1 || r) { | ||
n.add(e), n.add(d(t, e)); | ||
const r = g(t, e); | ||
for (let n = 0; n < r; n += 1) { | ||
const r = t.Uint32Array[(d(t, e) + n * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT]; | ||
o.push(r); | ||
case r.ARRAY: | ||
if (c <= 1 || e) { | ||
i.add(n), i.add(d(t, n)); | ||
const r = g(t, n); | ||
for (let e = 0; e < r; e += 1) { | ||
const r = t.Uint32Array[(d(t, n) + e * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT]; | ||
a.push(r); | ||
} | ||
} else i.add(e); | ||
} else o.add(n); | ||
break; | ||
case u.DATE: | ||
s <= 1 || r ? n.add(e) : i.add(e); | ||
break; | ||
default: | ||
throw new Error(u[a] + " Not implemented yet"); | ||
case r.DATE: | ||
c <= 1 || e ? i.add(n) : o.add(n); | ||
} | ||
} | ||
const ot = Math.clz32, at = String.fromCharCode; | ||
function st(t) { | ||
const st = Math.clz32, ct = String.fromCharCode; | ||
function ht(t) { | ||
let r = t.charCodeAt(0) << 24; | ||
const e = 0 | ot(~r); | ||
const e = 0 | st(~r); | ||
let n = 0; | ||
@@ -371,3 +370,3 @@ const i = 0 | t.length; | ||
for (r = r << e >>> 24 + e, n = 1; n < e; n = n + 1 | 0) r = r << 6 | 63 & t.charCodeAt(n); | ||
r <= 65535 ? o += at(r) : r <= 1114111 ? (r = r - 65536 | 0, o += at(55296 + (r >> 10) | 0, 56320 + (1023 & r) | 0)) : n = 0; | ||
r <= 65535 ? o += ct(r) : r <= 1114111 ? (r = r - 65536 | 0, o += ct(55296 + (r >> 10) | 0, 56320 + (1023 & r) | 0)) : n = 0; | ||
} | ||
@@ -377,73 +376,73 @@ for (;n < i; n = n + 1 | 0) o += "�"; | ||
} | ||
function ct(t, r) { | ||
function lt(t, r) { | ||
return function(t, r, e) { | ||
const n = t.subarray(r, r + e); | ||
let i = ""; | ||
for (let t = 0, r = 0 | n.length; t < r; t = t + 32768 | 0) i += at.apply(0, n.subarray(t, t + 32768 | 0)); | ||
return i.replace(/[\xc0-\xff][\x80-\xbf]*/g, st); | ||
}(t.Uint8Array, N(t, r), b(t, r)); | ||
for (let t = 0, r = 0 | n.length; t < r; t = t + 32768 | 0) i += ct.apply(0, n.subarray(t, t + 32768 | 0)); | ||
return i.replace(/[\xc0-\xff][\x80-\xbf]*/g, ht); | ||
}(t.Uint8Array, M(t, r), b(t, r)); | ||
} | ||
function ht(t, r, e, n, i) { | ||
const o = i.length, a = r.allocator.calloc(24), s = o + t > 0 ? r.allocator.calloc((o + t) * Uint32Array.BYTES_PER_ELEMENT) : 0; | ||
m(r.heap, a, u.ARRAY, 1, s, o, o + t); | ||
for (let t = 0; t < o; t += 1) e.push(i[t]), n.push(s + t * Uint32Array.BYTES_PER_ELEMENT); | ||
return a; | ||
function ut(t, e, n, i, o) { | ||
const a = o.length, s = e.allocator.calloc(24), c = a + t > 0 ? e.allocator.calloc((a + t) * Uint32Array.BYTES_PER_ELEMENT) : 0; | ||
m(e.heap, s, r.ARRAY, 1, c, a, a + t); | ||
for (let t = 0; t < a; t += 1) n.push(o[t]), i.push(c + t * Uint32Array.BYTES_PER_ELEMENT); | ||
return s; | ||
} | ||
function lt(t, r, e, n, i) { | ||
const o = r.allocator.malloc(16), a = Object.entries(i), s = a.length, c = q(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * s))); | ||
for (let i = 0; i < s; i += 1) { | ||
const o = H(t, r, c, a[i][0]); | ||
e.push(a[i][1]), n.push(o); | ||
function ft(t, e, n, i, o) { | ||
const a = e.allocator.malloc(16), s = Object.entries(o), c = s.length, h = $(e, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * c))); | ||
for (let r = 0; r < c; r += 1) { | ||
const o = K(t, e, h, s[r][0]); | ||
n.push(s[r][1]), i.push(o); | ||
} | ||
return S(r.heap, o, u.OBJECT, 1, c), o; | ||
return S(e.heap, a, r.OBJECT, 1, h), a; | ||
} | ||
function ut(t, r, e, n, i) { | ||
const o = r.allocator.malloc(16), a = q(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * i.size))); | ||
for (const [o, s] of i) { | ||
const i = H(t, r, a, o); | ||
e.push(s), n.push(i); | ||
function pt(t, e, n, i, o) { | ||
const a = e.allocator.malloc(16), s = $(e, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * o.size))); | ||
for (const [r, a] of o) { | ||
const o = K(t, e, s, r); | ||
n.push(a), i.push(o); | ||
} | ||
return S(r.heap, o, u.MAP, 1, a), o; | ||
return S(e.heap, a, r.MAP, 1, s), a; | ||
} | ||
function ft(t, r, e) { | ||
const n = r.allocator.malloc(16), i = q(r, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * e.size))); | ||
for (const n of e) H(t, r, i, n); | ||
return S(r.heap, n, u.SET, 1, i), n; | ||
function yt(t, e, n) { | ||
const i = e.allocator.malloc(16), o = $(e, Math.max(t.hashMapMinInitialCapacity, Math.ceil(1.3 * n.size))); | ||
for (const r of n) K(t, e, o, r); | ||
return S(e.heap, i, r.SET, 1, o), i; | ||
} | ||
function pt(t, r, e, n, i) { | ||
const s = [ i ], c = [ n ], {heap: {Uint32Array: l}, allocator: p, heap: y} = r; | ||
for (;0 !== s.length; ) { | ||
const n = s.pop(), i = c.pop(); | ||
if (void 0 === n) { | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
function Et(t, e, n, i, o) { | ||
const c = [ o ], h = [ i ], {heap: {Uint32Array: u}, allocator: p, heap: y} = e; | ||
for (;0 !== c.length; ) { | ||
const i = c.pop(), o = h.pop(); | ||
if (void 0 === i) { | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
if (null === n) { | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = 1; | ||
if (null === i) { | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = 1; | ||
continue; | ||
} | ||
if (!0 === n) { | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = 2; | ||
if (!0 === i) { | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = 2; | ||
continue; | ||
} | ||
if (!1 === n) { | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = 3; | ||
if (!1 === i) { | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = 3; | ||
continue; | ||
} | ||
switch (typeof n) { | ||
switch (typeof i) { | ||
case "number": | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), E(y, l[i / Uint32Array.BYTES_PER_ELEMENT], u.NUMBER, n); | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), E(y, u[o / Uint32Array.BYTES_PER_ELEMENT], r.NUMBER, i); | ||
continue; | ||
case "string": | ||
const t = h(n), r = p.calloc(t); | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), f(y.Uint8Array, r, n), M(y, l[i / Uint32Array.BYTES_PER_ELEMENT], u.STRING, t, r); | ||
const t = l(i), e = p.calloc(t); | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), f(y.Uint8Array, e, i), N(y, u[o / Uint32Array.BYTES_PER_ELEMENT], r.STRING, t, e); | ||
continue; | ||
case "bigint": | ||
if (n > o || n < -o) { | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
if (i > a || i < -a) { | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), T(y, l[i / Uint32Array.BYTES_PER_ELEMENT], n > 0 ? u.BIGINT_POSITIVE : u.BIGINT_NEGATIVE, n * (n > 0 ? BigInt("1") : BigInt("-1"))); | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(16), U(y, u[o / Uint32Array.BYTES_PER_ELEMENT], i > 0 ? r.BIGINT_POSITIVE : r.BIGINT_NEGATIVE, i * (i > 0 ? BigInt("1") : BigInt("-1"))); | ||
continue; | ||
@@ -453,58 +452,58 @@ | ||
case "symbol": | ||
l[i / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
u[o / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
continue; | ||
} | ||
const A = a(n, r.allocator); | ||
A ? (e.push(A), y.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = A) : Array.isArray(n) ? y.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = ht(t.arrayAdditionalAllocation, r, s, c, n) : n instanceof Date ? (y.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(24), | ||
U(y, y.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT], u.DATE, 1, 0, n.getTime())) : n instanceof Map ? y.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = ut(t, r, s, c, n) : n instanceof Set ? y.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = ft(t, r, n) : y.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT] = lt(t, r, s, c, n); | ||
const A = s(i, e.allocator); | ||
A ? (n.push(A), y.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = A) : Array.isArray(i) ? y.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = ut(t.arrayAdditionalAllocation, e, c, h, i) : i instanceof Date ? (y.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = p.calloc(24), | ||
T(y, y.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT], r.DATE, 1, 0, i.getTime())) : i instanceof Map ? y.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = pt(t, e, c, h, i) : i instanceof Set ? y.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = yt(t, e, i) : y.Uint32Array[o / Uint32Array.BYTES_PER_ELEMENT] = ft(t, e, c, h, i); | ||
} | ||
} | ||
function yt(t, r, e, n) { | ||
function At(t, r, e, n) { | ||
const i = []; | ||
return pt(t, r, i, e, n), i; | ||
return Et(t, r, i, e, n), i; | ||
} | ||
function Et(t, r, e, n) { | ||
const i = r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], o = yt(t, r, e, n); | ||
if (o.length > 0) for (const t of o) Tt(r.heap, t); | ||
At(r, i); | ||
function Ut(t, r, e, n) { | ||
const i = r.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], o = At(t, r, e, n); | ||
if (o.length > 0) for (const t of o) dt(r.heap, t); | ||
Tt(r, i); | ||
} | ||
function At(t, r) { | ||
const {heap: e, allocator: n} = t; | ||
if (l(r)) return; | ||
const i = I(e, r); | ||
if ((o = i) !== u.OBJECT && o !== u.ARRAY && o !== u.DATE && o !== u.MAP && o !== u.SET) return i === u.STRING && n.free(N(t.heap, r)), | ||
void n.free(r); | ||
var o; | ||
if (Ut(e, r) > 0) return void n.free(r); | ||
const {leafAddresses: a, arcAddresses: s} = nt(t.heap, !1, r); | ||
for (const t of a) n.free(t); | ||
for (const t of s) Ut(e, t); | ||
function Tt(t, e) { | ||
const {heap: n, allocator: i} = t; | ||
if (u(e)) return; | ||
const o = B(n, e); | ||
if ((a = o) !== r.OBJECT && a !== r.ARRAY && a !== r.DATE && a !== r.MAP && a !== r.SET) return o === r.STRING && i.free(M(t.heap, e)), | ||
void i.free(e); | ||
var a; | ||
if (gt(n, e) > 0) return void i.free(e); | ||
const {leafAddresses: s, arcAddresses: c} = ot(t.heap, !1, e); | ||
for (const t of s) i.free(t); | ||
for (const t of c) gt(n, t); | ||
} | ||
function Tt(t, r) { | ||
return R(t, r, B(t, r) + 1), B(t, r); | ||
function dt(t, r) { | ||
return R(t, r, I(t, r) + 1), I(t, r); | ||
} | ||
function Ut(t, r) { | ||
return R(t, r, B(t, r) - 1), B(t, r); | ||
function gt(t, r) { | ||
return R(t, r, I(t, r) - 1), I(t, r); | ||
} | ||
function dt(t, r, e) { | ||
I(t, r); | ||
const n = I(t, r); | ||
if (n !== I(t, e)) return !1; | ||
if (n === u.STRING) { | ||
const n = b(t, r); | ||
return n === b(t, e) && function(t, r, e, n) { | ||
function Pt(t, e, n) { | ||
B(t, e); | ||
const i = B(t, e); | ||
if (i !== B(t, n)) return !1; | ||
if (i === r.STRING) { | ||
const r = b(t, e); | ||
return r === b(t, n) && function(t, r, e, n) { | ||
if (t.byteLength < r + n || t.byteLength < e + n) return !1; | ||
for (let i = 0; i <= n - i; i += 1) if (t[r + i] !== t[e + i]) return !1; | ||
return !0; | ||
}(t.Uint8Array, N(t, r), N(t, e), n); | ||
}(t.Uint8Array, M(t, e), M(t, n), r); | ||
} | ||
return p(t, r) === p(t, e); | ||
return p(t, e) === p(t, n); | ||
} | ||
function gt(t, r) { | ||
return I(t, r) === u.NUMBER ? p(t, r) : ct(t, r); | ||
function mt(t, e) { | ||
return B(t, e) === r.NUMBER ? p(t, e) : lt(t, e); | ||
} | ||
function Pt(t) { | ||
function _t(t) { | ||
if (null == t) throw new Error("assertNonNull"); | ||
} | ||
function mt(t, r, e) { | ||
function St(t, r, e) { | ||
if (e >= g(t.heap, r)) return; | ||
@@ -517,32 +516,32 @@ const n = d(t.heap, r) + e * Uint32Array.BYTES_PER_ELEMENT; | ||
} | ||
function _t(t, r, e, n) { | ||
const i = mt(r, e, n); | ||
if (void 0 !== i) return Ot(t, r, i.pointer); | ||
function bt(t, r, e, n) { | ||
const i = St(r, e, n); | ||
if (void 0 !== i) return Ct(t, r, i.pointer); | ||
} | ||
function St(t, r, e, n) { | ||
const i = mt(t, r, e); | ||
Pt(i), t.heap.Uint32Array[i.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
function Mt(t, r, e, n) { | ||
const i = St(t, r, e); | ||
_t(i), t.heap.Uint32Array[i.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
} | ||
function bt(t, r, e, n) { | ||
var i, o; | ||
n > g(r.heap, e) && (n > (i = r.heap, o = e, i.Uint32Array[(o + 20) / 4]) ? function(t, r, e, n) { | ||
const i = d(t.heap, r), o = 0 !== i ? t.allocator.realloc(i, e * Uint32Array.BYTES_PER_ELEMENT) : t.allocator.calloc(e * Uint32Array.BYTES_PER_ELEMENT); | ||
m(t.heap, r, u.ARRAY, function(t, r) { | ||
function Nt(t, e, n, i) { | ||
var o, a; | ||
i > g(e.heap, n) && (i > (o = e.heap, a = n, o.Uint32Array[(a + 20) / 4]) ? function(t, e, n, i) { | ||
const o = d(t.heap, e), a = 0 !== o ? t.allocator.realloc(o, n * Uint32Array.BYTES_PER_ELEMENT) : t.allocator.calloc(n * Uint32Array.BYTES_PER_ELEMENT); | ||
m(t.heap, e, r.ARRAY, function(t, r) { | ||
return t.Uint32Array[(r + 8) / 4]; | ||
}(t.heap, r), o, n, e); | ||
}(r, e, n + t.arrayAdditionalAllocation, n) : P(r.heap, e, n)); | ||
}(t.heap, e), a, i, n); | ||
}(e, n, i + t.arrayAdditionalAllocation, i) : P(e.heap, n, i)); | ||
} | ||
function Nt(t, r, e, n = Mt) { | ||
const i = d(r.heap, e), o = [ ...new Array(g(r.heap, e)).keys() ].map(t => i + t * Uint32Array.BYTES_PER_ELEMENT).map(t => r.heap.Uint32Array[t / Uint32Array.BYTES_PER_ELEMENT]).map(e => [ e, Ot(t, r, e) ]); | ||
function Bt(t, r, e, n = It) { | ||
const i = d(r.heap, e), o = [ ...new Array(g(r.heap, e)).keys() ].map(t => i + t * Uint32Array.BYTES_PER_ELEMENT).map(t => r.heap.Uint32Array[t / Uint32Array.BYTES_PER_ELEMENT]).map(e => [ e, Ct(t, r, e) ]); | ||
o.sort((t, r) => n(t[1], r[1])); | ||
for (let t = 0; t < o.length; t += 1) r.heap.Uint32Array[(i + t * Uint32Array.BYTES_PER_ELEMENT) / Uint32Array.BYTES_PER_ELEMENT] = o[t][0]; | ||
} | ||
function Mt(t, r) { | ||
function It(t, r) { | ||
if (void 0 === t && void 0 === r) return 0; | ||
if (void 0 === t) return 1; | ||
if (void 0 === r) return -1; | ||
const e = It(t), n = It(r); | ||
const e = Rt(t), n = Rt(r); | ||
return e < n ? -1 : e > n ? 1 : 0; | ||
} | ||
function It(t) { | ||
function Rt(t) { | ||
if (null === t) return "null"; | ||
@@ -554,3 +553,3 @@ if ("boolean" == typeof t || "number" == typeof t) return t.toString(); | ||
} | ||
function Bt(t, r, e, n, i, ...o) { | ||
function wt(t, r, e, n, i, ...o) { | ||
const a = g(r.heap, e), s = function(t, r) { | ||
@@ -561,12 +560,12 @@ return r >= t ? t : r < 0 ? t + r : r; | ||
}(a, s, i), h = a + o.length - c; | ||
bt(t, r, e, h); | ||
Nt(t, r, e, h); | ||
const l = [], u = h - a; | ||
for (let n = s; n < s + c; n += 1) l.push(_t(t, r, e, n)), At(r, mt(r, e, n).pointer); | ||
for (let n = s; n < s + c; n += 1) l.push(bt(t, r, e, n)), Tt(r, St(r, e, n).pointer); | ||
if (u > 0) for (let t = h - 1; t >= s + u; t -= 1) { | ||
const n = mt(r, e, t - u); | ||
Pt(n), St(r, e, t, n.pointer), r.heap.Uint32Array[n.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
} else if (u < 0) for (let t = s + o.length; t < a + u; t += 1) St(r, e, t, mt(r, e, t - u).pointer); | ||
const n = St(r, e, t - u); | ||
_t(n), Mt(r, e, t, n.pointer), r.heap.Uint32Array[n.pointerToThePointer / Uint32Array.BYTES_PER_ELEMENT] = 0; | ||
} else if (u < 0) for (let t = s + o.length; t < a + u; t += 1) Mt(r, e, t, St(r, e, t - u).pointer); | ||
for (let n = 0; n < o.length; n += 1) { | ||
const i = mt(r, e, s + n); | ||
Pt(i), yt(t, r, i.pointerToThePointer, o[n]); | ||
const i = St(r, e, s + n); | ||
_t(i), At(t, r, i.pointerToThePointer, o[n]); | ||
} | ||
@@ -602,3 +601,3 @@ return h < a && function(t, r, e) { | ||
} | ||
function Rt(t, r) { | ||
function xt(t, r) { | ||
const e = [], n = r.malloc, i = r.calloc, o = r.realloc; | ||
@@ -631,6 +630,6 @@ let a = !1; | ||
constructor(t, r, e) { | ||
this.externalArgs = t, this.carrier = r, this._entryPointer = e, Tt(this.carrier.heap, this.entryPointer); | ||
this.externalArgs = t, this.carrier = r, this._entryPointer = e, dt(this.carrier.heap, this.entryPointer); | ||
} | ||
destroy() { | ||
const t = Ut(this.carrier.heap, this.entryPointer); | ||
const t = gt(this.carrier.heap, this.entryPointer); | ||
return this._entryPointer = 0, t; | ||
@@ -656,11 +655,11 @@ } | ||
class ArrayWrapper extends BaseProxyTrap { | ||
get(t, e) { | ||
if (e === r) return this; | ||
if (e in this && "constructor" !== e) return this[e]; | ||
if ("length" === e) return g(this.carrier.heap, this.entryPointer); | ||
if ("string" == typeof e || "number" == typeof e) { | ||
const t = "string" == typeof e ? Number.parseInt(e, 10) : e; | ||
if (Number.isSafeInteger(t)) return _t(this.externalArgs, this.carrier, this.entryPointer, t); | ||
get(t, r) { | ||
if (r === e) return this; | ||
if (r in this && "constructor" !== r) return this[r]; | ||
if ("length" === r) return g(this.carrier.heap, this.entryPointer); | ||
if ("string" == typeof r || "number" == typeof r) { | ||
const t = "string" == typeof r ? Number.parseInt(r, 10) : r; | ||
if (Number.isSafeInteger(t)) return bt(this.externalArgs, this.carrier, this.entryPointer, t); | ||
} | ||
return t[e]; | ||
return t[r]; | ||
} | ||
@@ -688,7 +687,7 @@ deleteProperty(t, r) { | ||
} | ||
has(t, e) { | ||
if (e === r) return !0; | ||
has(t, r) { | ||
if (r === e) return !0; | ||
const n = g(this.carrier.heap, this.entryPointer); | ||
if ("number" == typeof e) return n - 1 >= e; | ||
if ("string" == typeof e) return n - 1 >= Number.parseInt(e, 10); | ||
if ("number" == typeof r) return n - 1 >= r; | ||
if ("string" == typeof r) return n - 1 >= Number.parseInt(r, 10); | ||
throw new Error("unsupported"); | ||
@@ -701,5 +700,5 @@ } | ||
const t = g(this.carrier.heap, this.entryPointer); | ||
return t === e || Rt(() => { | ||
return t === e || xt(() => { | ||
if (t > e) return this.splice(e, t - e), !0; | ||
bt(this.externalArgs, this.carrier, this.entryPointer, e); | ||
Nt(this.externalArgs, this.carrier, this.entryPointer, e); | ||
}, this.carrier.allocator), !0; | ||
@@ -709,5 +708,5 @@ } | ||
if (!Number.isSafeInteger(n) || n < 0) throw new IllegalArrayIndexError; | ||
return Rt(() => { | ||
bt(this.externalArgs, this.carrier, this.entryPointer, n + 1), function(t, r, e, n, i) { | ||
Et(t, r, mt(r, e, n).pointerToThePointer, i); | ||
return xt(() => { | ||
Nt(this.externalArgs, this.carrier, this.entryPointer, n + 1), function(t, r, e, n, i) { | ||
Ut(t, r, St(r, e, n).pointerToThePointer, i); | ||
}(this.externalArgs, this.carrier, this.entryPointer, n, e); | ||
@@ -719,3 +718,3 @@ }, this.carrier.allocator), !0; | ||
do { | ||
yield [ t, _t(this.externalArgs, this.carrier, this.entryPointer, t) ], t += 1, | ||
yield [ t, bt(this.externalArgs, this.carrier, this.entryPointer, t) ], t += 1, | ||
r = g(this.carrier.heap, this.entryPointer); | ||
@@ -733,3 +732,3 @@ } while (t < r); | ||
do { | ||
yield _t(this.externalArgs, this.carrier, this.entryPointer, t), t += 1, r = g(this.carrier.heap, this.entryPointer); | ||
yield bt(this.externalArgs, this.carrier, this.entryPointer, t), t += 1, r = g(this.carrier.heap, this.entryPointer); | ||
} while (t < r); | ||
@@ -741,6 +740,6 @@ } | ||
sort(t) { | ||
Nt(this.externalArgs, this.carrier, this.entryPointer, t); | ||
Bt(this.externalArgs, this.carrier, this.entryPointer, t); | ||
} | ||
splice(t, r, ...e) { | ||
return Rt(() => Bt(this.externalArgs, this.carrier, this.entryPointer, t, r, ...e), this.carrier.allocator); | ||
return xt(() => wt(this.externalArgs, this.carrier, this.entryPointer, t, r, ...e), this.carrier.allocator); | ||
} | ||
@@ -750,4 +749,4 @@ reverse() { | ||
for (let e = 0; e < Math.floor(g(t.heap, r) / 2); e += 1) { | ||
const n = g(t.heap, r) - e - 1, i = mt(t, r, e); | ||
St(t, r, e, mt(t, r, n).pointer), St(t, r, n, i.pointer); | ||
const n = g(t.heap, r) - e - 1, i = St(t, r, e); | ||
Mt(t, r, e, St(t, r, n).pointer), Mt(t, r, n, i.pointer); | ||
} | ||
@@ -778,3 +777,3 @@ }(this.carrier, this.entryPointer), this; | ||
} | ||
const wt = [ "toString", "toDateString", "toTimeString", "toISOString", "toUTCString", "getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds", "getTime", "getTimezoneOffset", "getUTCDate", "getUTCDay", "getUTCFullYear", "getUTCHours", "getUTCMilliseconds", "getUTCMinutes", "getUTCMonth", "getUTCSeconds", "toJSON", "toLocaleString", "toLocaleDateString", "toLocaleTimeString" ], xt = [ "setDate", "setFullYear", "setHours", "setMilliseconds", "setMinutes", "setMonth", "setSeconds", "setTime", "getTimezoneOffset", "setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds" ]; | ||
const kt = [ "toString", "toDateString", "toTimeString", "toISOString", "toUTCString", "getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds", "getTime", "getTimezoneOffset", "getUTCDate", "getUTCDay", "getUTCFullYear", "getUTCHours", "getUTCMilliseconds", "getUTCMinutes", "getUTCMonth", "getUTCSeconds", "toJSON", "toLocaleString", "toLocaleDateString", "toLocaleTimeString" ], Lt = [ "setDate", "setFullYear", "setHours", "setMilliseconds", "setMinutes", "setMonth", "setSeconds", "setTime", "getTimezoneOffset", "setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds" ]; | ||
class DateWrapper extends BaseProxyTrap { | ||
@@ -784,9 +783,9 @@ constructor(t, r, e) { | ||
} | ||
get(t, e) { | ||
return e === r ? this : wt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = () => (this.updateDateObjectForReuse(), | ||
this.dateObjectForReuse[e]())), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : xt.includes(e) ? (e in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[e] = (...t) => { | ||
get(t, r) { | ||
return r === e ? this : kt.includes(r) ? (r in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[r] = () => (this.updateDateObjectForReuse(), | ||
this.dateObjectForReuse[r]())), this.useMeToGiveNamesToFunctionsAndCacheThem[r]) : Lt.includes(r) ? (r in this.useMeToGiveNamesToFunctionsAndCacheThem || (this.useMeToGiveNamesToFunctionsAndCacheThem[r] = (...t) => { | ||
this.updateDateObjectForReuse(); | ||
const r = this.dateObjectForReuse[e](...t); | ||
return this.persistDateObject(), r; | ||
}), this.useMeToGiveNamesToFunctionsAndCacheThem[e]) : t[e]; | ||
const e = this.dateObjectForReuse[r](...t); | ||
return this.persistDateObject(), e; | ||
}), this.useMeToGiveNamesToFunctionsAndCacheThem[r]) : t[r]; | ||
} | ||
@@ -798,5 +797,5 @@ updateDateObjectForReuse() { | ||
persistDateObject() { | ||
var t, r; | ||
U(this.carrier.heap, this.entryPointer, u.DATE, (t = this.carrier.heap, r = this.entryPointer, | ||
t.Uint32Array[(r + 8) / 4]), 0, this.dateObjectForReuse.getTime()); | ||
var t, e; | ||
T(this.carrier.heap, this.entryPointer, r.DATE, (t = this.carrier.heap, e = this.entryPointer, | ||
t.Uint32Array[(e + 8) / 4]), 0, this.dateObjectForReuse.getTime()); | ||
} | ||
@@ -873,11 +872,11 @@ defineProperty() { | ||
} | ||
const kt = new WeakMap; | ||
function Lt(t, r) { | ||
let e = kt.get(t); | ||
const Ft = new WeakMap; | ||
function Ot(t, r) { | ||
let e = Ft.get(t); | ||
return e || (e = "undefined" != typeof WeakRef ? new WeakValueMap(void 0, r) : new Map, | ||
kt.set(t, e)), e; | ||
Ft.set(t, e)), e; | ||
} | ||
class MapWrapper extends BaseProxyTrap { | ||
clear() { | ||
Gt(this.externalArgs, this.carrier, this.entryPointer); | ||
jt(this.externalArgs, this.carrier, this.entryPointer); | ||
} | ||
@@ -888,3 +887,3 @@ forEach(t, r) { | ||
get size() { | ||
return Z(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
return rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
} | ||
@@ -895,17 +894,17 @@ [Symbol.iterator]() { | ||
* entries() { | ||
for (const t of et(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r, keyPointer: e} = X(this.carrier.heap, t); | ||
yield [ Ot(this.externalArgs, this.carrier, e), Ot(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]) ]; | ||
for (const t of it(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r, keyPointer: e} = tt(this.carrier.heap, t); | ||
yield [ Ct(this.externalArgs, this.carrier, e), Ct(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]) ]; | ||
} | ||
} | ||
* keys() { | ||
for (const t of et(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = X(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of it(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = tt(this.carrier.heap, t); | ||
yield Ct(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
} | ||
* values() { | ||
for (const t of et(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r} = X(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
for (const t of it(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const {valuePointer: r} = tt(this.carrier.heap, t); | ||
yield Ct(this.externalArgs, this.carrier, this.carrier.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
@@ -916,3 +915,3 @@ } | ||
} | ||
get [r]() { | ||
get [e]() { | ||
return this; | ||
@@ -924,13 +923,13 @@ } | ||
get(t) { | ||
if ("string" == typeof t || "number" == typeof t) return zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
if ("string" == typeof t || "number" == typeof t) return Gt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
delete(t) { | ||
return ("string" == typeof t || "number" == typeof t) && Yt(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && vt(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
has(t) { | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== $(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== Q(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
set(t, r) { | ||
return "string" != typeof t && "number" != typeof t || Rt(() => { | ||
vt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, r); | ||
return "string" != typeof t && "number" != typeof t || xt(() => { | ||
Dt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, r); | ||
}, this.carrier.allocator), this; | ||
@@ -941,3 +940,3 @@ } | ||
clear() { | ||
Gt(this.externalArgs, this.carrier, this.entryPointer); | ||
jt(this.externalArgs, this.carrier, this.entryPointer); | ||
} | ||
@@ -948,3 +947,3 @@ forEach(t, r) { | ||
get size() { | ||
return Z(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
return rt(this.carrier.heap, _(this.carrier.heap, this.entryPointer)); | ||
} | ||
@@ -955,4 +954,4 @@ [Symbol.iterator]() { | ||
* entries() { | ||
for (const t of et(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = X(this.carrier.heap, t), e = Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of it(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = tt(this.carrier.heap, t), e = Ct(this.externalArgs, this.carrier, r.keyPointer); | ||
yield [ e, e ]; | ||
@@ -962,11 +961,11 @@ } | ||
* keys() { | ||
for (const t of et(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = X(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of it(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = tt(this.carrier.heap, t); | ||
yield Ct(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
} | ||
* values() { | ||
for (const t of et(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = X(this.carrier.heap, t); | ||
yield Ot(this.externalArgs, this.carrier, r.keyPointer); | ||
for (const t of it(this.carrier.heap, _(this.carrier.heap, this.entryPointer))) { | ||
const r = tt(this.carrier.heap, t); | ||
yield Ct(this.externalArgs, this.carrier, r.keyPointer); | ||
} | ||
@@ -977,3 +976,3 @@ } | ||
} | ||
get [r]() { | ||
get [e]() { | ||
return this; | ||
@@ -985,108 +984,108 @@ } | ||
has(t) { | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== $(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && 0 !== Q(this.carrier.heap, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
add(t) { | ||
return "string" != typeof t && "number" != typeof t || Rt(() => { | ||
vt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, void 0); | ||
return "string" != typeof t && "number" != typeof t || xt(() => { | ||
Dt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), t, void 0); | ||
}, this.carrier.allocator), this; | ||
} | ||
delete(t) { | ||
return ("string" == typeof t || "number" == typeof t) && Yt(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
return ("string" == typeof t || "number" == typeof t) && vt(this.carrier, _(this.carrier.heap, this.entryPointer), t); | ||
} | ||
} | ||
const Ft = { | ||
[u.OBJECT]: Dt, | ||
[u.DATE]: function(t, r, e) { | ||
const Yt = { | ||
[r.OBJECT]: Wt, | ||
[r.DATE]: function(t, r, e) { | ||
return new Proxy(new Date(0), new DateWrapper(t, r, e)); | ||
}, | ||
[u.ARRAY]: function(t, r, e) { | ||
[r.ARRAY]: function(t, r, e) { | ||
return new Proxy([], new ArrayWrapper(t, r, e)); | ||
}, | ||
[u.MAP]: function(t, r, e) { | ||
[r.MAP]: function(t, r, e) { | ||
return new MapWrapper(t, r, e); | ||
}, | ||
[u.SET]: function(t, r, e) { | ||
[r.SET]: function(t, r, e) { | ||
return new SetWrapper(t, r, e); | ||
} | ||
}; | ||
function Ot(t, r, e) { | ||
if (0 === e) return; | ||
if (1 === e) return null; | ||
if (2 === e) return !0; | ||
if (3 === e) return !1; | ||
const n = I(r.heap, e); | ||
switch (n) { | ||
case u.NUMBER: | ||
return p(r.heap, e); | ||
function Ct(t, e, n) { | ||
if (0 === n) return; | ||
if (1 === n) return null; | ||
if (2 === n) return !0; | ||
if (3 === n) return !1; | ||
const i = B(e.heap, n); | ||
switch (i) { | ||
case r.NUMBER: | ||
return p(e.heap, n); | ||
case u.STRING: | ||
return ct(r.heap, e); | ||
case r.STRING: | ||
return lt(e.heap, n); | ||
case u.BIGINT_POSITIVE: | ||
return A(r.heap, e); | ||
case r.BIGINT_POSITIVE: | ||
return A(e.heap, n); | ||
case u.BIGINT_NEGATIVE: | ||
return A(r.heap, e) * BigInt("-1"); | ||
case r.BIGINT_NEGATIVE: | ||
return A(e.heap, n) * BigInt("-1"); | ||
} | ||
if (n !== u.OBJECT && n !== u.DATE && n !== u.ARRAY && n !== u.MAP && n !== u.SET) throw new Error("Nope Nope Nope"); | ||
const i = Lt(r, t => { | ||
if (i !== r.OBJECT && i !== r.DATE && i !== r.ARRAY && i !== r.MAP && i !== r.SET) throw new Error("Nope Nope Nope"); | ||
const o = Ot(e, t => { | ||
!function(t, r) { | ||
if (0 === Ut(r.heap, t)) { | ||
const e = nt(r.heap, !1, t); | ||
if (0 === gt(r.heap, t)) { | ||
const e = ot(r.heap, !1, t); | ||
for (const t of e.leafAddresses) r.allocator.free(t); | ||
for (const t of e.arcAddresses) Ut(r.heap, t); | ||
for (const t of e.arcAddresses) gt(r.heap, t); | ||
} | ||
}(t, r); | ||
}(t, e); | ||
}); | ||
let o = i.get(e); | ||
return o || (o = Ft[n](t, r, e), i.set(e, o)), o; | ||
let a = o.get(n); | ||
return a || (a = Yt[i](t, e, n), o.set(n, a)), a; | ||
} | ||
function Yt(t, r, e) { | ||
const n = K(t, r, e); | ||
return 0 !== n && (At(t, t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]), | ||
function vt(t, r, e) { | ||
const n = X(t, r, e); | ||
return 0 !== n && (Tt(t, t.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]), | ||
!0); | ||
} | ||
function Ct(t, r) { | ||
let e = 0; | ||
const n = []; | ||
for (;e = Q(t.heap, r, e); ) { | ||
const {valuePointer: r, keyPointer: i} = X(t.heap, e), o = I(t.heap, i) === u.NUMBER ? p(t.heap, i) : ct(t.heap, i); | ||
n.push({ | ||
valuePointer: t.heap.Uint32Array[r / Uint32Array.BYTES_PER_ELEMENT], | ||
key: o | ||
function zt(t, e) { | ||
let n = 0; | ||
const i = []; | ||
for (;n = Z(t.heap, e, n); ) { | ||
const {valuePointer: e, keyPointer: o} = tt(t.heap, n), a = B(t.heap, o) === r.NUMBER ? p(t.heap, o) : lt(t.heap, o); | ||
i.push({ | ||
valuePointer: t.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT], | ||
key: a | ||
}); | ||
} | ||
return n; | ||
return i; | ||
} | ||
function vt(t, r, e, n, i) { | ||
Et(t, r, H(t, r, e, n), i); | ||
function Dt(t, r, e, n, i) { | ||
Ut(t, r, K(t, r, e, n), i); | ||
} | ||
function zt(t, r, e, n) { | ||
function Gt(t, r, e, n) { | ||
const i = function(t, r, e) { | ||
const n = $(t, r, e); | ||
const n = Q(t, r, e); | ||
return 0 === n ? 0 : t.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT] + 0; | ||
}(r.heap, e, n); | ||
return Ot(t, r, r.heap.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]); | ||
return Ct(t, r, r.heap.Uint32Array[i / Uint32Array.BYTES_PER_ELEMENT]); | ||
} | ||
function Gt(t, r, e) { | ||
const n = B(r.heap, e); | ||
function jt(t, r, e) { | ||
const n = I(r.heap, e); | ||
R(r.heap, e, 0); | ||
const {leafAddresses: i, arcAddresses: o} = nt(r.heap, !1, e); | ||
const {leafAddresses: i, arcAddresses: o} = ot(r.heap, !1, e); | ||
for (const t of i) t !== e && r.allocator.free(t); | ||
for (const t of o) t !== e && Ut(r.heap, t); | ||
for (const t of o) t !== e && gt(r.heap, t); | ||
var a, s, c; | ||
R(r.heap, e, n), a = r.heap, s = e, c = q(r, t.hashMapMinInitialCapacity), a.Uint32Array[(s + 12) / 4] = c; | ||
R(r.heap, e, n), a = r.heap, s = e, c = $(r, t.hashMapMinInitialCapacity), a.Uint32Array[(s + 12) / 4] = c; | ||
} | ||
class ObjectWrapper extends BaseProxyTrap { | ||
get(t, e) { | ||
return e === r ? this : "symbol" != typeof e ? zt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), e) : void 0; | ||
get(t, r) { | ||
return r === e ? this : "symbol" != typeof r ? Gt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), r) : void 0; | ||
} | ||
deleteProperty(t, r) { | ||
return "symbol" != typeof r && Yt(this.carrier, _(this.carrier.heap, this.entryPointer), r); | ||
return "symbol" != typeof r && vt(this.carrier, _(this.carrier.heap, this.entryPointer), r); | ||
} | ||
enumerate() { | ||
return Ct(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
return zt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
} | ||
ownKeys() { | ||
return Ct(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
return zt(this.carrier, _(this.carrier.heap, this.entryPointer)).map(t => t.key); | ||
} | ||
@@ -1099,9 +1098,9 @@ getOwnPropertyDescriptor(t, r) { | ||
} | ||
has(t, e) { | ||
return e === r || "symbol" != typeof e && 0 !== $(this.carrier.heap, _(this.carrier.heap, this.entryPointer), e); | ||
has(t, r) { | ||
return r === e || "symbol" != typeof r && 0 !== Q(this.carrier.heap, _(this.carrier.heap, this.entryPointer), r); | ||
} | ||
set(t, r, e) { | ||
if ("symbol" == typeof r) throw new IllegalObjectPropConfigError; | ||
return Rt(() => { | ||
vt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), r, e); | ||
return xt(() => { | ||
Dt(this.externalArgs, this.carrier, _(this.carrier.heap, this.entryPointer), r, e); | ||
}, this.carrier.allocator), !0; | ||
@@ -1122,3 +1121,3 @@ } | ||
} | ||
function Dt(t, r, e) { | ||
function Wt(t, r, e) { | ||
return new Proxy({ | ||
@@ -1128,3 +1127,3 @@ objectBufferWrapper: "objectBufferWrapper" | ||
} | ||
var jt, Wt; | ||
var Vt, Jt; | ||
!function(t) { | ||
@@ -1134,39 +1133,39 @@ t[t.U8 = 0] = "U8", t[t.U8C = 1] = "U8C", t[t.I8 = 2] = "I8", t[t.U16 = 3] = "U16", | ||
t[t.F64 = 8] = "F64"; | ||
}(jt || (jt = {})), function(t) { | ||
}(Vt || (Vt = {})), function(t) { | ||
t[t.I8 = 5120] = "I8", t[t.U8 = 5121] = "U8", t[t.I16 = 5122] = "I16", t[t.U16 = 5123] = "U16", | ||
t[t.I32 = 5124] = "I32", t[t.U32 = 5125] = "U32", t[t.F32 = 5126] = "F32"; | ||
}(Wt || (Wt = {})), Wt.I8, jt.I8, Wt.U8, jt.U8, Wt.I16, jt.I16, Wt.U16, jt.U16, | ||
Wt.I32, jt.I32, Wt.U32, jt.U32, Wt.F32, jt.F32, jt.I8, Wt.I8, jt.U8, Wt.U8, jt.U8C, | ||
Wt.U8, jt.I16, Wt.I16, jt.U16, Wt.U16, jt.I32, Wt.I32, jt.I32, Wt.I32, jt.U32, Wt.U32, | ||
jt.F32, Wt.F32, jt.F64; | ||
const Vt = { | ||
[jt.U8]: 1, | ||
[jt.U8C]: 1, | ||
[jt.I8]: 1, | ||
[jt.U16]: 2, | ||
[jt.I16]: 2, | ||
[jt.U32]: 4, | ||
[jt.I32]: 4, | ||
[jt.F32]: 4, | ||
[jt.F64]: 8 | ||
}, Jt = { | ||
[jt.U8]: Uint8Array, | ||
[jt.U8C]: Uint8ClampedArray, | ||
[jt.I8]: Int8Array, | ||
[jt.U16]: Uint16Array, | ||
[jt.I16]: Int16Array, | ||
[jt.U32]: Uint32Array, | ||
[jt.I32]: Int32Array, | ||
[jt.F32]: Float32Array, | ||
[jt.F64]: Float64Array, | ||
[Wt.U8]: Uint8Array, | ||
[Wt.I8]: Int8Array, | ||
[Wt.U16]: Uint16Array, | ||
[Wt.I16]: Int16Array, | ||
[Wt.U32]: Uint32Array, | ||
[Wt.I32]: Int32Array, | ||
[Wt.F32]: Float32Array | ||
}, qt = "undefined" == typeof process || "production" !== process.env.NODE_ENV || "1" === process.env.UMBRELLA_ASSERTS ? (t, r = "assertion failed") => { | ||
}(Jt || (Jt = {})), Jt.I8, Vt.I8, Jt.U8, Vt.U8, Jt.I16, Vt.I16, Jt.U16, Vt.U16, | ||
Jt.I32, Vt.I32, Jt.U32, Vt.U32, Jt.F32, Vt.F32, Vt.I8, Jt.I8, Vt.U8, Jt.U8, Vt.U8C, | ||
Jt.U8, Vt.I16, Jt.I16, Vt.U16, Jt.U16, Vt.I32, Jt.I32, Vt.I32, Jt.I32, Vt.U32, Jt.U32, | ||
Vt.F32, Jt.F32, Vt.F64; | ||
const qt = { | ||
[Vt.U8]: 1, | ||
[Vt.U8C]: 1, | ||
[Vt.I8]: 1, | ||
[Vt.U16]: 2, | ||
[Vt.I16]: 2, | ||
[Vt.U32]: 4, | ||
[Vt.I32]: 4, | ||
[Vt.F32]: 4, | ||
[Vt.F64]: 8 | ||
}, Ht = { | ||
[Vt.U8]: Uint8Array, | ||
[Vt.U8C]: Uint8ClampedArray, | ||
[Vt.I8]: Int8Array, | ||
[Vt.U16]: Uint16Array, | ||
[Vt.I16]: Int16Array, | ||
[Vt.U32]: Uint32Array, | ||
[Vt.I32]: Int32Array, | ||
[Vt.F32]: Float32Array, | ||
[Vt.F64]: Float64Array, | ||
[Jt.U8]: Uint8Array, | ||
[Jt.I8]: Int8Array, | ||
[Jt.U16]: Uint16Array, | ||
[Jt.I16]: Int16Array, | ||
[Jt.U32]: Uint32Array, | ||
[Jt.I32]: Int32Array, | ||
[Jt.F32]: Float32Array | ||
}, $t = "undefined" == typeof process || "production" !== process.env.NODE_ENV || "1" === process.env.UMBRELLA_ASSERTS ? (t, r = "assertion failed") => { | ||
if ("function" == typeof t && !t() || !t) throw new Error("function" == typeof r ? r() : r); | ||
} : () => {}, Ht = (t, r) => t + --r & ~r, $t = ((t, r = (t => void 0 !== t ? ": " + t : "")) => class extends Error { | ||
} : () => {}, Kt = (t, r) => t + --r & ~r, Qt = ((t, r = (t => void 0 !== t ? ": " + t : "")) => class extends Error { | ||
constructor(e) { | ||
@@ -1178,10 +1177,10 @@ super(t(e) + r(e)); | ||
constructor(t = {}) { | ||
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = null != t.start ? Ht(Math.max(t.start, 0), 4) : 0, | ||
if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = null != t.start ? Kt(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, 7), | ||
!t.skipInitialization) { | ||
const r = t.align || 8; | ||
qt(r >= 8, `invalid alignment: ${r}, must be a pow2 and >= 8`); | ||
$t(r >= 8, `invalid alignment: ${r}, must be a pow2 and >= 8`); | ||
const e = this.initialTop(r), n = null != t.end ? Math.min(t.end, this.buf.byteLength) : this.buf.byteLength; | ||
e >= n && (t => { | ||
throw new $t(t); | ||
throw new Qt(t); | ||
})(`insufficient address range (0x${this.start.toString(16)} - 0x${n.toString(16)})`), | ||
@@ -1214,5 +1213,5 @@ this.align = r, this.doCompact = !1 !== t.compact, this.doSplit = !1 !== t.split, | ||
mallocAs(t, r) { | ||
const e = this.malloc(r * Vt[t]); | ||
const e = this.malloc(r * qt[t]); | ||
return e ? function(t, ...r) { | ||
return new Jt[t](...r); | ||
return new Ht[t](...r); | ||
}(t, this.buf, e, r) : void 0; | ||
@@ -1226,3 +1225,3 @@ } | ||
if (t <= 0) return 0; | ||
const r = Ht(t + 8, this.align), e = this.end; | ||
const r = Kt(t + 8, this.align), e = this.end; | ||
let n = this.top, i = this._free, o = 0; | ||
@@ -1238,3 +1237,3 @@ for (;i; ) { | ||
} | ||
return Kt(i); | ||
return Xt(i); | ||
} | ||
@@ -1244,7 +1243,7 @@ o = i, i = this.blockNext(i); | ||
return i = n, n = i + r, n <= e ? (this.initBlock(i, r, this._used), this._used = i, | ||
this.top = n, Kt(i)) : 0; | ||
this.top = n, Xt(i)) : 0; | ||
} | ||
realloc(t, r) { | ||
if (r <= 0) return 0; | ||
const e = Qt(t); | ||
const e = Zt(t); | ||
let n = 0, i = this._used, o = 0; | ||
@@ -1255,3 +1254,3 @@ for (;i; ) { | ||
o = e + t; | ||
const a = o >= this.top, s = Ht(r + 8, this.align); | ||
const a = o >= this.top, s = Kt(r + 8, this.align); | ||
if (s <= t) { | ||
@@ -1269,3 +1268,3 @@ if (this.doSplit) { | ||
} | ||
this.free(e), n = Qt(this.malloc(r)); | ||
this.free(e), n = Zt(this.malloc(r)); | ||
break; | ||
@@ -1275,3 +1274,3 @@ } | ||
} | ||
return n && n !== e && this.u8.copyWithin(Kt(n), Kt(e), o), Kt(n); | ||
return n && n !== e && this.u8.copyWithin(Xt(n), Xt(e), o), Xt(n); | ||
} | ||
@@ -1289,3 +1288,3 @@ reallocArray(t, r) { | ||
} else r = t; | ||
r = Qt(r); | ||
r = Zt(r); | ||
let e = this._used, n = 0; | ||
@@ -1351,3 +1350,3 @@ for (;e; ) { | ||
set minSplit(t) { | ||
qt(t > 8, `illegal min split threshold: ${t}, require at least 9`), this.state[6] = t; | ||
$t(t > 8, `illegal min split threshold: ${t}, require at least 9`), this.state[6] = t; | ||
} | ||
@@ -1377,3 +1376,3 @@ blockSize(t) { | ||
initialTop(t = this.align) { | ||
return Ht(this.start + 28 + 8, t) - 8; | ||
return Kt(this.start + 28 + 8, t) - 8; | ||
} | ||
@@ -1406,3 +1405,3 @@ compact() { | ||
} | ||
const Kt = t => t + 8, Qt = t => t - 8, Xt = { | ||
const Xt = t => t + 8, Zt = t => t - 8, tr = { | ||
Uint8Array: Uint8Array, | ||
@@ -1420,24 +1419,24 @@ Uint8ClampedArray: Uint8ClampedArray, | ||
}; | ||
function Zt(t) { | ||
return Object.fromEntries(Object.entries(Xt).map(([r, e]) => [ r, new e(t) ])); | ||
function rr(t) { | ||
return Object.fromEntries(Object.entries(tr).map(([r, e]) => [ r, new e(t) ])); | ||
} | ||
function tr(t) { | ||
return c(t).getCarrier().heap.Uint8Array.buffer; | ||
function er(t) { | ||
return h(t).getCarrier().heap.Uint8Array.buffer; | ||
} | ||
function rr(t, r) { | ||
const e = Lt(tr(t)), n = Lt(r); | ||
function nr(t, r) { | ||
const e = Ot(er(t)), n = Ot(r); | ||
for (const t of e) n.set(t[0], t[1]), e.delete(t[0]); | ||
const o = new MemPool({ | ||
const i = new MemPool({ | ||
align: 8, | ||
buf: r, | ||
start: i, | ||
start: o, | ||
skipInitialization: !0 | ||
}), a = { | ||
allocator: o, | ||
heap: Zt(r) | ||
allocator: i, | ||
heap: rr(r) | ||
}; | ||
o.end = r.byteLength, c(t).replaceCarrierContent(a); | ||
i.end = r.byteLength, h(t).replaceCarrierContent(a); | ||
} | ||
t.acquireLock = function(t, r) { | ||
const e = tr(r); | ||
const e = er(r); | ||
!function(t, r) { | ||
@@ -1449,13 +1448,13 @@ if (!t) throw new Error(r); | ||
}, t.acquireLockWait = function(t, r, e) { | ||
const n = tr(r), i = new Int32Array(n), o = Atomics.compareExchange(i, 0, 0, t); | ||
const n = er(r), i = new Int32Array(n), o = Atomics.compareExchange(i, 0, 0, t); | ||
if (0 === o) return "have-lock"; | ||
const a = Atomics.wait(i, 0, o, e); | ||
return "not-equal" === a ? 0 === Atomics.compareExchange(i, 0, 0, t) ? "have-lock" : "miss-lock" : "timed-out" === a ? "timed-out" : "no-lock"; | ||
}, t.createObjectBuffer = function(t, r, o, a = {}) { | ||
if (c = o, Array.isArray(c) || c instanceof Date || c instanceof Map || c instanceof Set || "object" != typeof c || null === typeof c || "Object" !== c.constructor.name) throw new UnsupportedOperationError; | ||
var c; | ||
}, t.createObjectBuffer = function(t, r, e, a = {}) { | ||
if (s = e, Array.isArray(s) || s instanceof Date || s instanceof Map || s instanceof Set || "object" != typeof s || null === typeof s || "Object" !== s.constructor.name) throw new UnsupportedOperationError; | ||
var s; | ||
const h = new (a.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer)(r); | ||
!function(t) { | ||
const r = new Uint32Array(t); | ||
r[0] = 0, r[e / Uint32Array.BYTES_PER_ELEMENT] = n; | ||
r[0] = 0, r[n / Uint32Array.BYTES_PER_ELEMENT] = i; | ||
}(h); | ||
@@ -1465,55 +1464,57 @@ const l = new MemPool({ | ||
buf: h, | ||
start: i | ||
start: o | ||
}), u = { | ||
allocator: l, | ||
heap: Zt(h) | ||
heap: rr(h) | ||
}; | ||
return Rt(() => { | ||
pt(s(t), u, [], e, o); | ||
}, l), Dt(s(t), u, u.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT]); | ||
return xt(() => { | ||
Et(c(t), u, [], n, e); | ||
}, l), Wt(c(t), u, u.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]); | ||
}, t.disposeWrapperObject = function(t) { | ||
const r = c(t), e = r.getEntryPointer(), n = r.destroy(); | ||
if (Lt(r.getCarrier()).delete(e), 0 === n) { | ||
const t = nt(r.getCarrier().heap, !1, e), {allocator: n, heap: i} = r.getCarrier(); | ||
const r = h(t), e = r.getEntryPointer(), n = r.destroy(); | ||
if (Ot(r.getCarrier()).delete(e), 0 === n) { | ||
const t = ot(r.getCarrier().heap, !1, e), {allocator: n, heap: i} = r.getCarrier(); | ||
for (const r of t.leafAddresses) n.free(r); | ||
for (const r of t.arcAddresses) Ut(i, r); | ||
for (const r of t.arcAddresses) gt(i, r); | ||
return !0; | ||
} | ||
return !1; | ||
}, t.getUnderlyingArrayBuffer = tr, t.loadObjectBuffer = function(t, r) { | ||
const n = { | ||
}, t.getUnderlyingArrayBuffer = er, t.loadObjectBuffer = function(t, r) { | ||
const e = { | ||
allocator: new MemPool({ | ||
align: 8, | ||
buf: r, | ||
start: i, | ||
start: o, | ||
skipInitialization: !0 | ||
}), | ||
heap: Zt(r) | ||
heap: rr(r) | ||
}; | ||
return Dt(s(t), n, n.heap.Uint32Array[e / Uint32Array.BYTES_PER_ELEMENT]); | ||
return Wt(c(t), e, e.heap.Uint32Array[n / Uint32Array.BYTES_PER_ELEMENT]); | ||
}, t.memoryStats = function(t) { | ||
const r = tr(t), e = new MemPool({ | ||
const r = er(t), e = new MemPool({ | ||
align: 8, | ||
buf: r, | ||
skipInitialization: !0, | ||
start: i | ||
}), {available: n, total: o} = e.stats(); | ||
start: o | ||
}), {available: n, total: i, top: a} = e.stats(); | ||
return { | ||
available: n, | ||
used: o - n | ||
used: i - n, | ||
total: i, | ||
top: a | ||
}; | ||
}, t.releaseLock = function(t, r) { | ||
const e = tr(r), n = new Int32Array(e); | ||
const e = er(r), n = new Int32Array(e); | ||
return Atomics.compareExchange(n, 0, t, 0) === t && (Atomics.notify(n, 0, 1 / 0), | ||
!0); | ||
}, t.replaceUnderlyingArrayBuffer = rr, t.resizeObjectBuffer = function(t, r) { | ||
const e = tr(t), n = new ArrayBuffer(r); | ||
}, t.replaceUnderlyingArrayBuffer = nr, t.resizeObjectBuffer = function(t, r) { | ||
const e = er(t), n = new ArrayBuffer(r); | ||
return function(t, r, e, n, i) { | ||
const o = new Uint8Array(t); | ||
new Uint8Array(n).set(o.subarray(r, r + e), i); | ||
}(e, 0, Math.min(r, e.byteLength), n, 0), rr(t, n), n; | ||
}(e, 0, Math.min(r, e.byteLength), n, 0), nr(t, n), n; | ||
}, t.unreliable_sizeOf = function() { | ||
return console.warn("FAKE VALUE"), Math.pow(2, 24); | ||
}, t.updateExternalArgs = function(t, r) { | ||
Object.assign(c(t).getExternalArgs(), r); | ||
Object.assign(h(t).getExternalArgs(), r); | ||
}, Object.defineProperty(t, "__esModule", { | ||
@@ -1520,0 +1521,0 @@ value: !0 |
{ | ||
"name": "@bnaya/objectbuffer", | ||
"description": "Object-like api, backed by an array buffer", | ||
"version": "0.0.0-7449ff0", | ||
"version": "0.0.0-7a3f3a1", | ||
"main": "dist/objectbuffer.cjs.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.js", |
@@ -21,2 +21,4 @@ /* eslint-env jest */ | ||
"available": 328, | ||
"top": 696, | ||
"total": 1024, | ||
"used": 696, | ||
@@ -36,2 +38,4 @@ } | ||
"available": 1352, | ||
"top": 696, | ||
"total": 2048, | ||
"used": 696, | ||
@@ -45,2 +49,4 @@ } | ||
"available": 328, | ||
"top": 696, | ||
"total": 1024, | ||
"used": 696, | ||
@@ -54,2 +60,4 @@ } | ||
"available": 72, | ||
"top": 696, | ||
"total": 768, | ||
"used": 696, | ||
@@ -63,2 +71,4 @@ } | ||
"available": 1352, | ||
"top": 696, | ||
"total": 2048, | ||
"used": 696, | ||
@@ -65,0 +75,0 @@ } |
@@ -8,3 +8,6 @@ /* eslint-env jest */ | ||
} from "."; | ||
import { arrayBuffer2HexArray } from "./internal/testUtils"; | ||
import { | ||
arrayBuffer2HexArray, | ||
getArrayBufferOnTopSize, | ||
} from "./internal/testUtils"; | ||
import { externalArgsApiToExternalArgsApi } from "./internal/utils"; | ||
@@ -51,3 +54,5 @@ | ||
// that one tests implementation details, but... | ||
expect(arrayBuffer2HexArray(arrayBuffer, true)).toMatchSnapshot(); | ||
expect( | ||
arrayBuffer2HexArray(getArrayBufferOnTopSize(o), true) | ||
).toMatchSnapshot(); | ||
}); | ||
@@ -54,0 +59,0 @@ }); |
import { initializeArrayBuffer } from "./store"; | ||
import { createObjectWrapper } from "./objectWrapper"; | ||
import { ExternalArgsApi, GlobalCarrier } from "./interfaces"; | ||
import { ExternalArgsApi, GlobalCarrier, MemoryStats } from "./interfaces"; | ||
import { | ||
@@ -189,3 +189,3 @@ arrayBufferCopyTo, | ||
*/ | ||
export function memoryStats(objectBuffer: unknown) { | ||
export function memoryStats(objectBuffer: unknown): MemoryStats { | ||
const buf = getUnderlyingArrayBuffer(objectBuffer); | ||
@@ -200,5 +200,5 @@ | ||
const { available, total } = pool.stats(); | ||
const { available, total, top } = pool.stats(); | ||
return { available, used: total - available }; | ||
return { available, used: total - available, total, top }; | ||
} | ||
@@ -205,0 +205,0 @@ |
@@ -1,3 +0,1 @@ | ||
import { createKnownTypeGuard } from "./utils"; | ||
export enum ENTRY_TYPE { | ||
@@ -26,2 +24,5 @@ /** | ||
ARRAY, | ||
/** | ||
* @deprecated | ||
*/ | ||
ARRAY_ITEM, | ||
@@ -32,10 +33,1 @@ MAP, | ||
} | ||
export const PRIMITIVE_TYPES = [ | ||
ENTRY_TYPE.NUMBER, | ||
ENTRY_TYPE.BIGINT_POSITIVE, | ||
ENTRY_TYPE.BIGINT_NEGATIVE, | ||
ENTRY_TYPE.STRING, | ||
] as const; | ||
export const isPrimitiveEntryType = createKnownTypeGuard(PRIMITIVE_TYPES); |
@@ -134,2 +134,4 @@ /* eslint-env jest */ | ||
"available": 656, | ||
"top": 1392, | ||
"total": 2048, | ||
"used": 1392, | ||
@@ -157,2 +159,4 @@ } | ||
"available": 2008, | ||
"top": 40, | ||
"total": 2048, | ||
"used": 40, | ||
@@ -159,0 +163,0 @@ } |
@@ -127,5 +127,2 @@ import { ENTRY_TYPE } from "./entry-types"; | ||
break; | ||
default: | ||
throw new Error(ENTRY_TYPE[entryType] + " Not implemented yet"); | ||
} | ||
@@ -132,0 +129,0 @@ } |
@@ -7,2 +7,3 @@ /* eslint-env jest */ | ||
makeCarrier, | ||
makeAllocatorThrowOnOOM, | ||
} from "../testUtils"; | ||
@@ -34,2 +35,3 @@ import { | ||
carrier = makeCarrier(ab); | ||
makeAllocatorThrowOnOOM(carrier.allocator); | ||
} | ||
@@ -44,5 +46,5 @@ | ||
expect(mapPointer).toMatchInlineSnapshot(`48`); | ||
expect(arrayBuffer2HexArray(ab.slice(0, 128), true)).toMatchSnapshot( | ||
"simple create empty" | ||
); | ||
expect( | ||
arrayBuffer2HexArray(ab.slice(0, carrier.allocator.stats().top), true) | ||
).toMatchSnapshot("simple create empty"); | ||
}); | ||
@@ -62,3 +64,5 @@ | ||
expect(arrayBuffer2HexArray(ab, true)).toMatchSnapshot("after insert"); | ||
expect( | ||
arrayBuffer2HexArray(ab.slice(0, carrier.allocator.stats().top), true) | ||
).toMatchSnapshot("after insert"); | ||
}); | ||
@@ -78,3 +82,5 @@ | ||
expect(arrayBuffer2HexArray(ab, true)).toMatchSnapshot("after insert"); | ||
expect( | ||
arrayBuffer2HexArray(ab.slice(0, carrier.allocator.stats().top), true) | ||
).toMatchSnapshot("after insert"); | ||
}); | ||
@@ -225,3 +231,3 @@ | ||
expect(hashMapSize(carrier.heap, mapPointer)).toMatchInlineSnapshot(`0`); | ||
const memAvailableAfterEachStep = [carrier.allocator.stats().available]; | ||
const memAvailableAfterEachStep = [carrier.allocator.stats().top]; | ||
@@ -238,6 +244,6 @@ const input = [...new Array(26).keys()] | ||
memAvailableAfterEachStep.push(carrier.allocator.stats().available); | ||
memAvailableAfterEachStep.push(carrier.allocator.stats().top); | ||
} | ||
expect(hashMapSize(carrier.heap, mapPointer)).toMatchInlineSnapshot(`26`); | ||
expect(hashMapSize(carrier.heap, mapPointer)).toBe(26); | ||
@@ -247,7 +253,7 @@ hashMapDelete(carrier, mapPointer, "a"); | ||
hashMapDelete(carrier, mapPointer, "c"); | ||
expect(hashMapSize(carrier.heap, mapPointer)).toMatchInlineSnapshot(`26`); | ||
memAvailableAfterEachStep.push(carrier.allocator.stats().available); | ||
hashMapDelete(carrier, mapPointer, "t"); | ||
expect(hashMapSize(carrier.heap, mapPointer)).toBe(22); | ||
memAvailableAfterEachStep.push(carrier.allocator.stats().top); | ||
expect(memAvailableAfterEachStep.map((a) => abSize - a)) | ||
.toMatchInlineSnapshot(` | ||
expect(memAvailableAfterEachStep).toMatchInlineSnapshot(` | ||
Array [ | ||
@@ -262,3 +268,3 @@ 144, | ||
704, | ||
824, | ||
872, | ||
904, | ||
@@ -271,9 +277,9 @@ 984, | ||
1384, | ||
1464, | ||
1544, | ||
1624, | ||
1704, | ||
1784, | ||
1864, | ||
2024, | ||
1632, | ||
1632, | ||
1712, | ||
1792, | ||
1872, | ||
1952, | ||
2032, | ||
2112, | ||
@@ -301,3 +307,3 @@ 2192, | ||
// expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`880`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`144`); | ||
@@ -304,0 +310,0 @@ let toAdd: undefined | string; |
@@ -130,3 +130,3 @@ import { GlobalCarrier, ExternalArgs } from "../interfaces"; | ||
const keyHashCode = hashCodeInPlace( | ||
const bucket = hashCodeInPlace( | ||
heap.Uint8Array, | ||
@@ -140,3 +140,3 @@ hashmap_CAPACITY_get(heap, mapPointer), | ||
hashmap_ARRAY_POINTER_get(heap, mapPointer) + | ||
keyHashCode * Uint32Array.BYTES_PER_ELEMENT; | ||
bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
@@ -243,3 +243,3 @@ let ptrToPtrToSaveTheNodeTo = bucketStartPointer; | ||
) { | ||
const keyHashCode = hashCodeExternalValue( | ||
const bucket = hashCodeExternalValue( | ||
hashmap_CAPACITY_get(heap, mapPointer), | ||
@@ -251,3 +251,3 @@ externalKeyValue | ||
hashmap_ARRAY_POINTER_get(heap, mapPointer) + | ||
keyHashCode * Uint32Array.BYTES_PER_ELEMENT; | ||
bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
@@ -440,3 +440,3 @@ let ptrToPtr = bucketStartPtrToPtr; | ||
// Why not realloc? | ||
// we don't use re alloc because we don't need the old values | ||
allocator.free(hashmap_ARRAY_POINTER_get(heap, hashmapPointer)); | ||
@@ -449,2 +449,3 @@ const biggerArray = carrier.allocator.calloc( | ||
hashmap_CAPACITY_set(heap, hashmapPointer, newCapacity); | ||
hashmap_USED_CAPACITY_set(heap, hashmapPointer, 0); | ||
@@ -459,3 +460,3 @@ let pointerToNode = 0; | ||
) { | ||
hashMapRehashInsert(heap, biggerArray, newCapacity, pointerToNode); | ||
hashMapRehashInsert(heap, hashmapPointer, pointerToNode); | ||
} | ||
@@ -466,16 +467,15 @@ } | ||
heap: Heap, | ||
bucketsArrayPointer: number, | ||
arraySize: number, | ||
hashmapPointer: number, | ||
nodePointer: number | ||
) { | ||
const keyHashCode = hashCodeInPlace( | ||
const bucket = hashCodeInPlace( | ||
heap.Uint8Array, | ||
arraySize, | ||
getKeyStart(heap, nodePointer), | ||
getKeyLength(heap, nodePointer) | ||
hashmap_CAPACITY_get(heap, hashmapPointer), | ||
getKeyStart(heap, hashmapNode_KEY_POINTER_get(heap, nodePointer)), | ||
getKeyLength(heap, hashmapNode_KEY_POINTER_get(heap, nodePointer)) | ||
); | ||
const bucket = keyHashCode % arraySize; | ||
const bucketStartPointer = | ||
bucketsArrayPointer + bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
hashmap_ARRAY_POINTER_get(heap, hashmapPointer) + | ||
bucket * Uint32Array.BYTES_PER_ELEMENT; | ||
@@ -489,3 +489,12 @@ const prevFirstNodeInBucket = | ||
hashmapNode_NEXT_NODE_POINTER_set(heap, nodePointer, prevFirstNodeInBucket); | ||
if (prevFirstNodeInBucket !== 0) { | ||
hashmapNode_NEXT_NODE_POINTER_set(heap, nodePointer, prevFirstNodeInBucket); | ||
} else { | ||
hashmapNode_NEXT_NODE_POINTER_set(heap, nodePointer, 0); | ||
hashmap_USED_CAPACITY_set( | ||
heap, | ||
hashmapPointer, | ||
hashmap_USED_CAPACITY_get(heap, hashmapPointer) + 1 | ||
); | ||
} | ||
} | ||
@@ -492,0 +501,0 @@ |
import type { Heap } from "../structsGenerator/consts"; | ||
import type { IMemPool } from "@thi.ng/malloc"; | ||
export interface MemoryStats { | ||
available: number; | ||
used: number; | ||
total: number; | ||
top: number; | ||
} | ||
export interface GlobalCarrier { | ||
@@ -5,0 +12,0 @@ allocator: IMemPool; |
@@ -37,3 +37,5 @@ /* eslint-env jest */ | ||
expect(arrayBuffer2HexArray(ab, true)).toMatchSnapshot(); | ||
expect( | ||
arrayBuffer2HexArray(ab.slice(0, carrier.allocator.stats().top), true) | ||
).toMatchSnapshot(); | ||
@@ -44,3 +46,5 @@ const itemPointer = linkedListItemInsert(carrier, linkedListPointer, 7); | ||
expect(arrayBuffer2HexArray(ab, true)).toMatchSnapshot(); | ||
expect( | ||
arrayBuffer2HexArray(ab.slice(0, carrier.allocator.stats().top), true) | ||
).toMatchSnapshot(); | ||
}); | ||
@@ -52,3 +56,3 @@ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`56`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
@@ -58,3 +62,3 @@ const pointer1 = linkedListItemInsert(carrier, linkedListPointer, 7); | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`24`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`104`); | ||
@@ -89,3 +93,3 @@ expect(pointer1).toBe(64); | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`56`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
}); | ||
@@ -97,3 +101,3 @@ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
@@ -129,7 +133,7 @@ const itemsPointers = [ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`120`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`136`); | ||
itemsPointers.forEach((p) => linkedListItemRemove(carrier, p)); | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
}); | ||
@@ -141,3 +145,3 @@ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
@@ -180,7 +184,7 @@ const itemsPointers = [ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`152`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`136`); | ||
itemsPointers.forEach((p) => linkedListItemRemove(carrier, p)); | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
}); | ||
@@ -192,3 +196,3 @@ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`184`); | ||
@@ -239,7 +243,7 @@ const regularSet = new Set([7, 6, 5, 4]); | ||
expect(regularSetResults).toEqual(linkedLintResults); | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`152`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`152`); | ||
itemsPointers.forEach((p) => linkedListItemRemove(carrier, p)); | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`184`); | ||
}); | ||
@@ -251,3 +255,3 @@ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
@@ -299,3 +303,3 @@ const itemsPointers = [ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`120`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`136`); | ||
@@ -315,3 +319,3 @@ itemsPointers.forEach((p) => linkedListItemRemove(carrier, p)); | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`184`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
}); | ||
@@ -328,3 +332,3 @@ | ||
expect(carrier.allocator.stats().available).toMatchInlineSnapshot(`64`); | ||
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`72`); | ||
@@ -331,0 +335,0 @@ let toAdd: undefined | number = 0; |
@@ -0,1 +1,37 @@ | ||
import { IMemPool, MemPool } from "@thi.ng/malloc"; | ||
import { OutOfMemoryError } from "./exceptions"; | ||
import { GlobalCarrier } from "./interfaces"; | ||
import { MEM_POOL_START } from "./consts"; | ||
import { createHeap } from "../structsGenerator/consts"; | ||
import { getInternalAPI } from "./utils"; | ||
import { memoryStats } from "./api"; | ||
export function getArrayBufferOnTopSize(ob: unknown) { | ||
const stats = memoryStats(ob); | ||
const carrier = getInternalAPI(ob).getCarrier(); | ||
return carrier.heap.Uint8Array.slice(0, stats.top); | ||
} | ||
export function makeAllocatorThrowOnOOM(allocator: IMemPool) { | ||
const origMalloc = allocator.malloc; | ||
allocator.malloc = function wrappedMalloc(memSize) { | ||
if (memSize === 0) { | ||
throw new Error("memSize can't be 0"); | ||
} | ||
const allocated = origMalloc.call(allocator, memSize); | ||
if (allocated === 0) { | ||
throw new Error("OOM memSize"); | ||
} | ||
return allocated; | ||
}; | ||
} | ||
export function makeThrowOnOOM(ob: unknown) { | ||
const allocator = getInternalAPI(ob).getCarrier().allocator; | ||
makeAllocatorThrowOnOOM(allocator); | ||
} | ||
export function arrayBuffer2HexArray( | ||
@@ -23,8 +59,2 @@ buffer: ArrayBuffer, | ||
import { IMemPool, MemPool } from "@thi.ng/malloc"; | ||
import { OutOfMemoryError } from "./exceptions"; | ||
import { GlobalCarrier } from "./interfaces"; | ||
import { MEM_POOL_START } from "./consts"; | ||
import { createHeap } from "../structsGenerator/consts"; | ||
// extend pool and not monkey patch? need to think about it | ||
@@ -31,0 +61,0 @@ export function recordAllocations(operation: () => void, pool: IMemPool) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
206
16140
1276366