Debian Codegraph @

packages/babel-plugin-transform-parameters/test/fixtures/parameters/default-destructuring/exec.js

raw
1 function required(msg) {
2 throw new Error(msg);
3 }
4
5 function sum(
6 { arr = required('arr is required') } = { arr: arr = [] },
7 length = arr.length
8 ) {
9 let i = 0;
10 let acc = 0;
11 for (let item of arr) {
12 if (i >= length) return acc;
13 acc += item;
14 i++;
15 }
16 return acc;
17 }
18
19 expect(sum({arr:[1,2]})).toBe(3);