Expand description
JavaScript typed arrays (Uint8Array/Int8Array/…/Float64Array),
ArrayBuffer, WeakRef, and TextEncoder/TextDecoder.
A typed array is a plain object tagged @@native = "TypedArray" carrying its
kind (@@kind), its elements as a hidden @@elems array of numbers, and the
enumerable length/byteLength/BYTES_PER_ELEMENT data properties JS code
reads directly. Element indexing (ta[i] get/set) is special-cased in
builtins::get_property/set_property via elem_get/elem_set here, which
also apply each kind’s coercion (integer wrap / clamp / float).
WeakRef holds a strong reference (deref() always returns the target) —
node-js has no GC of JS objects, so this is observably correct for the
express dependency tree (object-inspect/qs/side-channel only ever deref()).
Constants§
- ELEMENT_
KINDS - The element kinds, each of which gets its own real prototype object whose
parent is the shared
%TypedArray%.prototype.Uint8Arrayleads becauseBuffer.prototypechains onto it. - PROTOTYPE_
METHODS - The methods installed on the real
Uint8Array.prototypeobject (as@proto:Uint8Array:<m>thunks), soUint8Array.prototype.slice.call(x)keeps working now that the prototype is an object rather than aBuiltinnamespace whose every property read synthesized a thunk. - STATIC_
METHODS
Functions§
- bytes_
per_ element - Bytes per element for a typed-array kind.
- construct
new Uint8Array(...)etc.ArrayBufferis a byte container with only abyteLength.- construct_
finalization_ registry - construct_
text_ decoder - construct_
text_ encoder - construct_
weakref - elem_
get ta[i]read: the element at char/indexi, orNoneifiis out of range or not an integer index.- elem_
set ta[i] = vwrite (coerced to the kind). Returns true ifiis a valid index.- elem_
values - The element values of a typed array / Buffer as stored —
Value, notf64, so a 64-bit view keeps its BigInts.elems_ofis the numeric view of the same data and stays, becauseBufferreads bytes through it. - elems_
of - The element values of a typed array / Buffer (
Nonefor anything else). - finalization_
registry_ call - has_
index - Whether
keyis an in-range integer index of the typed array / Bufferv.Nonewhenvis neither, so callers can fall through to their own logic. - index_
len - The number of elements
vexposes as integer-index own properties, for a typed array (@@elems) or aBuffer(@@bytes);Nonefor anything else. - instance_
call - Typed-array instance methods.
- is_
bigint_ kind - Whether
kindstores BigInt elements rather than Numbers. The two 64-bit views are the only ones: their elements do not fit anf64without loss, so the whole element pipeline carriesValuerather thanf64. - is_ctor
- The eleven element kinds plus
ArrayBuffer(which carries only a byte length). - kind_of
- The
@@kindof a typed-array receiver (defaults toUint8Array). - static_
call Uint8Array.from(iterable[, mapFn])/Uint8Array.of(...items).- text_
decoder_ call - text_
encoder_ call - weakref_
call