UNPKG

roaring-wasm-papandreou

Version:

WebAssembly port of Roaring Bitmaps for NodeJS

210 lines (209 loc) 6.52 kB
/// <reference types="node" /> /** * 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. * * @class RoaringUint32Array */ declare class RoaringUint32Array implements Iterable<number> { /** * The type of typed array used by this class. * For RoaringUint32Array is Uint32Array. * * @static * @property * @readonly * @type {typeof Uint32Array} * @memberof RoaringUint32Array */ static readonly TypedArray: typeof Uint32Array /** * The size in bytes of each element in the array. * For RoaringUint32Array is always 4 * * @static * @property * @readonly * @type {number} * @memberof RoaringUint32Array */ static readonly BYTES_PER_ELEMENT: 4 /** * The type of typed array used by this class. * For RoaringUint32Array is Uint32Array. * * @readonly * @property * @type {typeof Uint32Array} * @memberof RoaringUint32Array */ readonly TypedArray: typeof Uint32Array /** * The size in bytes of each element in the array. * For RoaringUint32Array is always 4 * * @readonly * @property * @type {number} * @memberof RoaringUint32Array */ readonly BYTES_PER_ELEMENT: 4 /** * 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. * * @readonly * @property * @type {ArrayBuffer} * @memberof RoaringUint32Array */ readonly buffer: ArrayBuffer /** * Returns true if this object was deallocated. * * @readonly * @property * @type {boolean} * @memberof RoaringUint32Array */ readonly isDisposed: boolean /** * The length in bytes of the array. * For RoaringUint32Array it is equal to this.length * 4 * * @readonly * @property * @type {number} * @memberof RoaringUint32Array */ readonly byteLength: number /** * 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. * * @readonly * @property * @type {TypedArray} * @memberof RoaringUint32Array */ readonly heap: Uint32Array /** * The offset in bytes of the array (the location of the first byte in WASM memory). * @readonly * @property * @type {number} * @memberof RoaringUint32Array */ readonly byteOffset: number /** * Number of elements allocated in this array. * * @readonly * @property * @type {number} * @memberof RoaringUint32Array */ readonly length: number /** * Allocates an array in the roaring WASM heap. * * Note: Memory is not garbage collected, you are responsible to free the allocated memory calling "dispose" method. * * If the parameter is a number, it creates a new uninitialized array of the given length. * If the parameter is an Iterable, it creates a copy of the given iterable. * * @constructor * @param {(number | Iterable<number>)} lengthOrArray Length of the array to allocate or the array to copy * @memberof RoaringUint32Array */ constructor(lengthOrArray: number | Iterable<number>, _pointer?: number) /** * Frees the allocated memory. * Is safe to call this method more than once. * * @returns {boolean} True if memory gets freed during this call, false if not. * @memberof RoaringUint32Array */ dispose(): boolean /** * Throws an error if the memory was freed. * * @readonly * @property * @returns {(void | never)} * @memberof RoaringUint32Array */ throwIfDisposed(): void | never /** * Writes the given array at the specified position * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. * @memberof RoaringUint32Array */ set(array: Iterable<number>, offset?: number): this /** * 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} A new typed array that shares the memory with this array. * @memberof RoaringUint32Array */ asTypedArray(): Uint32Array /** * 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} A new instance of NodeJS Buffer * @memberof RoaringUint32Array */ asNodeBuffer(): Buffer /** * 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} A new typed array that contains a copy of this buffer * @memberof RoaringUint32Array */ toTypedArray(): Uint32Array /** * 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} A new instance of NodeJS Buffer that contains a copy of this buffer * @memberof RoaringUint32Array */ toNodeBuffer(): Buffer /** * Copies the content of this typed array into a new JS array of numbers and returns it. * * @returns {number[]} A new array. * @memberof RoaringUint32Array */ toArray(): number[] /** * Copies the content of this typed array into a new JS Set<number> and returns it. * * @returns {number[]} A new array. * @memberof RoaringUint32Array */ toSet(): Set<number> /** * Returns a string representation of an array. * @memberof RoaringUint32Array */ toString(): string /** * Iterator that iterates through all values in the array. * * @returns {IterableIterator<number>} * @memberof RoaringUint32Array */ [Symbol.iterator](): IterableIterator<number> } export = RoaringUint32Array