Keypaths
A tools for javascript Object key paths.
Install
npm install keypaths --save
Test
git clone https://github.com/hiowenluke/keypathscd keypathsnpm installnpm test
Usage
Convert the key paths of an object to an array
const kp = ; const obj = a: {} b: b1: b11: {} b2: {} c: {}; const paths = kp;console;
Result
[ 'a', 'b.b1.b11', 'b.b2', 'c',]
Convert a key paths string array to an object
const kp = ; const paths = 'a' 'b.b1.b11' 'b.b2' 'c'; const obj = kp;console;
Result
Get by key path
const kp = ; const obj = a: b: c: 123 ; console; // 123
Set by key path
const kp = ; const obj = a: b: c: 123 ; kp;console; // [1, 2, 3]
License
Copyright (c) 2019, Owen Luke