Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.
Description
- Version: v4.5.0
- Platform: Linux *** 3.13.0-95-generic docs: Supplement docs for Writable and Transform streams #142-Ubuntu SMP Fri Aug 12 17:00:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: fs
I'm using read(2) to read 2 byte data of a file, and I found that the read(2) method trigger readable event twice if the file I'm reading is small (in my case, the file is 14 bytes). however, if the file I read from is large (1.3 GB, in my case), the read(2) method will only trigger readable event once.
Here is the code:
constfs=require('fs');varaBigFile=fs.createReadStream("/home/kt/ubuntu-gnome-16.04.1-desktop-amd64.iso");varaSmallFile=fs.createReadStream("/home/kt/1.txt");varchunkCount=0;varbigFileChunkCount=0;aSmallFile.on('readable',()=>{console.log(`[${chunkCount++}]smallfile:`,aSmallFile.read(2));});aBigFile.on('readable',()=>{console.log(`[${bigFileChunkCount++}]bigfile:`,aBigFile.read(2));});and the output goes:
[0]bigfile: <Buffer 4b 44> [0]smallfile: <Buffer 61 e4> [1]smallfile: <Buffer bd a0> Metadata
Metadata
Assignees
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.