serilize keys and query keys deep in an object
It is very easy to get value of keys deep into your object, or stringify keys to a string from array
import keySerializer from '@cat5th/key-serializer'
keySerializer.stringify(['a', 1, 'b', 0])
// result: "a[1].b[0]"
keySerializer.parse('a[1].b[0]')
// result: ['a', 1, 'b', 0]
const obj = { a: [{ b: [1, 2], c: [3, 4] }, { b: [5, 6], c: [7, 8] }] }
keySerializer.query(obj, 'a[1].b[0]')
// result: { value: 5, key: 0, target: [5, 6]}
keySerializer.get(obj, 'a[1].b[0]')
// result: 5
keySerializer.set(obj, 'a[1].b[0]', 1)
console.log(obj.a[1].b[0])
// result: 1
notice: get/set/query function will throw TypeError when target is null or undefined, keep in mind, and always use get/query in try block