smart-filter-builder
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

smart-filter-builder

Example

import { After, Is, LessThan } from "smart-filter-builder/filters";
import { And, Or } from "smart-filter-builder/operators";
import { Field } from "smart-filter-builder/sources";
import { predicateToCEL } from "smart-filter-builder/utilities";

const incompatibleBrowser = And(
  Field("user.lastSeen", After(Temporal.Now.instant().subtract({ months: 1 }))),
  Or(
    And(
      Or(
        Field("browser.name", Is("Chrome")),
        Field("browser.name", Is("Edge"))
      ),
      Field("browser.version", LessThan(79))
    ),
    And(
      Field("browser.name", Is("Firefox")),
      Field("browser.version", LessThan(67))
    ),
    And(
      Field("browser.name", Is("Safari")),
      Field("browser.version", LessThan(13))
    )
  )
);

incompatibleBrowser({ browser: { name: "Safari", version: "12" } }); // => true
predicateToCEL(incompatibleBrowser); // => (browser.name == "Chrome" || browser.name == "Edge") && browser.version < 79 || browser.name == "Firefox" && browser.version < 67 || browser.name == "Safari" && browser.version < 13

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.3.30latest

Version History

VersionDownloads (Last 7 Days)Published
0.3.30
0.3.20
0.3.10
0.2.10
0.2.00
0.1.00

Package Sidebar

Install

npm i smart-filter-builder

Weekly Downloads

0

Version

0.3.3

License

Apache-2.0

Unpacked Size

95.6 kB

Total Files

135

Last publish

Collaborators

  • ericmantooth