I am reading a file to buffer like:
var myfile = fs.readFileSync(myfile.txt);
What is the proper way to replace some string to another in myfile
buffer? I would like to keep it as buffer, because it is faster than to keep it as string.
var buf = new Buffer("Simply Easy Learning", "utf-8"); Though "utf8" is the default encoding, you can use any of the following encodings "ascii", "utf8", "utf16le", "ucs2", "base64" or "hex".
Buffer() is deprecated due to security and usability issues (v2. 0.0)
js buffer copy() Method.
The toJSON() method returns a JSON object based on the Buffer object.
The package buffer-replace https://www.npmjs.com/package/buffer-replace replaces content in a buffer like the function replace for String.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With