Soup.flat() - shysolocup/stews GitHub Wiki

concats layers into one object
type: Function

arguments:

  • ?depth Number
    optional depth telling it how many layers it should flatten

list: pair:
const { Soup } = require('stews');


let arr = new Soup([ ["a", "b"], [ "c", [ "d" ] ] ]);


console.log(arr.flat());
console.log(arr.flat(2));
const { Soup } = require('stews');


let obj = new Soup({ key1: "val1", key2: ["val2"] });


console.log(obj.flat());
console.log(obj.flat(2));
Soup(4) [ "a", "b", "c", [ "d" ] ] // depth of 1
Soup(4) [ "a", "b", "c", "d" ] // depth of 2
Soup(4) [ "key1", "val1", "key2", [ "val2" ] ] // depth of 1
Soup(4) [ "key1", "val1", "key2", "val2" ] // depth of 2


⚠️ **GitHub.com Fallback** ⚠️