Soup.map() - shysolocup/stews GitHub Wiki

overwrites all values with something
type: Function

arguments:

  • mapper Function:
    goes through every entry with the function and replaces the value with the return value
    see Soup.forEach() for more info

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


let arr = new Soup([ "abc", "def" ]);


console.log(arr.map( (v, i) => {
    return `${v} ${ 123 * (i+1) }`;
}));
const { Soup } = require('stews');


let obj = new Soup({ key1: "abc", key2: "def" });


console.log(obj.map( (k, v, i) => {
    return `${v} ${ 123 * (i+1) }`;
}));
Soup(2) [ "abc 123", "def 246" ] 
Soup(2) { key1: "abc 123", key2: "def 246" }


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