Browse Source

doc: increase Buffer.concat() documentation

This commit adds documentation for two edge cases in
Buffer.concat(). Those cases are:

- totalLength is specified, but is not an integer.
- The combined buffer length is greater than totalLength.

PR-URL: https://github.com/nodejs/node/pull/11845
Fixes: https://github.com/nodejs/node/issues/11605
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
v6
cjihrig 8 years ago
committed by James M Snell
parent
commit
db39273a8a
  1. 4
      doc/api/buffer.md

4
doc/api/buffer.md

@ -755,6 +755,10 @@ in `list`. This however causes an additional loop to be executed in order to
calculate the `totalLength`, so it is faster to provide the length explicitly if calculate the `totalLength`, so it is faster to provide the length explicitly if
it is already known. it is already known.
If `totalLength` is provided, it is coerced to an unsigned integer. If the
combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
truncated to `totalLength`.
Example: Create a single `Buffer` from a list of three `Buffer` instances Example: Create a single `Buffer` from a list of three `Buffer` instances
```js ```js

Loading…
Cancel
Save