Skip to content

Commit c3278c8

Browse files
committed
doc: align Buffer.concat documentation with behavior
1 parent 2bda7cb commit c3278c8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

doc/api/buffer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ If the list has no items, or if the `totalLength` is 0, then a new zero-length
10391039
If `totalLength` is not provided, it is calculated from the `Buffer` instances
10401040
in `list` by adding their lengths.
10411041

1042-
If `totalLength` is provided, it is coerced to an unsigned integer. If the
1042+
If `totalLength` is provided, it must be an unsigned integer. If the
10431043
combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
10441044
truncated to `totalLength`. If the combined length of the `Buffer`s in `list` is
10451045
less than `totalLength`, the remaining space is filled with zeros.

test/parallel/test-buffer-concat.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ assert.throws(() => {
7272
'or Uint8Array. Received type number (3)'
7373
});
7474

75+
assert.throws(() => {
76+
Buffer.concat([Buffer.from('hello')], 3.5);
77+
}, {
78+
code: 'ERR_OUT_OF_RANGE',
79+
message: 'The value of "length" is out of range. It must be an integer. ' +
80+
'Received 3.5'
81+
});
82+
7583
// eslint-disable-next-line node-core/crypto-check
7684
const random10 = common.hasCrypto ?
7785
require('crypto').randomBytes(10) :

0 commit comments

Comments
 (0)