Stew.mapKeys() - shysolocup/stews GitHub Wiki

overwrites all keys with something
type: Function

alt names:

  • mapKey()

arguments:

  • mapper Function:
    goes through every entry with the function and replaces the key 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.mapKeys( (v, i) => {
    return `${v} ${ 123 * (i+1) }`;
}));
const { Stew } = require('stews');


let obj = new Stew({ x: "val1", y: "val2" });


console.log(obj.mapKeys( (k, v, i) => {
    return `key${i}`;
}));
Stew(2) [ "abc 123", "def 246" ] 
Stew(2) { key1: "val1", key2: "val2" }


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