Skip to content

Commit 4a782e1

Browse files
JacksonTianBenjamin Gruenbaum
authored and
Benjamin Gruenbaum
committed
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 ddcd93a commit 4a782e1

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
@@ -24,7 +24,7 @@ const common = require('../common');
2424
const assert = require('assert');
2525
const fork = require('child_process').fork;
2626

27-
const expected = Array(1e5).join('ßßßß');
27+
const expected = 'ßßßß'.repeat(1e5 - 1);
2828
if (process.argv[2] === 'child') {
2929
process.send(expected);
3030
} else {

test/parallel/test-stringbytes-external.js

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

4646
// now create big strings
47-
const size = 1 + (1 << 20);
48-
write_str = Array(size).join(write_str);
49-
ucs2_control = Array(size).join(ucs2_control);
47+
const size = 1 << 20;
48+
write_str = write_str.repeat(size);
49+
ucs2_control = ucs2_control.repeat(size);
5050

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

132132
// https://github.com/nodejs/node/issues/1024
133133
{
134-
const a = Array(1 << 20).join('x');
134+
const a = 'x'.repeat(1 << 20 - 1);
135135
const b = Buffer.from(a, 'ucs2').toString('ucs2');
136136
const c = Buffer.from(b, 'utf8').toString('utf8');
137137

0 commit comments

Comments
 (0)