Comparing version 0.33.0 to 0.34.0
@@ -346,2 +346,21 @@ 'use strict'; | ||
/** | ||
* FromPairs takes an array of arrays with key-value pairs and returns an | ||
* object composed from key-value pairs. | ||
* | ||
* @param {Array} array input key-value pairs in an array of arrays | ||
* @returns {object} object filtered to only include elemnts with a key from the filter | ||
* | ||
* @example | ||
* const result = objects.fromPairs([['age', 12034], ['name', 'Trair'],['state', 'Floating']]); | ||
* console.log(result); | ||
* > { age: 12034, name: 'Trair', state: 'Floating' } | ||
*/ | ||
function fromPairs (array) { | ||
return array.reduce((acc, curr) => { | ||
acc[curr[0]] = curr[1]; | ||
return acc; | ||
}, {}); | ||
} | ||
/** | ||
* IndexOf method returns the first index at which a given element can be found in the array | ||
@@ -581,2 +600,3 @@ * beyond the starting index, or -1 if it is not present. | ||
flat: flat, | ||
fromPairs: fromPairs, | ||
indexOf: indexOf, | ||
@@ -583,0 +603,0 @@ map: map, |
@@ -342,2 +342,21 @@ /** | ||
/** | ||
* FromPairs takes an array of arrays with key-value pairs and returns an | ||
* object composed from key-value pairs. | ||
* | ||
* @param {Array} array input key-value pairs in an array of arrays | ||
* @returns {object} object filtered to only include elemnts with a key from the filter | ||
* | ||
* @example | ||
* const result = objects.fromPairs([['age', 12034], ['name', 'Trair'],['state', 'Floating']]); | ||
* console.log(result); | ||
* > { age: 12034, name: 'Trair', state: 'Floating' } | ||
*/ | ||
function fromPairs (array) { | ||
return array.reduce((acc, curr) => { | ||
acc[curr[0]] = curr[1]; | ||
return acc; | ||
}, {}); | ||
} | ||
/** | ||
* IndexOf method returns the first index at which a given element can be found in the array | ||
@@ -577,2 +596,3 @@ * beyond the starting index, or -1 if it is not present. | ||
flat: flat, | ||
fromPairs: fromPairs, | ||
indexOf: indexOf, | ||
@@ -579,0 +599,0 @@ map: map, |
{ | ||
"name": "absurdum", | ||
"version": "0.33.0", | ||
"version": "0.34.0", | ||
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -62,2 +62,3 @@ [![GitHub Releases](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases) | ||
- [flat][arrays.flat] | ||
- [fromPairs][arrays.fromPairs] | ||
- [indexOf][arrays.indexOf] | ||
@@ -86,2 +87,3 @@ - [map][arrays.map] | ||
[arrays.flat]: ./docs/arrays/flat.md | ||
[arrays.fromPairs]: ./docs/arrays/fromPairs.md | ||
[arrays.indexOf]: ./docs/arrays/indexOf.md | ||
@@ -88,0 +90,0 @@ [arrays.map]: ./docs/arrays/map.md |
@@ -14,2 +14,3 @@ export { chunk } from "./chunk.js"; | ||
export { flat } from "./flat.js"; | ||
export { fromPairs } from "./fromPairs.js"; | ||
export { indexOf } from "./indexOf.js"; | ||
@@ -16,0 +17,0 @@ export { map } from "./map.js"; |
@@ -14,2 +14,3 @@ export { chunk } from './chunk.js'; | ||
export { flat } from './flat.js'; | ||
export { fromPairs } from './fromPairs.js'; | ||
export { indexOf } from './indexOf.js'; | ||
@@ -16,0 +17,0 @@ export { map } from './map.js'; |
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
124297
109
3124
130