structurae
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -7,2 +7,6 @@ # Changelog | ||
## [1.3.0] - 2019-06-15 | ||
### Added | ||
- ObjectView, ArrayView, and TypedArrayView classes | ||
## [1.2.1] - 2019-06-10 | ||
@@ -9,0 +13,0 @@ ### Fix |
@@ -5,9 +5,13 @@ // Type definitions for structurae | ||
type Collection = any[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | | ||
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | | ||
Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; | ||
type CollectionConstructor = ArrayConstructor | Int8ArrayConstructor | Uint8ArrayConstructor | ||
type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | ||
| Uint8ClampedArrayConstructor | Int16Array | Uint16ArrayConstructor | Int32ArrayConstructor | ||
| Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor; | ||
type Collection = any[] | TypedArray; | ||
type CollectionConstructor = ArrayConstructor | TypedArrayConstructor; | ||
interface Constructor<T> { | ||
@@ -199,5 +203,5 @@ new (...args): T; | ||
get(index: number, field: string): any; | ||
getArray(offset: number, size: number, type: string): StringView; | ||
getArray(offset: number, size: number, type: string): Collection; | ||
getString(offset: number, size: number): StringView; | ||
set(index: number, field: string, value: any, littleEndian?: boolean): this; | ||
set(index: number, field: string, value: any): this; | ||
setArray(offset: number, value: Collection, size: number, type: string): void; | ||
@@ -210,2 +214,84 @@ setString(offset: number, value: Collection, size: number): void; | ||
type ViewType = typeof ArrayView | typeof ObjectView | typeof TypedArrayView | typeof StringView; | ||
type ArrayViewType = typeof ArrayView | typeof TypedArrayView; | ||
type View = ObjectView | ArrayView | TypedArrayView | StringView; | ||
type ObjectViewFieldType = 'int8' | 'uint8' | 'int16' | 'uint16' | ||
| 'int32' | 'uint32' | 'float32' | 'float64' | ||
| 'bigint64' | 'biguint64' | 'string' | ViewType; | ||
interface ObjectViewField { | ||
type: ObjectViewFieldType; | ||
size?: number; | ||
littleEndian?: boolean; | ||
start?: number; | ||
length?: number; | ||
ctor?: ViewType; | ||
} | ||
interface ObjectViewSchema { | ||
[propName: string]: ObjectViewField; | ||
} | ||
export declare class ObjectView extends DataView { | ||
size: number; | ||
private byteView: Uint8Array; | ||
static fields: string[]; | ||
static schema: ObjectViewSchema; | ||
static isInitialized: boolean; | ||
constructor(buffer?: ArrayBuffer, byteOffset?: number, byteLength?: number); | ||
get(field: string): number | View; | ||
private getObject(field: string, length: number, Ctor: ViewType): View; | ||
set(field: string, value: any): this; | ||
private setArray(start: number, value: ArrayView | TypedArrayView | ArrayLike<number>, length: number, Ctor: ArrayViewType): this; | ||
private setObject(start: number, value: ObjectView | Object, length: number, Ctor: typeof ObjectView): this; | ||
private setString(start: number, value: StringView | string, length: number): this; | ||
toObject(): object; | ||
static from(object: object, objectView?: ObjectView): ObjectView; | ||
static getLength(): number; | ||
static initialize(): void; | ||
} | ||
export declare class ArrayView extends DataView { | ||
size: number; | ||
private byteView: Uint8Array; | ||
constructor(sizeOrBuffer?: ArrayBuffer | number, byteOffset?: number, byteLength?: number); | ||
get(index: number): ObjectView; | ||
set(index: string, value: ObjectView | object): this; | ||
toObject(): object; | ||
static from(value: ArrayLike<object>, array?: ArrayView): ArrayView; | ||
static getLength(size: number): number; | ||
} | ||
export declare function ArrayViewMixin(ViewClass: typeof ObjectView): typeof ArrayView; | ||
export declare class TypedArrayView extends DataView { | ||
size: number; | ||
private byteView: Uint8Array; | ||
static typeGetter: string; | ||
static typeSetter: string; | ||
static offset: number; | ||
constructor(sizeOrBuffer?: ArrayBuffer | number, byteOffset?: number, byteLength?: number); | ||
get(index: number): number; | ||
set(index: string, value: number): this; | ||
toObject(): object; | ||
static from(value: ArrayLike<number>, array?: TypedArrayView): TypedArrayView; | ||
static getLength(size: number): number; | ||
} | ||
export declare class Int8View extends TypedArrayView {} | ||
export declare class Uint8View extends TypedArrayView {} | ||
export declare class Int16View extends TypedArrayView {} | ||
export declare class Uint16View extends TypedArrayView {} | ||
export declare class Int32View extends TypedArrayView {} | ||
export declare class Uint32View extends TypedArrayView {} | ||
export declare class Float32View extends TypedArrayView {} | ||
export declare class Float64View extends TypedArrayView {} | ||
export declare class BigInt64View extends TypedArrayView {} | ||
export declare class BigUint64View extends TypedArrayView {} | ||
export declare class BitArray extends Uint32Array { | ||
@@ -212,0 +298,0 @@ size: number; |
@@ -16,2 +16,4 @@ const BitField = require('./lib/bit-field'); | ||
const WeightedAdjacencyMatrixMixin = require('./lib/weighted-adjacency-matrix'); | ||
const ArrayViewMixin = require('./lib/array-view'); | ||
const ObjectView = require('./lib/object-view'); | ||
@@ -49,2 +51,4 @@ /** | ||
WeightedAdjacencyMatrixMixin, | ||
ArrayViewMixin, | ||
ObjectView, | ||
}; |
/** | ||
* @typedef {ArrayConstructor| | ||
* Int8ArrayConstructor| | ||
* Int8ArrayConstructor| | ||
* Uint8ArrayConstructor| | ||
* Uint8ClampedArrayConstructor| | ||
* Int16ArrayConstructor| | ||
* Uint16ArrayConstructor| | ||
* Int32ArrayConstructor| | ||
* Uint32ArrayConstructor| | ||
* Float32ArrayConstructor| | ||
* Float64ArrayConstructor} CollectionConstructor | ||
* @typedef {Int8ArrayConstructor | | ||
* Int8ArrayConstructor | | ||
* Uint8ArrayConstructor | | ||
* Uint8ClampedArrayConstructor | | ||
* Int16ArrayConstructor | | ||
* Uint16ArrayConstructor | | ||
* Int32ArrayConstructor | | ||
* Uint32ArrayConstructor | | ||
* Float32ArrayConstructor | | ||
* Float64ArrayConstructor} TypedArrayConstructor | ||
*/ | ||
/** | ||
* @typedef {Array| | ||
* Int8Array| | ||
* Uint8Array| | ||
* Uint8ClampedArray| | ||
* Int16Array| | ||
* Uint16Array| | ||
* Int32Array| | ||
* Uint32Array| | ||
* Float32Array| | ||
* Float64Array} Collection | ||
* @typedef {ArrayConstructor|TypedArrayConstructor} CollectionConstructor | ||
*/ | ||
/** | ||
* @typedef {Int8Array | | ||
* Uint8Array | | ||
* Uint8ClampedArray | | ||
* Int16Array | | ||
* Uint16Array | | ||
* Int32Array | | ||
* Uint32Array | | ||
* Float32Array | | ||
* Float64Array} TypedArray | ||
*/ | ||
/** | ||
* @typedef {Array|TypedArray} Collection | ||
*/ | ||
/** | ||
* @typedef {Object} Coordinates | ||
@@ -30,0 +36,0 @@ * @property {number} row row index |
{ | ||
"name": "structurae", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Data structures for performance-sensitive modern JavaScript applications.", | ||
@@ -48,3 +48,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/jest": "^24.0.13", | ||
"@types/jest": "^24.0.14", | ||
"benchmark": "^2.1.4", | ||
@@ -51,0 +51,0 @@ "codecov": "^3.5.0", |
181909
27
5137