0.2.1 • Published 8 years ago
dynamic-typed-array v0.2.1
dynamic-typed-array
https://en.wikipedia.org/wiki/Dynamic_array
API:
class DynamicTypedArray<T extends TypedArray> {
constructor(constructor: TypedArrayConstructor<T> = Float64Array,
init: number | ArrayLike<number> | Iterable<number> = 0,
options: DynamicTypedArrayOptions = {});
size(): number;
capacity(): number;
get(index: number): number;
set(index: number, value: number): void;
push(...values: number[]): void;
pop(): number;
forEach(callback: (value: number, index: number) => void, thisArg?: any): void;
[Symbol.iterator](): IterableIterator<number>;
toArray(): number[];
toJSON(): number[];
toString(): string;
}
type TypedArray = ArrayBufferView & ArrayLike<number>;
type TypedArrayConstructor<T extends TypedArray> = {
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): T;
BYTES_PER_ELEMENT: number;
}
type GrowthPolicy = (minCapacity: number) => number;
type Allocator = (minByteLength: number) => ArrayBuffer;
type Deallocator = (buffer: ArrayBuffer) => void;
type Reallocator = (oldBuffer: ArrayBuffer, newByteLength: number,
allocator: Allocator, deallocator: Deallocator) => ArrayBuffer;
type DynamicTypedArrayOptions = {
growthPolicy?: GrowthPolicy;
allocator?: Allocator;
deallocator?: Deallocator;
reallocator?: Reallocator;
}