JSPM

dynamic-typed-array

0.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q24904F
  • License MIT

Dynamically growing typed arrays

Package Exports

  • dynamic-typed-array

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dynamic-typed-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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