Augment a class so that instances can be encoded/decoded using a given layout.
Calling this function couples Class
with layout
in several ways:
Class.layout_
becomes a static member property equal to layout
;layout.boundConstructor_
becomes a static member property equal
to Class
;layout
is set to a function that returns a new Class()
;Class.decode(b, offset)
becomes a static member function that
delegates to {@link Layout#decode|layout.decode}. The
synthesized function may be captured and extended.Class.prototype.encode(b, offset)
provides an instance member
function that delegates to {@link Layout#encode|layout.encode}
with src
set to this
. The synthesized function may be
captured and extended, but when the extension is invoked this
must be explicitly bound to the instance.a JavaScript class with a nullary constructor.
the Layout instance used to encode
instances of Class
.
Factory for BitStructure values.
Factory for Blob values.
Factory for little-endian 32-bit floating point values.
Factory for big-endian 32-bit floating point values.
Factory for little-endian 64-bit floating point values.
Factory for big-endian 64-bit floating point values.
Factory for GreedyCount.
Factory for little-endian signed int layouts interpreted as Numbers.
Factory for big-endian signed int layouts interpreted as Numbers.
Factory for little-endian unsigned int layouts interpreted as Numbers.
Factory for big-endian unsigned int layouts interpreted as Numbers.
Factory for OffsetLayout.
Factory for little-endian signed int layouts spanning two bytes.
Factory for big-endian signed int layouts spanning two bytes.
Factory for little-endian signed int layouts spanning three bytes.
Factory for big-endian signed int layouts spanning three bytes.
Factory for little-endian signed int layouts spanning four bytes.
Factory for big-endian signed int layouts spanning four bytes.
Factory for little-endian signed int layouts spanning five bytes.
Factory for big-endian signed int layouts spanning five bytes.
Factory for little-endian signed int layouts spanning six bytes.
Factory for big-endian signed int layouts spanning six bytes.
Factory for signed int layouts spanning one byte.
Factory for Sequence values.
Factory for little-endian unsigned int layouts spanning two bytes.
Factory for big-endian unsigned int layouts spanning two bytes.
Factory for little-endian unsigned int layouts spanning three bytes.
Factory for big-endian unsigned int layouts spanning three bytes.
Factory for little-endian unsigned int layouts spanning four bytes.
Factory for big-endian unsigned int layouts spanning four bytes.
Factory for little-endian unsigned int layouts spanning five bytes.
Factory for big-endian unsigned int layouts spanning five bytes.
Factory for little-endian unsigned int layouts spanning six bytes.
Factory for big-endian unsigned int layouts spanning six bytes.
Factory for unsigned int layouts spanning one byte.
Factory for Union values.
Factory for UnionLayoutDiscriminator values.
Generated using TypeDoc
Support for translating between Uint8Array instances and JavaScript native types.
{@link module:Layout~Layout|Layout} is the basis of a class hierarchy that associates property names with sequences of encoded bytes.
Layouts are supported for these scalar (numeric) types:
and for these aggregate types:
Layout|Layout}, with JavaScript representation as an Array and constant or data-dependent {@link module:LayoutSequence#count|length};All {@link module:Layout~Layout|Layout} instances are immutable after construction, to prevent internal state from becoming inconsistent.
Layout
ExternalLayout
GreedyCount
OffsetLayout
UInt
UIntBE
Int
IntBE
NearUInt64
NearUInt64BE
NearInt64
NearInt64BE
Float
FloatBE
Double
DoubleBE
Sequence
Structure
UnionDiscriminator
UnionLayoutDiscriminator
Union
VariantLayout
BitStructure
BitField
Boolean
Blob
CString
Constant
bindConstructorLayout
MIT
Peter A. Bigot
buffer-layout on GitHub