roaring-wasm-papandreou
Version:
WebAssembly port of Roaring Bitmaps for NodeJS
332 lines (329 loc) • 10.5 kB
JavaScript
var roaring_wasm_module = (() => {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename
return function(config) {
var roaring_wasm_module = config || {}
var a
a || (a = typeof roaring_wasm_module !== 'undefined' ? roaring_wasm_module : {})
var c, h
a.ready = new Promise(function(b, d) {
c = b
h = d
})
process.argv = []
process.on = function() {}
process.exit = function() {}
var l = Object.assign({}, a),
m = 'object' == typeof window,
n = 'function' == typeof importScripts,
p = '',
q,
r
if ('object' == typeof process && 'object' == typeof process.versions && 'string' == typeof process.versions.node) {
var fs = require('fs'),
t = require('path')
p = n ? t.dirname(p) + '/' : __dirname + '/'
q = (b, d) => {
b = b.startsWith('file://') ? new URL(b) : t.normalize(b)
return fs.readFileSync(b, d ? void 0 : 'utf8')
}
r = b => {
b = q(b, !0)
b.buffer || (b = new Uint8Array(b))
return b
}
1 < process.argv.length && process.argv[1].replace(/\\/g, '/')
process.argv.slice(2)
process.on('unhandledRejection', function(b) {
throw b
})
a.inspect = function() {
return '[Emscripten Module object]'
}
} else if (m || n) {
n ? (p = self.location.href) : 'undefined' != typeof document && document.currentScript && (p = document.currentScript.src),
_scriptDir && (p = _scriptDir),
0 !== p.indexOf('blob:') ? (p = p.substr(0, p.replace(/[?#].*/, '').lastIndexOf('/') + 1)) : (p = ''),
(q = b => {
var d = new XMLHttpRequest()
d.open('GET', b, !1)
d.send(null)
return d.responseText
}),
n &&
(r = b => {
var d = new XMLHttpRequest()
d.open('GET', b, !1)
d.responseType = 'arraybuffer'
d.send(null)
return new Uint8Array(d.response)
})
}
a.print || console.log.bind(console)
var u = a.printErr || console.warn.bind(console)
Object.assign(a, l)
l = null
var w
a.wasmBinary && (w = a.wasmBinary)
var noExitRuntime = a.noExitRuntime || !0
'object' != typeof WebAssembly && x('no native wasm support detected')
var y,
z = !1,
A = 'undefined' != typeof TextDecoder ? new TextDecoder('utf8') : void 0
function B(b) {
if (b) {
for (var d = C, e = b + NaN, f = b; d[f] && !(f >= e); ) {
++f
}
if (16 < f - b && d.buffer && A) {
b = A.decode(d.subarray(b, f))
} else {
for (e = ''; b < f; ) {
var g = d[b++]
if (g & 128) {
var k = d[b++] & 63
if (192 == (g & 224)) {
e += String.fromCharCode(((g & 31) << 6) | k)
} else {
var v = d[b++] & 63
g = 224 == (g & 240) ? ((g & 15) << 12) | (k << 6) | v : ((g & 7) << 18) | (k << 12) | (v << 6) | (d[b++] & 63)
65536 > g ? (e += String.fromCharCode(g)) : ((g -= 65536), (e += String.fromCharCode(55296 | (g >> 10), 56320 | (g & 1023))))
}
} else {
e += String.fromCharCode(g)
}
}
b = e
}
} else {
b = ''
}
return b
}
var C
function D() {
var b = y.buffer
a.HEAP8 = new Int8Array(b)
a.HEAP16 = new Int16Array(b)
a.HEAP32 = new Int32Array(b)
a.HEAPU8 = C = new Uint8Array(b)
a.HEAPU16 = new Uint16Array(b)
a.HEAPU32 = new Uint32Array(b)
a.HEAPF32 = new Float32Array(b)
a.HEAPF64 = new Float64Array(b)
}
var E = [],
F = [],
G = []
function H() {
var b = a.preRun.shift()
E.unshift(b)
}
var I = 0,
J = null,
K = null
function x(b) {
if (a.onAbort) {
a.onAbort(b)
}
b = 'Aborted(' + b + ')'
u(b)
z = !0
b = new WebAssembly.RuntimeError(b + '. Build with -sASSERTIONS for more info.')
h(b)
throw b
}
var L
L = 'roaring-wasm-module.wasm'
if (!L.startsWith('data:application/octet-stream;base64,')) {
var M = L
L = a.locateFile ? a.locateFile(M, p) : p + M
}
function O(b) {
var d = L
try {
a: {
try {
if (d == L && w) {
var e = new Uint8Array(w)
break a
}
if (r) {
e = r(d)
break a
}
throw "sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"
} catch (k) {
x(k)
}
e = void 0
}
var f = new WebAssembly.Module(e)
var g = new WebAssembly.Instance(f, b)
} catch (k) {
throw ((b = k.toString()), u('failed to compile wasm module: ' + b), (b.includes('imported Memory') || b.includes('memory import')) && u('Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time).'), k)
}
return [g, f]
}
function P(b) {
for (; 0 < b.length; ) {
b.shift()(a)
}
}
var Q = {
a: function(b, d, e, f) {
x('Assertion failed: ' + B(b) + ', at: ' + [d ? B(d) : 'unknown filename', e, f ? B(f) : 'unknown function'])
},
c: function(b, d, e) {
C.copyWithin(b, d, d + e)
},
b: function(b) {
var d = C.length
b >>>= 0
if (2147483648 < b) {
return !1
}
for (var e = 1; 4 >= e; e *= 2) {
var f = d * (1 + 0.2 / e)
f = Math.min(f, b + 100663296)
var g = Math,
k = g.min
f = Math.max(b, f)
f += (65536 - (f % 65536)) % 65536
a: {
var v = y.buffer
try {
y.grow((k.call(g, 2147483648, f) - v.byteLength + 65535) >>> 16)
D()
var N = 1
break a
} catch (V) {}
N = void 0
}
if (N) {
return !0
}
}
return !1
}
},
R = (function() {
function b(e) {
a.asm = e.exports
y = a.asm.d
D()
I--
a.monitorRunDependencies && a.monitorRunDependencies(I)
0 == I && (null !== J && (clearInterval(J), (J = null)), K && ((e = K), (K = null), e()))
}
var d = { a: Q }
I++
a.monitorRunDependencies && a.monitorRunDependencies(I)
if (a.instantiateWasm) {
try {
return a.instantiateWasm(d, b)
} catch (e) {
u('Module.instantiateWasm callback failed with error: ' + e), h(e)
}
}
d = O(d)
b(d[0])
return a.asm
})()
a._free = R.e
a._roaring_bitmap_portable_size_in_bytes = R.f
a._roaring_bitmap_add_many = R.g
a._roaring_bitmap_add = R.h
a._roaring_bitmap_get_cardinality = R.i
a._roaring_bitmap_free = R.j
a._roaring_bitmap_remove = R.k
a._roaring_bitmap_and_inplace = R.l
a._roaring_bitmap_or_inplace = R.m
a._roaring_bitmap_xor_inplace = R.n
a._roaring_bitmap_andnot_inplace = R.o
a._roaring_bitmap_is_empty = R.p
a._roaring_bitmap_to_uint32_array = R.q
a._roaring_bitmap_serialize = R.r
a._roaring_bitmap_portable_serialize = R.s
a._roaring_bitmap_size_in_bytes = R.t
a._roaring_bitmap_portable_deserialize = R.u
a._roaring_bitmap_deserialize = R.v
a._roaring_bitmap_equals = R.w
a._roaring_bitmap_is_subset = R.x
a._roaring_bitmap_flip_inplace = R.y
a._roaring_bitmap_rank = R.z
a._roaring_bitmap_minimum = R.A
a._roaring_bitmap_maximum = R.B
a._roaring_bitmap_intersect = R.C
a._roaring_bitmap_and_cardinality = R.D
a._roaring_bitmap_jaccard_index = R.E
a._roaring_bitmap_or_cardinality = R.F
a._roaring_bitmap_andnot_cardinality = R.G
a._roaring_bitmap_xor_cardinality = R.H
a._roaring_bitmap_contains = R.I
a._roaring_bitmap_is_strict_subset = R.J
a._roaring_bitmap_portable_deserialize_frozen = R.K
a._malloc = R.L
a._roaring_bitmap_add_checked_js = R.M
a._roaring_bitmap_remove_checked_js = R.N
a._roaring_bitmap_optimize_js = R.O
a._roaring_bitmap_create_js = R.P
a._roaring_bitmap_select_js = R.Q
a._roaring_bitmap_deserialize_frozen_js = R.R
var S
K = function T() {
S || U()
S || (K = T)
}
function U() {
function b() {
if (!S && ((S = !0), (a.calledRun = !0), !z)) {
P(F)
c(a)
if (a.onRuntimeInitialized) {
a.onRuntimeInitialized()
}
if (a.postRun) {
for ('function' == typeof a.postRun && (a.postRun = [a.postRun]); a.postRun.length; ) {
var d = a.postRun.shift()
G.unshift(d)
}
}
P(G)
}
}
if (!(0 < I)) {
if (a.preRun) {
for ('function' == typeof a.preRun && (a.preRun = [a.preRun]); a.preRun.length; ) {
H()
}
}
P(E)
0 < I ||
(a.setStatus
? (a.setStatus('Running...'),
setTimeout(function() {
setTimeout(function() {
a.setStatus('')
}, 1)
b()
}, 1))
: b())
}
}
if (a.preInit) {
for ('function' == typeof a.preInit && (a.preInit = [a.preInit]); 0 < a.preInit.length; ) {
a.preInit.pop()()
}
}
U()
a.wasmMemory = y
return roaring_wasm_module
}
})()
if (typeof exports === 'object' && typeof module === 'object') module.exports = roaring_wasm_module
else if (typeof define === 'function' && define['amd'])
define([], function() {
return roaring_wasm_module
})
else if (typeof exports === 'object') exports['roaring_wasm_module'] = roaring_wasm_module