a simple utility function for getting a value at a path from an object with all the usecases properly covered
npm install object-resolve-path
npm i object-resolve-path
`Usage
`javascript
var resolvePath = require('object-resolve-path');
resolvePath(someObject, 'a.b[0]'); //returns first property from b from a from someObject
resolvePath(someObject, 'a["b-a"][0]'); //this works as well, thanks to the parser/statemachine
`Typical usecase?
Most other libraries for accessing deeply nested properties of an object don't work with bracket syntax. This one does work with bracket syntax.For thorough description, check the tests.
$3
https://www.npmjs.com/package/lodash.get (works for both but much much slower, doesn't throw when path is not valid, object-resolve-path does)
https://github.com/deoxxa/dotty (works only for dots)
https://github.com/Ntran013/dot-access (works only for dots)
https://github.com/substack/js-traverse (much more complex and useful)
Benchmarks
`
node benchmark.js
lodash.get x 2,088,580 ops/sec ±3.42% (74 runs sampled)
object-resolve-path x 26,260,596 ops/sec ±3.39% (85 runs sampled)
Fastest is object-resolve-path
``