forked from carlssonemil/interstellar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8caa8a5
commit 34a5c77
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const groupBy = (array, keyGetter) => { | ||
return array.reduce((map, item) => { | ||
const key = keyGetter(item) | ||
map[key] = map[key] || [] | ||
map[key].push(item) | ||
return map | ||
}, {}) | ||
} | ||
|
||
export { groupBy } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const round = (number, precision) => { | ||
const factor = Math.pow(10, precision) | ||
return Math.round(number * factor) / factor | ||
} | ||
|
||
export { round } |