Deno.write
🌙
手机阅读
本文目录结构
write
-
write(rid: number, data: Uint8Array): Promise<number>
-
将数组缓冲区 (
data
) 的内容写入资源 ID 的所属文件 (rid
) 。Write to the resource ID (
rid
) the contents of the array buffer (data
).解析为写入的字节数。
Resolves to the number of bytes written.
const encoder = new TextEncoder(); const data = encoder.encode("Hello world"); const file = await Deno.open("/foo/bar.txt"); const bytesWritten = await Deno.write(file.rid, data); // 11 Deno.close(file.rid);
参数
- ##### rid: number
- ##### data: Uint8Array