Stew.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 Stew.forEach() for more info

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


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


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


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


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


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