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!
For docs and examples please visit jsqry.github.io.
npm install jsqry
or
yarn add jsqry
<script src="https://cdn.jsdelivr.net/npm/jsqry@1.2.4/jsqry.min.js"></script>