jsqry
v1.2.4
Published
Simple lib to query JS objects/arrays
Downloads
382
Readme
jsqry
Simple lib to query JS objects/arrays.
This tiny lib allows to query JS object/arrays in one-liner fashion instead of writing tedious loops (possibly nested).
Before:
var name;
for (var i = 0; i < users.length; i++) {
if (users[i].id == 123) {
name = users[i].name;
break;
}
}
After:
var name = first(users, '[_.id==?].name', 123);
Features include:
- Filtering
- Mapping
- Python-style array indexing & slicing
- lot more!
Documentation
For docs and examples please visit jsqry.github.io.
Install
Nodejs
npm install jsqry
or
yarn add jsqry
Web
<script src="https://cdn.jsdelivr.net/npm/[email protected]/jsqry.min.js"></script>