Skip to content

Stew.flat()

github-actions[bot] edited this page Sep 30, 2024 · 5 revisions

concats layers into one object
type: Function

arguments:

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

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


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


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


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


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


Stews Docs 🍲

🛈 Stew 🛈 Soup
🛈 Noodle 🛈 random

Clone this wiki locally