Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 92106x 21792x | /* * Allows access to nested JavaScript objects with a string key. * Example usage: * resolveToProperty("style.width", document.body) */ const resolveToProperty = (path, obj) => (typeof path !== 'string' ? undefined : path.split('.').reduce((prev, curr) => (prev ? prev[curr] : undefined), obj)); /** * Returns true if path is represented as a nested prop. Otherwise false. * @param {string} path the string representation of a path to the nested property. */ const isKeyNestedProp = path => /[a-zA-Z_](\w*\.[a-z_]\w*)+/i.test(path); export { resolveToProperty, isKeyNestedProp }; |