Skip to content

Commit

Permalink
test: os, replace custom flatten method with built-in Array.flat
Browse files Browse the repository at this point in the history
PR-URL: #38770
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
waelsy123 authored and richardlau committed Jul 20, 2021
1 parent 826ae9b commit eb91932
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/parallel/test-os.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ const is = {
}
};

const flatten = (arr) =>
arr.reduce((acc, c) =>
acc.concat(Array.isArray(c) ? flatten(c) : c), []);

process.env.TMPDIR = '/tmpdir';
process.env.TMP = '/tmp';
process.env.TEMP = '/temp';
Expand Down Expand Up @@ -174,7 +170,8 @@ const netmaskToCIDRSuffixMap = new Map(Object.entries({
'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff': 128
}));

flatten(Object.values(interfaces))
Object.values(interfaces)
.flat(Infinity)
.map((v) => ({ v, mask: netmaskToCIDRSuffixMap.get(v.netmask) }))
.forEach(({ v, mask }) => {
assert.ok('cidr' in v, `"cidr" prop not found in ${inspect(v)}`);
Expand Down

0 comments on commit eb91932

Please sign in to comment.