Skip to content

Commit 80cf08a

Browse files
committed
Remove for of loops so transpiled source doens't require Symbol.iterator
1 parent 64b13ad commit 80cf08a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"tape": "^4.10.1"
3131
},
3232
"dependencies": {
33+
"array-from": "^2.1.1",
3334
"buffer": "^5.2.1",
3435
"es6-object-assign": "^1.1.0",
3536
"object-is": "^1.0.1",

test/parallel/test-assert-deep.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const { AssertionError } = assert;
1010
const defaultMsgStart = 'Expected values to be strictly deep-equal:\n';
1111
const defaultMsgStartFull = `${defaultMsgStart}+ actual - expected`;
1212

13+
const objectEntries = require('object.entries');
14+
const arrayFrom = require('array-from');
15+
1316
// Disable colored output to prevent color codes from breaking assertion
1417
// message comparisons. This should only be an issue when process.stdout
1518
// is a TTY.
@@ -20,7 +23,7 @@ if (process.stdout && process.stdout.isTTY)
2023
// for assert.throws()
2124
function re(literals, ...values) {
2225
let result = 'Expected values to be loosely deep-equal:\n\n';
23-
for (const [i, value] of values.entries()) {
26+
arrayFrom(values.entries()).forEach(([i, value]) => {
2427
const str = util.inspect(value, {
2528
compact: false,
2629
depth: 1000,
@@ -33,7 +36,7 @@ function re(literals, ...values) {
3336
// Need to escape special characters.
3437
result += str;
3538
result += literals[i + 1];
36-
}
39+
});
3740
return {
3841
code: 'ERR_ASSERTION',
3942
message: result
@@ -174,17 +177,17 @@ assert.throws(
174177
(function() { return arguments; })(1)
175178
]);
176179

177-
for (const a of similar) {
178-
for (const b of similar) {
180+
arrayFrom(similar).forEach(a => {
181+
arrayFrom(similar).forEach(b => {
179182
if (a !== b) {
180183
assert.notDeepEqual(a, b);
181184
assert.throws(
182185
() => assert.deepStrictEqual(a, b),
183186
{ code: 'ERR_ASSERTION' }
184187
);
185188
}
186-
}
187-
}
189+
});
190+
});
188191
}
189192

190193
function assertDeepAndStrictEqual(a, b) {

0 commit comments

Comments
 (0)