diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 1ad65494278b73..5a967b4569f1fd 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -788,6 +788,28 @@ const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); A `TypeError` will be thrown if `array` is not an `Array`. +`Buffer.from(array)` may also use the internal `Buffer` pool like +[`Buffer.allocUnsafe()`] does. + +```js +const nodeBuffers = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + +console.log(nodeBuffers.offset); +// prints: 344 + +// Default Buffer.poolsize is 8192 +console.log(Buffer.poolSize); +// prints: 8192 + +// But you can change it +Buffer.poolSize = 5; + +const buf = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + +console.log(buf.offset); +// prints: 0 +``` + ### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])