Check that data is exactly length bytes and return it as a
FixedBytes.
The byte counterpart to fixedArray: a fixed length is a literal
type, so a plain Uint8Array (length number) cannot be assigned to
FixedBytes<N> directly. This is the checked construction path.
Returns a copy, so later writes through the caller's reference cannot
change the bytes behind the result — the same caller-owned convention the
readers use for readFixedOpaque. Copying a view copies only that view's
range. Unlike fixedArray the result is not frozen: Object.freeze throws
on a non-empty typed array. Nothing is lost by that, since a Uint8Array's
length cannot change through an alias at all — only its contents, which the
copy already isolates.
Check that
datais exactlylengthbytes and return it as a FixedBytes.The byte counterpart to fixedArray: a fixed length is a literal type, so a plain
Uint8Array(lengthnumber) cannot be assigned toFixedBytes<N>directly. This is the checked construction path.Returns a copy, so later writes through the caller's reference cannot change the bytes behind the result — the same caller-owned convention the readers use for
readFixedOpaque. Copying a view copies only that view's range. UnlikefixedArraythe result is not frozen:Object.freezethrows on a non-empty typed array. Nothing is lost by that, since aUint8Array's length cannot change through an alias at all — only its contents, which the copy already isolates.