Skip to content

jsqry/jsqry

Repository files navigation

Stand With Ukraine

jsqry

GitHub license npm Coverage Status

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/jsqry@1.2.4/jsqry.min.js"></script>