object-path-plus
object-path-plus
is an object-path compatible library that also
provides the ability to synthesize values from multiple provided paths.
Currently, it only supports the .
delimited path format of object-path
.
Installation
npm install object-path-plus
or
yarn add object-path-plus
Usage
object-path
usage
To see basic object path usage, see object-path's documentation
Concatenating values
Concatenation with object-path-plus
is very simple, just add a +
sign!
You can concatenate resolve values from multiple object-path
s and you can
also concatenate string literals with resolved path values.
const resolve = ; === 3; === 'foobar'; === '1 - 2'; === 'foo bar'; === 'foo bar whiz'; === 'foo bar 1';
Dynamic array lookups
You can also use a property to index within an array. Just use the []
syntax.
=== 2
Validating object-path-plus paths
You can also test if a path is valid prior to trying to resolve a value with it.
const validate = ; === true; === true; === false;