Skip to content

Commit 4f9e5d9

Browse files
committed
Shim Array.fill
1 parent e5a82e3 commit 4f9e5d9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@babel/core": "^7.4.4",
2525
"@babel/preset-env": "^7.4.4",
2626
"airtap": "^2.0.2",
27+
"array-fill": "^1.2.0",
2728
"core-js": "^3.0.1",
2829
"cross-env": "^5.2.0",
2930
"object.getownpropertydescriptors": "^2.0.3",

test/parallel/test-assert.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
'use strict';
2727

28+
const arrayFill = require('array-fill');
29+
2830
const common = require('../common');
2931
const assert = require('../../assert');
3032
const { inspect } = require('util/');
@@ -602,7 +604,7 @@ assert.throws(
602604
common.repeat('- 2,\n', 10) +
603605
'...';
604606
assert.throws(
605-
() => assert.deepEqual(Array(12).fill(1), Array(12).fill(2)),
607+
() => assert.deepEqual(arrayFill(Array(12), 1), arrayFill(Array(12), 2)),
606608
// { message }
607609
);
608610

@@ -635,7 +637,7 @@ assert.throws(
635637

636638
message = 'Expected "actual" not to be strictly deep-equal to:' +
637639
`\n\n[${common.repeat('\n 1,', 25)}\n...\n`;
638-
const data = Array(31).fill(1);
640+
const data = arrayFill(Array(31), 1);
639641
assert.throws(
640642
() => assert.notDeepEqual(data, data),
641643
// { message }
@@ -1172,7 +1174,7 @@ assert.throws(
11721174
{
11731175
let threw = false;
11741176
try {
1175-
assert.deepStrictEqual(Array(100).fill(1), 'foobar');
1177+
assert.deepStrictEqual(arrayFill(Array(100), 1), 'foobar');
11761178
} catch (err) {
11771179
threw = true;
11781180
// assert(/actual: \[Array],\n expected: 'foobar',/.test(inspect(err)));

0 commit comments

Comments
 (0)