-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
- Version: v9.10.1
- Platform: Linux pca 4.15.13-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Sun Mar 25 11:27:57 UTC 2018 x86_64 GNU/Linux
- Subsystem: fs
I think it would be better to throw in the following case. The following case also causes every newly created read stream to end immediately.
$ node --experimental-modules a.mjs
with a.mjs
:
import fs from 'fs'
function length(rs){
return new Promise(res=>{
let a=[]
rs.on('data',[].push.bind(a))
rs.on('end',e=>{
res(Buffer.concat(a).length)
})
})
}
fs.writeFileSync('hello.txt','world')
;(async()=>{
// print 5 0 0
console.log(
await length(fs.createReadStream('hello.txt')),
await length(fs.createReadStream('hello.txt',{start:NaN,end:NaN})),
await length(fs.createReadStream('hello.txt')),
)
})()
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.