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