buffer: fix MAX_LENGTH constant export
This was a typo and accidentally returned the wrong value. Fixes: https://github.com/nodejs/node/issues/14819 Ref: https://github.com/nodejs/node/pull/13467 PR-URL: https://github.com/nodejs/node/pull/14821 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
f853baf544
commit
9ecc440642
@ -76,7 +76,7 @@ Buffer.prototype = FastBuffer.prototype;
|
||||
|
||||
const constants = Object.defineProperties({}, {
|
||||
MAX_LENGTH: {
|
||||
value: kStringMaxLength,
|
||||
value: kMaxLength,
|
||||
writable: false,
|
||||
enumerable: true
|
||||
},
|
||||
|
@ -2,6 +2,7 @@
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const { kMaxLength, kStringMaxLength } = require('buffer');
|
||||
const { MAX_LENGTH, MAX_STRING_LENGTH } = require('buffer').constants;
|
||||
|
||||
assert.strictEqual(typeof MAX_LENGTH, 'number');
|
||||
@ -11,3 +12,7 @@ assert.throws(() => ' '.repeat(MAX_STRING_LENGTH + 1),
|
||||
/^RangeError: Invalid string length$/);
|
||||
|
||||
assert.doesNotThrow(() => ' '.repeat(MAX_STRING_LENGTH));
|
||||
|
||||
// Legacy values match:
|
||||
assert.strictEqual(kMaxLength, MAX_LENGTH);
|
||||
assert.strictEqual(kStringMaxLength, MAX_STRING_LENGTH);
|
||||
|
Loading…
x
Reference in New Issue
Block a user