Deno.writeall
🌙
手机阅读
本文目录结构
writeAll
-
writeAll(w: Writer, arr: Uint8Array): Promise<void>
-
将所有 Array Buffer (
arr
)中的的内容写入到对象 (w
) 中。Write all the content of the array buffer (
arr
) to the writer (w
).// 举例:写入到 stdout const contentBytes = new TextEncoder().encode("Hello World"); await Deno.writeAll(Deno.stdout, contentBytes);
// 举例:写入到文件 const contentBytes = new TextEncoder().encode("Hello World"); const file = await Deno.open('test.file', {write: true}); await Deno.writeAll(file, contentBytes); Deno.close(file.rid);
// 举例:写入到 Buffer 对象 const contentBytes = new TextEncoder().encode("Hello World"); const writer = new Deno.Buffer(); await Deno.writeAll(writer, contentBytes); console.log(writer.bytes().length); // 11
参数
- ##### w: [Writer](interfaces/deno.writer.html)
- ##### arr: Uint8Array