【发布时间】:2021-03-02 20:43:24
【问题描述】:
Deno 的文档似乎没有提到我如何执行以下二进制文件读取操作:
- 从二进制文件的开头寻找 p 的位置;
- 读取接下来的 4 个字节;
- 并将读取的内容转换为数字(32 位整数);
【问题讨论】:
标签: javascript deno
Deno 的文档似乎没有提到我如何执行以下二进制文件读取操作:
【问题讨论】:
标签: javascript deno
Deno.seek
file.read
DataView.getInt32
const file = await Deno.open('binary.file');
const p = 100; // your position
await Deno.seek(file.rid, p, Deno.SeekMode.Start);
const buf = new Uint8Array(4); // you can read more and then access a particular slice of the buffer
const bytesRead = await file.read(buf);
// ... do whatever operation you want with buf
【讨论】: