tvl-depot/users/wpcarro/slx.js
William Carroll e20c0d2fbf fix(wpcarro/slx): Fix LTE/GTE parsing error
Fix: `i += 2`. Welp!
Change-Id: I06061f0c5bb5283c8b85bd3f5a6e52e2eb59d4f5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7885
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
2023-01-20 23:50:27 +00:00
..
.gitignore test(wpcarro/slx): Add (basic) tests 2023-01-20 23:33:22 +00:00
default.nix feat(wpcarro/slx.js): Support JavaScript simple-select impl 2023-01-19 18:12:59 +00:00
index.html test(wpcarro/slx): Add (basic) tests 2023-01-20 23:33:22 +00:00
index.js fix(wpcarro/slx): Fix LTE/GTE parsing error 2023-01-20 23:50:27 +00:00
package.json test(wpcarro/slx): Add (basic) tests 2023-01-20 23:33:22 +00:00
README.md feat(wpcarro/slx.js): Support JavaScript simple-select impl 2023-01-19 18:12:59 +00:00
tests.js fix(wpcarro/slx): Fix LTE/GTE parsing error 2023-01-20 23:50:27 +00:00
yarn.lock test(wpcarro/slx): Add (basic) tests 2023-01-20 23:33:22 +00:00

slx.js

Filter tabular data in the browser using an ergonomic query language.

Status

This project is usable today (I use it in my projects), but it's currently alpha status. See the wish list for remaining features.

Installation

slx.js is available via CDN:

<script src="https://cdn.jsdelivr.net/gh/wpcarro/slx.js/index.js" async></script>

Usage

slx.js hasn't been properly benchmarked, but in my personal projects, it works fine with O(1,000)s of records.

const cast = [
  { first: "Graham", last: "Chapman" },
  { first: "John", last: "Cleese" },
  { first: "Terry", last: "Gilliam" },
  { first: "Eric", last: "Idle" },
  { first: "Terry", last: "Jones" },
  { first: "Michael", last: "Palin" },
];

const config = {
    // Match values case sensitively when filtering.
    caseSensitive: false,
    // Coerce values into regular expressions (instead of strings) when they're defined as atoms.
    preferRegex: true,
    // The key in the JS object that hosts the Date type against which we filter.
    dateKey: 'Date',
};

console.log(select('last:^C.+$', cast, config));
// [{ first: "Graham", last: "Chapman" }, { first: "John", last: "Cleese" }]

Wish List

  • Support explicit grouping with parentheses (e.g. title:once (director:Tarantino OR director:Coen)).
  • Proper benchmarking (see "Usage" section).
  • Something something documentation.
  • Something something testing.

See also: