Ease way to get, set and find object property.
npm install o-query
For ES5
var oQuery = require('o-query');
or for ES6
import * as oQuery from 'o-query'
In all demos uses this object
var obj = {
a: 'str',
b: {
num: 123
},
e: {
f: {
num: 'string num'
}
},
arr: [1,2,4, {num: 321}, {num: 'str num in arr'}]
};
Get some property in object or array;
console.log(oQuery.get('/b/num', obj));
console.log(oQuery.get('/arr/1', obj));
Set some property in object or array;
oQuery.set('/b/newProp', 'string', obj);
console.log(oQuery.get('/b/newProp', obj));
oQuery.set('/arr/3', 123, obj);
console.log(oQuery.get('/arr', obj));
Remove some property in object or array;
oQuery.remove('/arr/3', obj);
console.log(oQuery.get('/arr', obj));
oQuery.remove('/a', obj);
console.log(oQuery.get('/', obj));
Find props by pattern and params
console.log(oQuery.wildcard('/**', ['num'], obj));
See license in LICENSE.md