UNPKG

roaring-wasm-papandreou

Version:

WebAssembly port of Roaring Bitmaps for NodeJS

899 lines (569 loc) 33.9 kB
# roaring-wasm WebAssembly port of [Roaring Bitmaps](http://roaringbitmap.org) for NodeJS. It is interoperable with other implementations via the [Roaring format](https://github.com/RoaringBitmap/RoaringFormatSpec/). Roaring bitmaps are compressed bitmaps. They can be hundreds of times faster. ## motivation This project was born to use Roaring WASM in AWS Lambdas without the need to compile a node-gyp module. AWS Lambda supports node 8.10 and supports WASM. ## installation ```sh npm install --save roaring-wasm ``` Try it live - <https://npm.runkit.com/roaring-wasm> Code sample: ```javascript // npm install --save roaring-wasm // create this file as demo.js // type node demo.js or nodejs demo.js depending on your system var roaring = require("roaring-wasm"); var bitmap1 = new roaring.RoaringBitmap32() bitmap1.addMany([1, 2, 3, 4, 5, 100, 1000]) console.log("bitmap1.toSet():",bitmap1.toSet()) var bitmap2 = new roaring.RoaringBitmap32() bitmap2.addMany([3, 4, 1000]) console.log("bitmap2.toSet():",bitmap1.toSet()) var bitmap3 = new roaring.RoaringBitmap32() console.log("bitmap1.cardinality():", bitmap1.cardinality()) console.log("bitmap2.contains(3):",bitmap2.contains(3)) bitmap3.add(111) bitmap3.add(544) bitmap3.orInPlace(bitmap1) bitmap1.optimize() console.log(bitmap3.toString()) console.log("bitmap3.toArray():",bitmap3.toArray()) console.log("bitmap3.maximum():",bitmap3.maximum()) console.log("bitmap3.rank(100):",bitmap3.rank(100)) bitmap1.dispose() bitmap2.dispose() bitmap3.dispose() ``` ## references This package - <https://www.npmjs.com/package/roaring-wasm> Source code and build tools for this package - <https://github.com/SalvatorePreviti/roaring-wasm> Roaring Bitmaps - <http://roaringbitmap.org/> Portable Roaring bitmaps in C - <https://github.com/RoaringBitmap/CRoaring> emscripten - <https://github.com/kripken/emscripten/wiki> AWS Lambda - <https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html> # licenses - This package is provided as open source software using Apache License. - CRoaring is provided as open source software using Apache License. # API <!-- Generated by documentation.js. Update this documentation by updating the source code. --> ### Table of Contents - [RoaringBitmap32](#roaringbitmap32) - [xorCardinality](#xorcardinality) - [Parameters](#parameters) - [deserialize](#deserialize) - [Parameters](#parameters-1) - [deserialize](#deserialize-1) - [Parameters](#parameters-2) - [serializeArrayToNewBuffer](#serializearraytonewbuffer) - [Parameters](#parameters-3) - [deserializeToArray](#deserializetoarray) - [Parameters](#parameters-4) - [deserializeToSet](#deserializetoset) - [Parameters](#parameters-5) - [isDisposed](#isdisposed) - [dispose](#dispose) - [throwIfDisposed](#throwifdisposed) - [cardinality](#cardinality) - [isEmpty](#isempty) - [add](#add) - [Parameters](#parameters-6) - [addChecked](#addchecked) - [Parameters](#parameters-7) - [addMany](#addmany) - [Parameters](#parameters-8) - [remove](#remove) - [Parameters](#parameters-9) - [removeChecked](#removechecked) - [Parameters](#parameters-10) - [maximum](#maximum) - [minimum](#minimum) - [contains](#contains) - [Parameters](#parameters-11) - [isSubset](#issubset) - [Parameters](#parameters-12) - [isStrictSubset](#isstrictsubset) - [Parameters](#parameters-13) - [toRoaringUint32Array](#toroaringuint32array) - [toArray](#toarray) - [toSet](#toset) - [toUint32Array](#touint32array) - [equals](#equals) - [Parameters](#parameters-14) - [flipRange](#fliprange) - [Parameters](#parameters-15) - [optimize](#optimize) - [select](#select) - [Parameters](#parameters-16) - [andCardinality](#andcardinality) - [Parameters](#parameters-17) - [orCardinality](#orcardinality) - [Parameters](#parameters-18) - [andNotCardinality](#andnotcardinality) - [Parameters](#parameters-19) - [andInPlace](#andinplace) - [Parameters](#parameters-20) - [orInPlace](#orinplace) - [Parameters](#parameters-21) - [xorInPlace](#xorinplace) - [Parameters](#parameters-22) - [andNotInPlace](#andnotinplace) - [Parameters](#parameters-23) - [rank](#rank) - [Parameters](#parameters-24) - [intersects](#intersects) - [Parameters](#parameters-25) - [jaccardIndex](#jaccardindex) - [Parameters](#parameters-26) - [getSerializationSizeInBytes](#getserializationsizeinbytes) - [Parameters](#parameters-27) - [serializeToRoaringUint8Array](#serializetoroaringuint8array) - [Parameters](#parameters-28) - [serializeToUint8Array](#serializetouint8array) - [Parameters](#parameters-29) - [serializeToNodeBuffer](#serializetonodebuffer) - [Parameters](#parameters-30) - [RoaringUint32Array](#roaringuint32array) - [TypedArray](#typedarray) - [TypedArray](#typedarray-1) - [BYTES_PER_ELEMENT](#bytes_per_element) - [BYTES_PER_ELEMENT](#bytes_per_element-1) - [buffer](#buffer) - [isDisposed](#isdisposed-1) - [byteLength](#bytelength) - [heap](#heap) - [dispose](#dispose-1) - [throwIfDisposed](#throwifdisposed-1) - [set](#set) - [Parameters](#parameters-31) - [asTypedArray](#astypedarray) - [asNodeBuffer](#asnodebuffer) - [toTypedArray](#totypedarray) - [toNodeBuffer](#tonodebuffer) - [toArray](#toarray-1) - [toSet](#toset-1) - [toString](#tostring) - [iterator](#iterator) - [RoaringUint8Array](#roaringuint8array) - [TypedArray](#typedarray-2) - [TypedArray](#typedarray-3) - [BYTES_PER_ELEMENT](#bytes_per_element-2) - [BYTES_PER_ELEMENT](#bytes_per_element-3) - [buffer](#buffer-1) - [isDisposed](#isdisposed-2) - [byteLength](#bytelength-1) - [heap](#heap-1) - [dispose](#dispose-2) - [throwIfDisposed](#throwifdisposed-2) - [set](#set-1) - [Parameters](#parameters-32) - [asTypedArray](#astypedarray-1) - [asNodeBuffer](#asnodebuffer-1) - [toTypedArray](#totypedarray-1) - [toNodeBuffer](#tonodebuffer-1) - [toArray](#toarray-2) - [toString](#tostring-1) - [iterator](#iterator-1) ## RoaringBitmap32 A Roaring Bitmap that supports 32 bit unsigned integers. The roaring bitmap allocates in WASM memory, remember to dispose the RoaringBitmap32 when not needed anymore to release WASM memory. ### xorCardinality Computes the size of the symmetric difference (xor) between two bitmaps. Both bitmaps are unchanged. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Cardinality of the symmetric difference (xor) of two bitmaps. ### deserialize Creates a new roaring bitmap deserializing it from a buffer The roaring bitmap allocates in WASM memory, remember to dispose the RoaringBitmap32 when not needed anymore to release WASM memory. #### Parameters - `buffer` **([RoaringUint8Array](#roaringuint8array) \| [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Iterable&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** The buffer to deserialize - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, deserialization is compatible with the Java and Go versions of the library. If false, deserialization is compatible with the C version of the library. Default is false. (optional, default `false`) - `frozen` (optional, default `false`) Returns **[RoaringBitmap32](#roaringbitmap32)** The reulting bitmap. Remember to dispose the instance when finished using it. ### deserialize Reads a bitmap from a serialized version. Throws an error if deserialization failed. #### Parameters - `buffer` **([RoaringUint8Array](#roaringuint8array) \| [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Iterable&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, deserialization is compatible with the Java and Go versions of the library. If false, deserialization is compatible with the C version of the library. Default is false. (optional, default `false`) - `frozen` (optional, default `false`) Returns **void** ### serializeArrayToNewBuffer Utility function that serializes an array of uint32 to a new NodeJS buffer. The returned buffer is automatically garbage collected. #### Parameters - `values` **([RoaringUint32Array](#roaringuint32array) | Iterable&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, serialization is compatible with the Java and Go versions of the library. If false, serialization is compatible with the C version of the library. Default is false. (optional, default `false`) Returns **[Buffer](https://nodejs.org/api/buffer.html)** The NodeJS buffer containing the serialized data. ### deserializeToArray Utility function that deserializes a RoaringBitmap32 serialized in a buffer to an Array<number> of values. The array can be very big, be careful when you use this function. #### Parameters - `buffer` **([RoaringUint8Array](#roaringuint8array) \| [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Iterable&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** The buffer to deserialize. - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, deserialization is compatible with the Java and Go versions of the library. If false, deserialization is compatible with the C version of the library. Default is false. (optional, default `false`) Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** All the values in the bitmap. ### deserializeToSet Utility function that deserializes a RoaringBitmap32 serialized in a buffer to a Set<number> of values. The array can be very big, be careful when you use this function. #### Parameters - `buffer` **([RoaringUint8Array](#roaringuint8array) \| [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Iterable&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** The buffer to deserialize. - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, deserialization is compatible with the Java and Go versions of the library. If false, deserialization is compatible with the C version of the library. Default is false. (optional, default `false`) Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** All the values in the bitmap. ### isDisposed Returns true if this instance was disposed. Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) ### dispose Disposes this object freeing all WASM memory associated to it. Is safe to call this method more than once. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if disposed during this call, false if not. ### throwIfDisposed Throws an exception if this object was disposed before. Returns **(void | never)** ### cardinality Get the cardinality of the bitmap (number of elements). Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of elements in this bitmap. ### isEmpty Returns true if the bitmap has no elements. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the bitmap is empty. ### add Adds a 32 bit unsigned integer value. Values are unique, this function does nothing if the value already exists. #### Parameters - `value` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 32 bit unsigned integer to add in the set. ### addChecked Adds a 32 bit unsigned integer value checking if the bitmap changes. Use add() if you don't need to know if something changed. Values are unique, this function does nothing and returns false if the value already exists. #### Parameters - `value` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 32 bit unsigned integer to add in the set. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the bitmap changed, false if not. ### addMany Adds multiple values. Using this is faster than calling add() multiple times. Inserting ordered or partially ordered arrays is faster. #### Parameters - `values` **([RoaringUint32Array](#roaringuint32array) | Iterable&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** The values to add. ### remove Removes a value from the set. If the value does not exists, this function does nothing. #### Parameters - `value` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The value to remove. ### removeChecked Removes a value from the set checking if the bitmap changes. Use remove() if you don't need to know if something changed. If the value does not exists, this function does nothing and returns false. #### Parameters - `value` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 32 bit unsigned integer to remove from the set. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the bitmap changed, false if not. ### maximum Gets the maximum value stored in the bitmap. If the bitmap is empty, returns 0. Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The maximum 32 bit unsigned integer or 0 if empty. ### minimum Gets the minimum value stored in the bitmap. If the bitmap is empty, returns 0xFFFFFFFF Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The minimum 32 bit unsigned integer or 0xFFFFFFFF if empty. ### contains Checks whether the given value is contained in the set. #### Parameters - `value` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The value to look for. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if value exists in the set, false if not. ### isSubset Returns true if the bitmap is subset of the other. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** the other bitmap Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** ### isStrictSubset Returns true if this bitmap is strict subset of the other. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** The other bitmap Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if this bitmap is a strict subset of other ### toRoaringUint32Array Converts the bitmap to an array. The array may be very big, use this function with caution. The returned RoaringUint32Array is allocated in WASM memory and not garbage collected, it need to be freed manually calling dispose(). Returns **[RoaringUint32Array](#roaringuint32array)** The RoaringUint32Array. Remember to manually dispose to free the memory. ### toArray Converts the bitmap to a JS array. The resulting array may be very big, use this function with caution. Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** The array containing all values in the bitmap. ### toSet Converts the bitmap to a JS Set<number>. The resulting set may be very big, use this function with caution. Returns **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** The set containing all values in the bitmap. ### toUint32Array Converts the bitmap to a JS Uint32Array. The resulting array may be very big, use this function with caution. Returns **[Uint32Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array)** The array containing all values in the bitmap. ### equals Checks wether two roaring bitmap contains the same data. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the bitmaps contains the same data, false if not. ### flipRange Negates in place the bitmap within a specified interval. Areas outside the range are passed through unchanged. #### Parameters - `start` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Range start. - `end` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Range end. ### optimize Optimizes the bitmap releasing unused memory and compressing containers. Returns true if something changed. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if something changed. ### select If the size of the roaring bitmap is strictly greater than rank, then this function returns the element of given rank. Otherwise, it returns NaN. #### Parameters - `rank` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Element rank Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** element or NaN ### andCardinality Computes the size of the intersection between two bitmaps. Both bitmaps are unchanged. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Cardinality of the intersection between two bitmaps. ### orCardinality Computes the size of the union of two bitmaps. Both bitmaps are unchanged. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Cardinality of the union of two bitmaps. ### andNotCardinality Computes the size of the difference (andnot) of two bitmaps. Both bitmaps are unchanged. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Cardinality of the difference (andnot) of two bitmaps. ### andInPlace Intersects this bitmap with another. Removes the elements from this bitmap that don't exists in the other. Stores the result in this bitmap. The provided bitmap is not modified. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** ### orInPlace Adds the element of the other bitmap into this bitmap. Stores the result in this bitmap. The provided bitmap is not modified. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** ### xorInPlace Computes the difference between two bitmaps. Stores the result in this bitmap. The provided bitmap is not modified. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** ### andNotInPlace Compute the difference between this and the provided bitmap, writing the result in the current bitmap. The provided bitmap is not modified. #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** ### rank Returns the number of integers that are smaller or equal to the given value. #### Parameters - `value` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The value to rank Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The number of values smaller than the given value ### intersects Check whether the two bitmaps intersect (have at least one element in common). #### Parameters - `other` **[RoaringBitmap32](#roaringbitmap32)** The other bitmap. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if the two bitmaps intersects, false if not. ### jaccardIndex Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto distance, or the Jaccard similarity coefficient) See <https://en.wikipedia.org/wiki/Jaccard_index> The Jaccard index is undefined if both bitmaps are empty. #### Parameters - `other` Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The Jaccard index ### getSerializationSizeInBytes How many bytes are required to serialize this bitmap. #### Parameters - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, deserialization is compatible with the Java and Go versions of the library. If false, deserialization is compatible with the C version of the library. Default is false. (optional, default `false`) ### serializeToRoaringUint8Array Serializes a bitmap to a byte buffer allocated in WASM memory. The returned RoaringUint8Array is allocated in WASM memory and not garbage collected, it need to be freed manually calling dispose(). #### Parameters - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, serialization is compatible with the Java and Go versions of the library. If false, serialization is compatible with the C version of the library. Default is false. (optional, default `false`) Returns **[RoaringUint8Array](#roaringuint8array)** The RoaringUint8Array. Remember to manually dispose to free the memory. ### serializeToUint8Array Serializes a bitmap to a typed Uint8Array. The returned array is automatically garbage collected and there is no need to be disposed manually. #### Parameters - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, serialization is compatible with the Java and Go versions of the library. If false, serialization is compatible with the C version of the library. Default is false. (optional, default `false`) Returns **[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)** The Uint8Array that contains the serialized bitmap ### serializeToNodeBuffer Serializes a bitmap to a NodeJS buffer. The returned buffer is automatically garbage collected and there is no need to be disposed manually. #### Parameters - `portable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, serialization is compatible with the Java and Go versions of the library. If false, serialization is compatible with the C version of the library. Default is false. (optional, default `false`) Returns **[Buffer](https://nodejs.org/api/buffer.html)** The NodeJS Buffer that contains the serialized bitmap ## RoaringUint32Array Array of unsigned 32 bit integers allocted directly in roaring library WASM memory. Note: Memory is not garbage collected, you are responsible to free the allocated memory calling "dispose" method. ### TypedArray The type of typed array used by this class. For RoaringUint32Array is Uint32Array. ### TypedArray The type of typed array used by this class. For RoaringUint32Array is Uint32Array. ### BYTES_PER_ELEMENT The size in bytes of each element in the array. For RoaringUint32Array is always 4 Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) ### BYTES_PER_ELEMENT The size in bytes of each element in the array. For RoaringUint32Array is always 4 Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) ### buffer The ArrayBuffer instance referenced by the array. Note that the buffer may become invalid if the WASM allocated memory grows. When the WASM grows the preallocated memory this property will return the new allocated buffer. Use the returned buffer for short periods of time. Type: [ArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) ### isDisposed Returns true if this object was deallocated. Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) ### byteLength The length in bytes of the array. For RoaringUint32Array it is equal to this.length \* 4 Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) ### heap The full WASM heap in hich this array is allocated. Note that the buffer may become invalid if the WASM allocated memory grows. When the WASM grows the preallocated memory this property will return the new allocated buffer. Use the returned array for short periods of time. Type: [TypedArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) ### dispose Frees the allocated memory. Is safe to call this method more than once. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if memory gets freed during this call, false if not. ### throwIfDisposed Throws an error if the memory was freed. Returns **(void | never)** ### set Writes the given array at the specified position #### Parameters - `array` A typed or untyped array of values to set. - `offset` The index in the current array at which the values are to be written. ### asTypedArray Gets a new JS typed array instance that shares the memory used by this buffer. Note that the buffer may point to an outdated WASM memory if the WASM allocated memory grows while using the returned buffer. Use the returned array for short periods of time. Returns **[Uint32Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array)** A new typed array that shares the memory with this array. ### asNodeBuffer Gets a new NodeJS Buffer instance that shares the memory used by this buffer. Note that the buffer may point to an outdated WASM memory if the WASM allocated memory grows while using the returned buffer. Use the returned array for short periods of time. Returns **[Buffer](https://nodejs.org/api/buffer.html)** A new instance of NodeJS Buffer ### toTypedArray Copies the content of this buffer to a typed array. The returned array is garbage collected and don't need to be disposed manually. Returns **[TypedArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** A new typed array that contains a copy of this buffer ### toNodeBuffer Copies the content of this buffer to a NodeJS Buffer. The returned buffer is garbage collected and don't need to be disposed manually. Returns **[Buffer](https://nodejs.org/api/buffer.html)** A new instance of NodeJS Buffer that contains a copy of this buffer ### toArray Copies the content of this typed array into a new JS array of numbers and returns it. Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** A new array. ### toSet Copies the content of this typed array into a new JS Set<number> and returns it. Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** A new array. ### toString Returns a string representation of an array. ### iterator Iterator that iterates through all values in the array. Returns **IterableIterator&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** ## RoaringUint8Array Array of bytes allocted directly in roaring library WASM memory. Note: Memory is not garbage collected, you are responsible to free the allocated memory calling "dispose" method. ### TypedArray The type of typed array used by this class. For RoaringUint8Array is Uint8Array. ### TypedArray The type of typed array used by this class. For RoaringUint8Array is Uint8Array. ### BYTES_PER_ELEMENT The size in bytes of each element in the array. For RoaringUint8Array is always 1 Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) ### BYTES_PER_ELEMENT The size in bytes of each element in the array. For RoaringUint8Array is always 1 Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) ### buffer The ArrayBuffer instance referenced by the array. Note that the buffer may become invalid if the WASM allocated memory grows. When the WASM grows the preallocated memory this property will return the new allocated buffer. Use the returned buffer for short periods of time. Type: [ArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) ### isDisposed Returns true if this object was deallocated. Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) ### byteLength The length in bytes of the array. For RoaringUint8Array it is equal to this.length Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) ### heap The full WASM heap in hich this array is allocated. Note that the buffer may become invalid if the WASM allocated memory grows. When the WASM grows the preallocated memory this property will return the new allocated buffer. Use the returned array for short periods of time. Type: [TypedArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) ### dispose Frees the allocated memory. Is safe to call this method more than once. Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** True if memory gets freed during this call, false if not. ### throwIfDisposed Throws an error if the memory was freed. Returns **(void | never)** ### set Writes the given array at the specified position #### Parameters - `array` A typed or untyped array of values to set. - `offset` The index in the current array at which the values are to be written. ### asTypedArray Gets a new JS typed array instance that shares the memory used by this buffer. Note that the buffer may point to an outdated WASM memory if the WASM allocated memory grows while using the returned buffer. Use the returned array for short periods of time. Returns **[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)** A new typed array that shares the memory with this array. ### asNodeBuffer Gets a new NodeJS Buffer instance that shares the memory used by this buffer. Note that the buffer may point to an outdated WASM memory if the WASM allocated memory grows while using the returned buffer. Use the returned array for short periods of time. Returns **[Buffer](https://nodejs.org/api/buffer.html)** A new instance of NodeJS Buffer ### toTypedArray Copies the content of this buffer to a typed array. The returned array is garbage collected and don't need to be disposed manually. Returns **[TypedArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** A new typed array that contains a copy of this buffer ### toNodeBuffer Copies the content of this buffer to a NodeJS Buffer. The returned buffer is garbage collected and don't need to be disposed manually. Returns **[Buffer](https://nodejs.org/api/buffer.html)** A new instance of NodeJS Buffer that contains a copy of this buffer ### toArray Copies the content of this typed array into a standard JS array of numbers and returns it. Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** A new array. ### toString Returns a string representation of an array. ### iterator Iterator that iterates through all values in the array. Returns **IterableIterator&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>**