object-dot-keys
v1.0.3
Published
🌳 Create an array of key paths from an object.
Downloads
50
Maintainers
Readme
object-dot-keys
🌳 Create an array of key paths from an object.
API
import objectDotKeys from 'object-dot-keys';
objectDotKeys({}, 'separator');
Usage
import objectDotKeys from 'object-dot-keys';
const obj = {
a: { b: 'c' },
b: [{ c: 'a' }, { c: 'b' }, { c: 'c' }]
};
objectDotKeys(obj) // ['a.b', 'b.0.c', 'b.1.c', 'b.2.c']
objectDotKeys(obj, { separator: '_' }); // ['a_b', 'b_0_c', 'b_1_c', 'b_2_c']
objectDotKeys(obj, { array: false }); // ['a.b', 'b']