Skip to content

Commit

Permalink
buffer: fix MAX_LENGTH constant export
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
addaleax authored and MylesBorins committed Sep 10, 2017
1 parent c417ceb commit 8b1bbe3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exports.kMaxLength = binding.kMaxLength;

const constants = Object.defineProperties({}, {
MAX_LENGTH: {
value: binding.kStringMaxLength,
value: binding.kMaxLength,
writable: false,
enumerable: true
},
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-buffer-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);

0 comments on commit 8b1bbe3

Please sign in to comment.