UNPKG

@mindfiredigital/pivothead

Version:

PivotHead is a powerful and flexible library for creating interactive pivot tables in JavaScript applications. It provides a core engine for data manipulation and, in the future, will be compatible with wrappers for React, Vue, Svelte, and Angular, making

263 lines (262 loc) 8.2 kB
const z = "Operation requires compiling with --exportTable", K = "Operation requires compiling with --exportRuntime", S = () => { throw Error(K); }, J = typeof BigUint64Array < "u", h = Symbol(), Q = 192, D = 1024, x = new TextDecoder("utf-16le", { fatal: !0 }); Object.hasOwn = Object.hasOwn || function(t, s) { return Object.prototype.hasOwnProperty.call(t, s); }; function W(t, s) { let i = new Uint32Array(t)[s + -4 >>> 2] >>> 1; const r = new Uint16Array(t, s, i); if (i <= Q) return String.fromCharCode(...r); try { return x.decode(r); } catch { let a = "", A = 0; for (; i - A > D; ) a += String.fromCharCode(...r.subarray(A, A += D)); return a + String.fromCharCode(...r.subarray(A)); } } function Y(t) { const s = {}; function i(a, A) { return a ? W(a.buffer, A) : "<yet unknown>"; } const r = t.env = t.env || {}; return r.abort = r.abort || function(A, u, f, F) { const l = s.memory || r.memory; throw Error(`abort: ${i(l, A)} at ${i(l, u)}:${f}:${F}`); }, r.trace = r.trace || function(A, u, ...f) { const F = s.memory || r.memory; console.log(`trace: ${i(F, A)}${u ? " " : ""}${f.slice(0, u).join(", ")}`); }, r.seed = r.seed || Date.now, t.Math = t.Math || Math, t.Date = t.Date || Date, s; } function B(t, s) { const i = s.exports, r = i.memory, a = i.table, A = i.__new || S, u = i.__pin || S, f = i.__unpin || S, F = i.__collect || S, l = i.__rtti_base, T = l ? (n) => n[l >>> 2] : S; t.__new = A, t.__pin = u, t.__unpin = f, t.__collect = F; function y(n) { const e = new Uint32Array(r.buffer); if ((n >>>= 0) >= T(e)) throw Error(`invalid id: ${n}`); return e[(l + 4 >>> 2) + n]; } function R(n) { const e = y(n); if (!(e & 7)) throw Error(`not an array: ${n}, flags=${e}`); return e; } function O(n) { return 31 - Math.clz32(n >>> 6 & 31); } function Z(n) { if (n == null) return 0; const e = n.length, c = A(e << 1, 2), o = new Uint16Array(r.buffer); for (let _ = 0, E = c >>> 1; _ < e; ++_) o[E + _] = n.charCodeAt(_); return c; } t.__newString = Z; function v(n) { if (n == null) return 0; const e = new Uint8Array(n), c = A(e.length, 1); return new Uint8Array(r.buffer).set(e, c), c; } t.__newArrayBuffer = v; function $(n) { if (!n) return null; const e = r.buffer; if (new Uint32Array(e)[n + -8 >>> 2] !== 2) throw Error(`not a string: ${n}`); return W(e, n); } t.__getString = $; function p(n, e, c) { const o = r.buffer; if (c) switch (n) { case 2: return new Float32Array(o); case 3: return new Float64Array(o); } else switch (n) { case 0: return new (e ? Int8Array : Uint8Array)(o); case 1: return new (e ? Int16Array : Uint16Array)(o); case 2: return new (e ? Int32Array : Uint32Array)(o); case 3: return new (e ? BigInt64Array : BigUint64Array)(o); } throw Error(`unsupported align: ${n}`); } function H(n, e = 0) { const c = e, o = R(n), _ = O(o), E = typeof c != "number", b = E ? c.length : c, I = A(b << _, o & 4 ? n : 1); let m; if (o & 4) m = I; else { u(I); const g = A(o & 2 ? 16 : 12, n); f(I); const w = new Uint32Array(r.buffer); w[g + 0 >>> 2] = I, w[g + 4 >>> 2] = I, w[g + 8 >>> 2] = b << _, o & 2 && (w[g + 12 >>> 2] = b), m = g; } if (E) { const g = p(_, o & 2048, o & 4096), w = I >>> _; if (o & 16384) for (let U = 0; U < b; ++U) g[w + U] = c[U]; else g.set(c, w); } return m; } t.__newArray = H; function N(n) { const e = new Uint32Array(r.buffer), c = e[n + -8 >>> 2], o = R(c), _ = O(o); let E = o & 4 ? n : e[n + 4 >>> 2]; const b = o & 2 ? e[n + 12 >>> 2] : e[E + -4 >>> 2] >>> _; return p(_, o & 2048, o & 4096).subarray(E >>>= _, E + b); } t.__getArrayView = N; function k(n) { const e = N(n), c = e.length, o = new Array(c); for (let _ = 0; _ < c; _++) o[_] = e[_]; return o; } t.__getArray = k; function X(n) { const e = r.buffer, c = new Uint32Array(e)[n + -4 >>> 2]; return e.slice(n, n + c); } t.__getArrayBuffer = X; function d(n) { if (!a) throw Error(z); const e = new Uint32Array(r.buffer)[n >>> 2]; return a.get(e); } t.__getFunction = d; function q(n, e, c) { return new n(V(n, e, c)); } function V(n, e, c) { const o = r.buffer, _ = new Uint32Array(o); return new n( o, _[c + 4 >>> 2], _[c + 8 >>> 2] >>> e ); } function L(n, e, c) { t[`__get${e}`] = q.bind(null, n, c), t[`__get${e}View`] = V.bind(null, n, c); } return [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array ].forEach((n) => { L(n, n.name, 31 - Math.clz32(n.BYTES_PER_ELEMENT)); }), J && [BigUint64Array, BigInt64Array].forEach((n) => { L(n, n.name.slice(3), 3); }), t.memory = t.memory || r, t.table = t.table || a, P(i, t); } function G(t) { return typeof Response < "u" && t instanceof Response; } function C(t) { return t instanceof WebAssembly.Module; } async function j(t, s = {}) { if (G(t = await t)) return M(t, s); const i = C(t) ? t : await WebAssembly.compile(t), r = Y(s), a = await WebAssembly.instantiate(i, s), A = B(r, a); return { module: i, instance: a, exports: A }; } function tt(t, s = {}) { const i = C(t) ? t : new WebAssembly.Module(t), r = Y(s), a = new WebAssembly.Instance(i, s), A = B(r, a); return { module: i, instance: a, exports: A }; } async function M(t, s = {}) { if (!WebAssembly.instantiateStreaming) return j( G(t = await t) ? t.arrayBuffer() : t, s ); const i = Y(s), r = await WebAssembly.instantiateStreaming(t, s), a = B(i, r.instance); return { ...r, exports: a }; } function P(t, s = {}) { const i = t.__argumentsLength ? (r) => { t.__argumentsLength.value = r; } : t.__setArgumentsLength || t.__setargc || (() => { }); for (let r of Object.keys(t)) { const a = t[r]; let A = r.split("."), u = s; for (; A.length > 1; ) { let l = A.shift(); Object.hasOwn(u, l) || (u[l] = {}), u = u[l]; } let f = A[0], F = f.indexOf("#"); if (F >= 0) { const l = f.substring(0, F), T = u[l]; if (typeof T > "u" || !T.prototype) { const y = function(...R) { return y.wrap(y.prototype.constructor(0, ...R)); }; y.prototype = { valueOf() { return this[h]; } }, y.wrap = function(R) { return Object.create(y.prototype, { [h]: { value: R, writable: !1 } }); }, T && Object.getOwnPropertyNames(T).forEach( (R) => Object.defineProperty(y, R, Object.getOwnPropertyDescriptor(T, R)) ), u[l] = y; } if (f = f.substring(F + 1), u = u[l].prototype, /^(get|set):/.test(f)) { if (!Object.hasOwn(u, f = f.substring(4))) { let y = t[r.replace("set:", "get:")], R = t[r.replace("get:", "set:")]; Object.defineProperty(u, f, { get() { return y(this[h]); }, set(O) { R(this[h], O); }, enumerable: !0 }); } } else f === "constructor" ? (u[f] = function(...y) { return i(y.length), a(...y); }).original = a : (u[f] = function(...y) { return i(y.length), a(this[h], ...y); }).original = a; } else /^(get|set):/.test(f) ? Object.hasOwn(u, f = f.substring(4)) || Object.defineProperty(u, f, { get: t[r.replace("set:", "get:")], set: t[r.replace("get:", "set:")], enumerable: !0 }) : typeof a == "function" && a !== i ? (u[f] = (...l) => (i(l.length), a(...l))).original = a : u[f] = a; } return s; } const nt = { instantiate: j, instantiateSync: tt, instantiateStreaming: M, demangle: P }; export { nt as default, P as demangle, j as instantiate, M as instantiateStreaming, tt as instantiateSync };