aggregate-array-extensions
Advanced tools
Comparing version
{ | ||
"name": "aggregate-array-extensions", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Simple extensions to the Array prototype for aggregating elements", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -103,1 +103,23 @@ # aggregate-array-extensions | ||
``` | ||
## mapIntoObject | ||
Array.prototype.mapIntoObject = function(keySelector, valueSelector) | ||
Parameter|Description | ||
-|- | ||
keySelector|Function to select the key on the result object | ||
valueSelector|Function to select the value to assign | ||
```Javascript | ||
expect([ | ||
{ v: 1 }, | ||
{ v: 2 }, | ||
{ v: 3 } | ||
].mapIntoObject(x => x.v, x => x.v * 2)) | ||
.toEqual({ | ||
1: 2, | ||
2: 4, | ||
3: 6 | ||
}) | ||
``` |
7226
9.57%9
12.5%90
5.88%124
20.39%