Variables
Const PROPS
PROPS: Set<string | number | symbol> = new Set<PropertyKey>([SYM_B,SYM_C,SYM_CV,SYM_EMPTY,SYM_EQD,SYM_L,SYM_O,SYM_S,SYM_STR,Symbol.iterator,])
Const SYM_B
SYM_B: "buf" = "buf"
Const SYM_C
SYM_C: "copy" = "copy"
Const SYM_CV
SYM_CV: "copyView" = "copyView"
Const SYM_EMPTY
SYM_EMPTY: "empty" = "empty"
Const SYM_EQD
SYM_EQD: "eqDelta" = "eqDelta"
Const SYM_L
SYM_L: "length" = "length"
Const SYM_O
SYM_O: "offset" = "offset"
Const SYM_S
SYM_S: "stride" = "stride"
Const SYM_STR
SYM_STR: "toString" = "toString"
Const keys
keys: (x: A) => B = memoize1<number, PropertyKey[]>((size: number) => [...map(String, range(size)),...PROPS,])
Wrapper for strided, arbitrary length vectors.
Wraps given buffer in ES6
Proxy
with custom property getters/setters and implements the following interfaces:Iterable
(ES6)Object.toString()
Read/write access for the following properties:
size
) intervaloffset
- start indexstride
- component stridebuf
- backing buffer (readonly)length
- vector sizeArray index access uses bounds checking against the [0 ..
size
) interval, but, for performance reasons, not against the actual wrapped buffer.Note: ES6 proxies are ~10x slower than standard array accesses. If several computations are to be performed on such vectors it will be much more efficient to first copy them to compact arrays and then copy result back if needed.
// 3D vector w/ stride length of 4 a = gvec([1,0,0,0,2,0,0,0,3,0,0,0], 3, 0, 4); a[0] // 1 a[1] // 2 a[2] // 3 a.stride // 4 [...a] // [1, 2, 3] a.toString() // "[1,2,3]" add([], a, a) // [2, 4, 6] copy(a) // [1, 2, 3] a.copyView() // Proxy [ [ 1, 0, 2, 0, 3, 0 ], ... } eqDelta(a, [1, 2, 3]) // true