Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
8
test/invertKeyValues/invertKeyValues.js
Normal file
8
test/invertKeyValues/invertKeyValues.js
Normal file
@ -0,0 +1,8 @@
|
||||
const invertKeyValues = (obj, fn) =>
|
||||
Object.keys(obj).reduce((acc, key) => {
|
||||
const val = fn ? fn(obj[key]) : obj[key];
|
||||
acc[val] = acc[val] || [];
|
||||
acc[val].push(key);
|
||||
return acc;
|
||||
}, {
|
||||
module.exports = invertKeyValues;
|
||||
Reference in New Issue
Block a user