roaring-wasm-papandreou
Version:
WebAssembly port of Roaring Bitmaps for NodeJS
203 lines (202 loc) • 6.27 kB
TypeScript
/// <reference types="node" />
/**
* 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.
*
* @class RoaringUint8Array
*/
declare class RoaringUint8Array implements Iterable<number> {
/**
* The type of typed array used by this class.
* For RoaringUint8Array is Uint8Array.
*
* @static
* @readonly
* @property
* @type {typeof Uint8Array}
* @memberof RoaringUint8Array
*/
static readonly TypedArray: typeof Uint8Array
/**
* The size in bytes of each element in the array.
* For RoaringUint8Array is always 1
*
* @static
* @readonly
* @property
* @type {number}
* @memberof RoaringUint8Array
*/
static readonly BYTES_PER_ELEMENT: 1
/**
* The type of typed array used by this class.
* For RoaringUint8Array is Uint8Array.
*
* @readonly
* @property
* @type {typeof Uint8Array}
* @memberof RoaringUint8Array
*/
readonly TypedArray: typeof Uint8Array
/**
* The size in bytes of each element in the array.
* For RoaringUint8Array is always 1
*
* @readonly
* @property
* @type {number}
* @memberof RoaringUint8Array
*/
readonly BYTES_PER_ELEMENT: 1
/**
* 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 RoaringUint8Array
*/
readonly buffer: ArrayBuffer
/**
* Returns true if this object was deallocated.
*
* @readonly
* @property
* @type {boolean}
* @memberof RoaringUint8Array
*/
readonly isDisposed: boolean
/**
* The length in bytes of the array.
* For RoaringUint8Array it is equal to this.length
*
* @readonly
* @property
* @type {number}
* @memberof RoaringUint8Array
*/
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 RoaringUint8Array
*/
readonly heap: Uint8Array
/**
* The offset in bytes of the array (the location of the first byte in WASM memory).
* @readonly
* @property
* @type {number}
* @memberof RoaringUint8Array
*/
readonly byteOffset: number
/**
* Number of elements allocated in this array.
*
* @readonly
* @property
* @type {number}
* @memberof RoaringUint8Array
*/
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 RoaringUint8Array
*/
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 RoaringUint8Array
*/
dispose(): boolean
/**
* Throws an error if the memory was freed.
*
* @readonly
* @property
* @returns {(void | never)}
* @memberof RoaringUint8Array
*/
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 RoaringUint8Array
*/
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 {Uint8Array} A new typed array that shares the memory with this array.
* @memberof RoaringUint8Array
*/
asTypedArray(): Uint8Array
/**
* 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 RoaringUint8Array
*/
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 RoaringUint8Array
*/
toTypedArray(): Uint8Array
/**
* 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 RoaringUint8Array
*/
toNodeBuffer(): Buffer
/**
* Copies the content of this typed array into a standard JS array of numbers and returns it.
*
* @returns {number[]} A new array.
* @memberof RoaringUint8Array
*/
toArray(): number[]
/**
* Returns a string representation of an array.
* @memberof RoaringUint8Array
*/
toString(): string
/**
* Iterator that iterates through all values in the array.
*
* @returns {IterableIterator<number>}
* @memberof RoaringUint8Array
*/
[Symbol.iterator](): IterableIterator<number>
}
export = RoaringUint8Array