Node.js buffer write() Method
Example
Overwrite parts of an existing buffer:
var buf = Buffer.from('abcdef');
buf.write('qq', 2);
console.log(buf.toString());
Run example »
Definition and Usage
The write() method writes the specified string into a buffer, at the specified position.
Syntax
buffer.write(value, start, bytes, encoding);
Parameter Values
Parameter | Description |
---|---|
value | Required. The string to insert |
start | Optional. Where to start writing. Default 0 |
bytes | Optional. How many bytes to write. Default length of buffer minus start position |
encoding | Optional. The encoding of the value. Default 'utf8' |
Technical Details
Return Value: | A Number, representing the number of bytes written |
---|---|
Node.js Version: | 0.1.90 |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.