Deno.readallsync
🌙
手机阅读
本文目录结构
readAllSync
-
readAllSync(r: SyncReader): Uint8Array
-
同步地读取 Reader
r
直到文件的末尾 (Deno.EOF
),返回文件的内容,以Uint8Array
表示。Synchronously reads Reader
r
until end of file (Deno.EOF
) and returns the content asUint8Array
.// Example:从 stdin 读取 const stdinContent = Deno.readAllSync(Deno.stdin);
// Example:从文件读取 const file = Deno.openSync("my_file.txt", {read: true}); const myFileContent = Deno.readAllSync(file); Deno.close(file.rid);
// Example:从 buffer 读取 const myData = new Uint8Array(100); //... 此处省略了填充 myData 数组的代码 const reader = new Deno.Buffer(myData.buffer as ArrayBuffer); const bufferContent = Deno.readAllSync(reader);
参数
- ##### r: [SyncReader](interfaces/deno.syncreader.html)