1.0.3 • Published 8 years ago

o-query v1.0.3

Weekly downloads
9
License
GNU/PGLv3
Repository
github
Last release
8 years ago

Object query

Ease way to get, set and find object property.

Instalation

npm install o-query

Usage

For ES5

var oQuery = require('o-query');

or for ES6

import * as oQuery from 'o-query'

Methods

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'}]
};

oQuery.get(path, object);

Get some property in object or array;

console.log(oQuery.get('/b/num', obj));

console.log(oQuery.get('/arr/1', obj));

oQuery.set(path, patch, object);

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));

oQuery.remove(path, object);

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));

oQuery.wildcard(pattern, findProps, object, filter);

Find props by pattern and params

console.log(oQuery.wildcard('/**', ['num'], obj));

Licese

See license in LICENSE.md

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

9 years ago