diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 0dc86f1c0080fc..c9f975770bc6ae 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -510,6 +510,11 @@ console.log(buf2.toString()); ### Class Method: Buffer.alloc(size[, fill[, encoding]]) * `size` {integer} The desired length of the new `Buffer`. @@ -1253,6 +1258,19 @@ Example: Fill a `Buffer` with a two-byte character console.log(Buffer.allocUnsafe(3).fill('\u0222')); ``` +If `value` contains invalid characters, it is truncated; if no valid +fill data remains, no filling is performed: + +```js +const buf = Buffer.allocUnsafe(5); +// Prints: +console.log(buf.fill('a')); +// Prints: +console.log(buf.fill('aazz', 'hex')); +// Prints: +console.log(buf.fill('zz', 'hex')); +``` + ### buf.includes(value[, byteOffset][, encoding])