Skip to content

Releases: cshaa/filtrex

v3.1.0

14 Oct 11:11
Compare
Choose a tag to compare
  • Change links to github.com/m93a to github.com/cshaa (#62)
  • Quality of life improvements in the codebase
    • Migrate from yarn to pnpm
    • Update dependencies
    • Format everything using prettier

v3.0.0

14 Oct 08:29
Compare
Choose a tag to compare

Breaking Changes

  • Trying to access properties that aren't present in the data object now produces an error (#22)
  • Logical values are no longer converted to 1 and 0, proper booleans are returned instead (#27)
  • Corrected the precedence of exponentiation (#41, #43)
  • Modulo now always returns a positive number (#36)
  • Removed random from standard functions (#47)
  • Corrected the precedence of not in (#42)
  • Corrected the precedence of the ternary operator (#34)

Deprecations

  • The ternary operator ? : is now deprecated in favor of if..then..else (#34)
  • Modulo operator % is now deprecated in favor of mod (#48)

New Features

  • Chained comparisons are now possible: x>y>z, meaning x>y and y>z (#37)

  • Operators can now be overloaded using options.operators['+'] and the like (#38)

    • The supported operators are +, -, *, /, mod, ^, ==, !=, <, <=, >=, >, ~=
    • The minus operator overload is used for both the binary and the unary operator:
      • -a will result in operators['-'](a)
      • a - b will result in operators['-'](a, b).
  • Errors are now i18n-friendly (#35)

    • err.I18N_STRING will return one of the following strings:

      • UNKNOWN_FUNCTION, English message: “Unknown function: <funcName>
      • UNKNOWN_PROPERTY, English message: “Property “<propName>” does not exist.”
      • UNKNOWN_OPTION, English message: “Unknown option: <key>
      • UNEXPECTED_TYPE, English message: “Expected a <expected>, but got a <got> instead.”
      • INTERNAL, does not have a standardized message
    • The values in angled brackeds are available as properties on the error, eg. err.funcName and err.propName

    • Parse errors are sadly not i18n-friendly yet – this is a limitation of Jison (#55)

  • Adds options.constants, which allows you to pass constant values (like pi) to the user without the need to modify data (#38)

    • When using unquoted symbols, constants shadow data properties, ie. 2*pi will resolve as 2*constants.pi if it is defined
    • Quoted symbols always resolve as data properties, ie. 2*'pi' will always resolve as 2*data.pi
  • Optionally, you use dot as a property accessor (#44)

v2.2.0

16 Jun 21:16
e8677d7
Compare
Choose a tag to compare

Maintenance release that adds more import options and updates README

Minor improvements

05 Sep 07:02
Compare
Choose a tag to compare

Changelog

  • Added support for quote-escaping in string literals and quoted symbols.

    • "some \"quoted\" string and a \\ backslash"
    • 'a \'quoted\' symbol and a \\ backslash'
    • Breaking change: Backslash \ character now has to be escaped \\.
    • These expressions throw a syntax error: "\'", '\"', "\n" (use literal newline), "\anythingother"
  • Added support for in operator with runtime arrays.

    • value in array will return 1 when the value is present in the array and 0 otherwise
    • array in array will return 1 when the first array is a subset of the second one, 0 otherwise
    • array in value and value in value technically also work, they convert value to [value].
  • Changed the compileExpression method's call signature

    • Breaking change.
    • Previously the method had up to three parameters: expression, extraFunctions and customProp.
    • Now the method has two parameters: expression and options, where options = { extraFunctions, customProp }.
    • Current exported types:
export function compileExpression(
    expression: string,
    options?: Options
): (obj: any) => any

export interface Options
{
    extraFunctions?: {
        [T: string]: Function
    },

    customProp?: (
        name: string,
        get: (name: string) => any,
        object: any
    ) => any
}

Stable and safe

16 Apr 12:37
Compare
Choose a tag to compare

First publish from @m93a.