snakecase fix, include sip_status in dial action hook

This commit is contained in:
Dave Horton
2021-04-27 08:21:14 -04:00
parent 576f645489
commit 5cc4852bf9
6 changed files with 30 additions and 26 deletions

View File

@@ -0,0 +1,22 @@
const snakeCase = require('to-snake-case');
const isObject = (value) => typeof value === 'object' && value !== null;
const snakeObject = (obj, excludes) => {
const target = {};
for (const [key, value] of Object.entries(obj)) {
if (excludes.includes(key)) {
target[key] = value;
continue;
}
const newKey = snakeCase(key);
const newValue = isObject(value) ? snakeObject(value, excludes) : value;
target[newKey] = newValue;
}
return target;
};
module.exports = (obj, excludes = []) => {
return snakeObject(obj, excludes);
};