[nodejs] Buffer.write - Is there an efficient way to get the last index of the string that was written to the buffer

2016-01-23 Thread Chethiya Abeysinghe
This question is regarding this : https://nodejs.org/api/buffer.html#buffer_buf_write_string_offset_length_encoding In case Buffer has no enough space to fit in all the bytes this function returns the number of bytes it could write to the buffer. But is there an efficient way to find last index

[nodejs] JSON.parse(Buffer) works! Is that true?

2016-02-03 Thread Chethiya Abeysinghe
Following works in nodejs 4.2.3. But I don't see any documentation saying JSON.parse() accepts a buffer. Is this behavior guaranteed but not documented oris there something I'm doing wrong? o = {"tes": 1, "4 byte utf8": "𠜎 𠜱 𠝹 𠱓"};// { tes: 1, '4 byte utf8': '𠜎 𠜱 𠝹 𠱓' } buffer = new Buffer

[nodejs] Re: Is file closing explicitly needed after fs.readFileSync()?

2019-10-28 Thread Chethiya Abeysinghe
Hi On Wednesday, October 23, 2019 at 9:15:02 PM UTC+5:30, Peng Yu wrote: > > I'd like to fs.writeFileSync() to the same file after reading its content > by fs.readFileSync(). It is not clear to me whether fs.closeSync() (or any > other file closing function) is needed between writeFileSync() and