funkjunky/schemaless-normalizer

View on GitHub
getPropertyTree.js

Summary

Maintainability
A
0 mins
Test Coverage
const getPropertyTree = (obj, defaultValue, ...keys) => {
    if (!obj) return defaultValue;
    if (!keys.length) return obj;
    const [ key, ...otherKeys ] = keys;
    return getPropertyTree(obj[key], defaultValue, ...otherKeys);
};

export default getPropertyTree;