diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 58d425489ed..17886539013 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1254,6 +1254,19 @@ Example: Fill a `Buffer` with a two-byte character console.log(Buffer.allocUnsafe(3).fill('\u0222')); ``` +If `value` is 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])