Comparing version 0.46.0 to 0.47.0
@@ -1182,2 +1182,21 @@ /** | ||
/** | ||
* Create a new object with key-value pairs inverted, in the case of duplicate values the latter value | ||
* will overwrite the previous value. | ||
* | ||
* @param {object} object input string | ||
* @returns {object} returns an object with key-value pairs inverted | ||
* | ||
* @example | ||
* const result = Objects.invert({ a: 1, b: 2, c: 1 }); | ||
* console.log(result); | ||
* > { '1': 'c', '2': 'b' } | ||
*/ | ||
function invert (object) { | ||
return Object.entries(object).reduce((acc, curr) => { | ||
acc[curr[1]] = curr[0]; | ||
return acc; | ||
}, {}); | ||
} | ||
/** | ||
* Keys is an alias for Object.keys returns an array of all keys in an object | ||
@@ -1203,2 +1222,3 @@ * | ||
include: include, | ||
invert: invert, | ||
keys: keys | ||
@@ -1205,0 +1225,0 @@ }); |
{ | ||
"name": "absurdum", | ||
"version": "0.46.0", | ||
"version": "0.47.0", | ||
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
[![GitHub Releases](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases) | ||
[![NPM Releases](https://img.shields.io/npm/v/absurdum.svg)](https://www.npmjs.com/package/absurdum) | ||
[![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vanillaes/absurdum/master/LICENSE) | ||
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vanillaes/absurdum/master/LICENSE) | ||
[![Latest Status](https://github.com/vanillaes/absurdum/workflows/Latest/badge.svg)](https://github.com/vanillaes/absurdum/actions) | ||
@@ -117,2 +117,3 @@ [![Release Status](https://github.com/vanillaes/absurdum/workflows/Release/badge.svg)](https://github.com/vanillaes/absurdum/actions) | ||
- [include][objects.include] | ||
- [invert][objects.invert] | ||
- [keys][objects.keys] | ||
@@ -122,2 +123,3 @@ | ||
[objects.include]: ./docs/objects/include.md | ||
[objects.invert]: ./docs/objects/invert.md | ||
[objects.keys]: ./docs/objects/keys.md | ||
@@ -124,0 +126,0 @@ |
export { exclude } from "./exclude.js"; | ||
export { include } from "./include.js"; | ||
export { invert } from "./invert.js"; | ||
export { keys } from "./keys.js"; |
export { exclude } from './exclude.js'; | ||
export { include } from './include.js'; | ||
export { invert } from './invert.js'; | ||
export { keys } from './keys.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
167274
145
4225
154