Skip to content

Commit bda5585

Browse files
addaleaxMylesBorins
authored andcommitted
buffer: fix MAX_LENGTH constant export
This was a typo and accidentally returned the wrong value. Fixes: #14819 Ref: #13467 PR-URL: #14821 Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 8c61b72 commit bda5585

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/buffer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ exports.kMaxLength = binding.kMaxLength;
4747

4848
const constants = Object.defineProperties({}, {
4949
MAX_LENGTH: {
50-
value: binding.kStringMaxLength,
50+
value: binding.kMaxLength,
5151
writable: false,
5252
enumerable: true
5353
},

test/parallel/test-buffer-constants.js

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require('../common');
33
const assert = require('assert');
44

5+
const { kMaxLength, kStringMaxLength } = require('buffer');
56
const { MAX_LENGTH, MAX_STRING_LENGTH } = require('buffer').constants;
67

78
assert.strictEqual(typeof MAX_LENGTH, 'number');
@@ -11,3 +12,7 @@ assert.throws(() => ' '.repeat(MAX_STRING_LENGTH + 1),
1112
/^RangeError: Invalid string length$/);
1213

1314
assert.doesNotThrow(() => ' '.repeat(MAX_STRING_LENGTH));
15+
16+
// Legacy values match:
17+
assert.strictEqual(kMaxLength, MAX_LENGTH);
18+
assert.strictEqual(kStringMaxLength, MAX_STRING_LENGTH);

0 commit comments

Comments
 (0)