Skip to content

Commit 4a19062

Browse files
JacksonTianevanlucas
authored andcommitted
test: replace [].join() with ''.repeat()
Replace [].join calls with the more modern .repeat PR-URL: #12305 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
1 parent 4ce58bd commit 4a19062

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/parallel/test-child-process-send-utf8.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const common = require('../common');
33
const assert = require('assert');
44
const fork = require('child_process').fork;
55

6-
const expected = Array(1e5).join('ßßßß');
6+
const expected = 'ßßßß'.repeat(1e5 - 1);
77
if (process.argv[2] === 'child') {
88
process.send(expected);
99
} else {

test/parallel/test-stringbytes-external.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ assert.strictEqual(b[1], 0);
2323
assert.strictEqual(ucs2_control, c);
2424

2525
// now create big strings
26-
const size = 1 + (1 << 20);
27-
write_str = Array(size).join(write_str);
28-
ucs2_control = Array(size).join(ucs2_control);
26+
const size = 1 << 20;
27+
write_str = write_str.repeat(size);
28+
ucs2_control = ucs2_control.repeat(size);
2929

3030
// check resultant buffer and output string
3131
b = Buffer.from(write_str, 'ucs2');
@@ -110,7 +110,7 @@ const PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS;
110110

111111
// https://github.com/nodejs/node/issues/1024
112112
{
113-
const a = Array(1 << 20).join('x');
113+
const a = 'x'.repeat(1 << 20 - 1);
114114
const b = Buffer.from(a, 'ucs2').toString('ucs2');
115115
const c = Buffer.from(b, 'utf8').toString('utf8');
116116

0 commit comments

Comments
 (0)