- Source:
Members
(static) filterBy
Filter a collection of objects by one prop
- Source:
Example
const arr = [{a: 1}, {a: 2}, {a: 3}]
filterBy("a", [1, 3], arr);
// The output will be:
// [{a: 1}, {a: 3}]
(static) indexCollection
Takes an array of objects and transforms it into an object where the keys
are some value of each array
- Source:
Example
const data = [{id: 1, name: "foo"}, {id: 2, name: "abc"}]
indexCollection(data, "id")
// output will be {1: {id: 1, name: "foo"}, {id: 2, name: "abc"}}
(static) sortByObjectKey
Sort a collection of objects by one of the keys
- Source:
Example
const data = [{id: 1, name: "foo"}, {id: 2, name: "abc"}]
sortByObjectKey(data, "name")
// output will be [{id: 2, name: "abc"}, {id: 1, name: "foo"}]