- arrayOf(array, key) β
Array.<any>
Takes an array of any objects and accumulates an array of a shared property between them.
- sumOf(array, ...keys) β
number
Takes an array of any objects and recursively adds a shallow or complex property shared between them.
Takes an array of any objects and accumulates an array of a shared property between them.
Param | Type | Description |
---|---|---|
array | Array.<any> |
The array of objects with a shared property. |
key | string |
The property accessor for the objects in the array. |
Example
const data = [{ name: "John", id: 1 }, { name: "Jane", id: 2 }];
arrayOf(data, "name"); // ["John", "Jane"]
arrayOf(data, "id"); // [1, 2]
Takes an array of any objects and recursively adds a shallow or complex property shared between them.
Param | Type | Description |
---|---|---|
array | Array.<any> |
The array of objects with a shared shallow or nested property. |
...keys | string |
The property accessor(s) for the objects in the array. |
Example
const data = [{ nested: { value: 12 } }, { nested: { value: 34 } }];
sumOf(data, "nested", "value"); // 46