KIT

FixedSizeEncoder

一个可以将 TFrom 类型的值编码为固定大小的 ReadonlyUint8Array 的对象。

查看 Encoder 以了解更多关于创建和组合编码器的信息。

示例

const encoder: FixedSizeEncoder<number, 4>;
const bytes = encoder.encode(42);
const size = encoder.fixedSize; // 4

参见

类型参数

类型参数默认类型描述
TFrom-要编码的值的类型。
TSize extends numbernumber编码后的值的大小(以字节为单位)。

属性

属性修饰符类型描述
encodereadonly(value) => ReadonlyUint8Array编码提供的值并直接返回编码后的字节。
fixedSizereadonlyTSize编码后的值的固定大小(以字节为单位)。
writereadonly(value, bytes, offset) => number将编码后的值写入到给定偏移量处的提供的字节数组中。返回编码后的值之后的下一个字节的偏移量。

On this page