filehandle.readableWebStream()
添加于:v17.0.0
Stability: 1 - 实验性
- 返回: <ReadableStream>
返回可用于读取文件数据的ReadableStream
。
如果多次调用此方法或在关闭或关闭FileHandle
之后调用此方法,则会引发错误。
import { open, } from 'node:fs/promises'; const file = await open('./some/file/to/read'); for await (const chunk of file.readableWebStream()) console.log(chunk); await file.close();
const { open, } = require('node:fs/promises'); (async () => { const file = await open('./some/file/to/read'); for await (const chunk of file.readableWebStream()) console.log(chunk); await file.close(); })();
虽然ReadableStream
将读取文件完成,但它不会自动关闭FileHandle
。用户代码仍必须调用fileHandle.close()
方法。
相关用法
- Node.js FileHandle.truncate(len)用法及代码示例
- Node.js FileHandle.close()用法及代码示例
- Node.js FileHandle.createReadStream([options])用法及代码示例
- Node.js MySQL FIELD()用法及代码示例
- Node.js MySQL FIND_IN_SET()用法及代码示例
- Node.js MySQL FORMAT()用法及代码示例
- Node.js ServerHttp2Stream http2stream.pushStream(headers[, options], callback)用法及代码示例
- Node.js http2.Http2ServerRequest request.url用法及代码示例
- Node.js request.socket用法及代码示例
- Node.js assert.notEqual(actual, expected[, message])用法及代码示例
- Node.js tlsSocket.authorized用法及代码示例
- Node.js zlib.deflateRaw()用法及代码示例
- Node.js http.IncomingMessage message.rawHeaders用法及代码示例
- Node.js Console用法及代码示例
- Node.js GM transparent()用法及代码示例
- Node.js URL.protocol用法及代码示例
- Node.js http.Agent.reuseSocket(socket, request)用法及代码示例
- Node.js fs.filehandle.datasync()用法及代码示例
- Node.js socket.bind()用法及代码示例
- Node.js v8.getHeapSpaceStatistics()用法及代码示例
- Node.js http2session.destroyed用法及代码示例
- Node.js http.ServerResponse response.statusCode用法及代码示例
- Node.js Buffer buf.writeBigUInt64BE(value[, offset])用法及代码示例
- Node.js Http2ServerResponse.finished用法及代码示例
- Node.js Http2Stream close用法及代码示例
注:本文由纯净天空筛选整理自nodejs.org大神的英文原创作品 FileHandle.readableWebStream()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。