包详细信息

@informatiqal/filter-parser

informatiqal7MIT0.1.0

Library to parse Qlik filter into JS format

informatiqal, automatiqal

自述文件

Automatiqal filter parser

Description

Small (and very specific) package to parse Automatiqal conditions and covert them to JS.

These condition are quite similar to Qlik Repository filtering format.

Usage

import { parseFilter } from "@informatiqal/filter-parser";

const parsed = parseFilter("(('something' so 'thing' and 1 eq 1) or 3 gt 4)")

Once executed the value of parsed (string) will be:

(('something'.includes('thing') && 1 == 1) || 3 > 4)

The returned string can then be evaluated to get the result of it. In the example above the result will be true.

Base path

UNDER DEVELOPMENT Please do not use at the moment!

The main function accepts additional parameter - base path. Extending the example above:

import { parseFilter } from "@informatiqal/filter-parser";

const parsed = parseFilter("(('something' so 'thing' and 1 eq 1) or 3 gt 4)", "myObj")

Will return:

((myObj.something.includes('thing') && myObj.1 == 1) || myObj.3 > 4)

Available operators

Math

  • eq - equal ==
  • ne - not equal !=
  • gt - grater than >
  • ge - greater than or equal >=
  • lt - less than <
  • le - less than or equal <=

String

  • sw - starts with
  • ew - ends with
  • so - substring of