dynamic-typed-array
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

dynamic-typed-array

NPM Build Status Coverage Status Dependency Status devDependency Status

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;
}

Package Sidebar

Install

npm i dynamic-typed-array

Weekly Downloads

0

Version

0.2.1

License

MIT

Last publish

Collaborators

  • maxdavidson