object/mapValues.jsjavascript
/**
 * 使用转换函数生成对象的新属性值。
 * @function mapValues
 * @memberof module:object
 * @param {Object} object 要转换的对象
 * @param {Function} iteratee 转换函数,参数为值、键和原对象
 * @returns {Object} 转换后的新对象
 * @throws {TypeError} 参数类型不正确时抛出
 */
function mapValues(object, iteratee) {
  if (object === null || typeof object !== 'object' || Array.isArray(object)) throw new TypeError('object must be an object')
  if (typeof iteratee !== 'function') throw new TypeError('iteratee must be a function')
  return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, iteratee(value, key, object)]))
}

export default mapValues