loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6936209393344519","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"ZnVuY3Rpb24gc3RlYW1yb2xsQXJyYXkoYXJyKSB7CiAgZnVuY3Rpb24gZmxhdHRlbihpdGVtKXsKCiAgICBpZihBcnJheS5pc0FycmF5KGl0ZW0pKXsKICAgICAgY29uc29sZS5sb2coImZvdW5kIHRoaXMgYXJyYXk6ICIgKyBpdGVtKTsKICAgICAgZm9yIChsZXQgYSBpbiBpdGVtKSB7CiAgICAgICAgY29uc29sZS5sb2coImEgaXMgIiArIGEpOwogICAgICAgIGNvbnNvbGUubG9nKCJ0cnkgdG8gZmxhdHRlbiB0aGlzOiAiICsgaXRlbVthXSk7CiAgICAgICAgcmV0dXJuIGZsYXR0ZW4oaXRlbVthXSk7CiAgICAgIH0KICAgIH0gZWxzZSB7IAogICAgICAgcmV0dXJuIGl0ZW07CiAgICB9CiAgfQogIGNvbnNvbGUubG9nKCJhcHBseSBmbGF0dGVuIHRvIGFsbCB0aGUgaXRlbXMgaW4gdGhlIGdpdmVuIGFycmF5OiIgKyBhcnIpOwogIGNvbnNvbGUubG9nKGFyci5tYXAoZmxhdHRlbikpOwogIHJldHVybiBhcnIubWFwKGZsYXR0ZW4pOwp9CgpzdGVhbXJvbGxBcnJheShbMSwgWzJdLCBbMywgW1s0XV1dXSk7"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function steamrollArray(arr) {
  function flatten(item){

    if(Array.isArray(item)){
      console.log("found this array: " + item);
      for (let a in item) {
        console.log("a is " + a);
        console.log("try to flatten this: " + item[a]);
        return flatten(item[a]);
      }
    } else { 
       return item;
    }
  }
  console.log("apply flatten to all the items in the given array:" + arr);
  console.log(arr.map(flatten));
  return arr.map(flatten);
}

steamrollArray([1, [2], [3, [[4]]]]);
node v10.16.0