UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

28 lines (26 loc) 661 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = mapObject; /** * Returns the results of applying the iteratee to each element of the object. * @param {object} object * @param {function(val, key)} iteratee * @returns {object} * @example * ```js * const newObj = mapObject({ start: 5, end: 12 }, function(val, key) { * return val + 5; * }); * console.log(newObj) // { start: 10, end: 17 } * ``` */ function mapObject(obj, iteratee) { const keys = Object.keys(obj); const mappedObject = {}; keys.forEach(key => { mappedObject[key] = iteratee(obj[key], key); }); return mappedObject; }