Comparing version 0.61.0 to 0.62.0
@@ -1513,2 +1513,22 @@ /** | ||
/** | ||
* MapKeys iterates over an object and applies a function to each value | ||
* | ||
* @param {Object} object input object | ||
* @param {Function} func map function | ||
* @returns {Object} object with mutated values | ||
* | ||
* @example | ||
* const result = objects.mapValues({ a: 1, b: 2, c: 3 }, value => `neat_${value}`); | ||
* console.log(result); | ||
* > { a: neat_1, b: neat_2, c: neat_3 } | ||
*/ | ||
function mapValues (object, func) { | ||
if (typeof func !== 'function') { return object; } | ||
return Object.entries(object).reduce((acc, [key, value]) => ({ | ||
...acc, | ||
[key]: func(value, key, object) | ||
}), {}); | ||
} | ||
/** | ||
* Merge recursively merges object properties from all supplied objects with object values | ||
@@ -1633,2 +1653,3 @@ * being merged recursively and other value types overridden when applied from left to right. | ||
mapKeys: mapKeys, | ||
mapValues: mapValues, | ||
merge: merge, | ||
@@ -1635,0 +1656,0 @@ pick: pick, |
{ | ||
"name": "absurdum", | ||
"version": "0.61.0", | ||
"version": "0.62.0", | ||
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -144,2 +144,3 @@ [![GitHub Releases](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases) | ||
- [mapKeys][objects.mapKeys] | ||
- [mapValues][objects.mapValues] | ||
- [merge][objects.merge] | ||
@@ -159,2 +160,3 @@ - [pick][objects.pick] | ||
[objects.mapKeys]: ./docs/objects/mapKeys.md | ||
[objects.mapValues]: ./docs/objects/mapValues.md | ||
[objects.merge]: ./docs/objects/merge.md | ||
@@ -161,0 +163,0 @@ [objects.pick]: ./docs/objects/pick.md |
@@ -11,4 +11,5 @@ export { at } from "./at.js"; | ||
export { mapKeys } from "./mapKeys.js"; | ||
export { mapValues } from "./mapValues.js"; | ||
export { merge } from "./merge.js"; | ||
export { pick } from "./pick.js"; | ||
export { values } from "./values.js"; |
@@ -11,4 +11,5 @@ export { at } from './at.js'; | ||
export { mapKeys } from './mapKeys.js'; | ||
export { mapValues } from './mapValues.js'; | ||
export { merge } from './merge.js'; | ||
export { pick } from './pick.js'; | ||
export { values } from './values.js'; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222660
184
5636
193