OK, firstly ,where's the new documentation of new V8 js module ?
Secondly, I think, loop read small piece of file will cause too much I/O request . SO , i usually do read in following way.
open the file ----> get file size --> read the whole file ( OS will charge the "one time " read size).
and in real-life , real-project , there's not so many big files. So, just open the file ,and read all. in 99.99% situation , it's safe.
in some situation , you cann't open the "incomplete file" , you even cann't "see" them. There's too much detail when we talk about file read ,we can discuss file-system in rest of our life.
For Faruq , i think just read whole file is ok . if you warry about "incomplete file" ,just wait 1 second ,and read the file size again. it's may casuse delay ,but useful if you have lots of files to read .
In my opinion, when linux do file read ,it read 1 block one time . A block is a sequence of bit or Bytes with a fixed length ie 512 bytes, 4kB, 8kB, 16kB, 32kB etc. So , please not use strange number as your read size. it's not a good idea. And ......I really hate "while (.....)" code ,it's really really bad.
Raymond
At 2017-06-24 04:00:36, "Anthony Minessale" <anthony.minessale@gmail.com> wrote:
That wiki documentation is from the old spidermonkey js module not the new v8 one.
I believe that putting a very large number will not cause any problems as the data read cannot exceed the total bytes in the file so it should not be a problem.
You can always do an append loop. Its usually a good practice to have a precise max size to read because what if the file was accidentally 2gb.