Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
8
test/flattenObject/flattenObject.js
Normal file
8
test/flattenObject/flattenObject.js
Normal file
@ -0,0 +1,8 @@
|
||||
const flattenObject = (obj, prefix = '') =>
|
||||
Object.keys(obj).reduce((acc, k) => {
|
||||
const pre = prefix.length ? prefix + '.' : '';
|
||||
if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k));
|
||||
else acc[pre + k] = obj[k];
|
||||
return acc;
|
||||
}, {
|
||||
module.exports = flattenObject;
|
||||
Reference in New Issue
Block a user