mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Drop the bounded subarray case, remove the unnecessary error code check, and use a 2**31 byte Uint8Array directly instead of slicing an offset subarray. Signed-off-by: semimikoh <ejffjeosms@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62621 Fixes: https://github.com/nodejs/node/issues/62610 Refs: https://github.com/nodejs/node/pull/58070 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
27 lines
561 B
JavaScript
27 lines
561 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIf32Bits();
|
|
|
|
const assert = require('assert');
|
|
|
|
const encoder = new TextEncoder();
|
|
const source = 'a\xFF\u6211\u{1D452}';
|
|
const expected = encoder.encode(source);
|
|
|
|
let dest;
|
|
|
|
try {
|
|
dest = new Uint8Array(2 ** 31);
|
|
} catch {
|
|
common.skip('insufficient space for Uint8Array allocation');
|
|
}
|
|
|
|
const result = encoder.encodeInto(source, dest);
|
|
assert.deepStrictEqual(result, {
|
|
read: source.length,
|
|
written: expected.length,
|
|
});
|
|
assert.deepStrictEqual(dest.subarray(0, expected.length), expected);
|