node_py_struct
Version:
使用 ts 版的 nodejs 复刻 python 中的 struct
23 lines (13 loc) • 478 B
Markdown
使用 ts 版 nodejs 复刻 python 中的 struct, 目前只支持 pack,unpack,calcsize 方法
npm install node_py_struct
function pack(format: string, ...values: any[]): Buffer;
function unpack(fmt: string, buffer: Buffer | ArrayBuffer | Uint8Array | DataView): any[];
function calcsize(fmt: string): number;
```
import struct from "node_py_struct";
struct.pack("<i", 123, Buffer.from([3,4,5]));
```