Skip to content

Latest commit

 

History

History
83 lines (65 loc) · 6.35 KB

CHANGELOG.md

File metadata and controls

83 lines (65 loc) · 6.35 KB

Changelog

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)

How to Migrate from 2.2.0

  • TODO: these will be the steps you need to take for the smoothest ride
  • The parser is now precompiled, massively speeding up cold start (#19)
  • Fixes Jison dependence (#21)
  • BREAKING CHANGE: Changes the compileExpression method's call signature

    • 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 }
  • BREAKING CHANGE: Adds support for quote-escaping in string literals and quoted symbols (#11, #12, #20, #31j)

    • "some \"quoted\" string and a \\ backslash"
    • 'a \'quoted\' symbol and a \\ backslash'
    • backslash \ character now has to be escaped \\
    • these expressions throw a syntax error: "\'", '\"', "\n" (use literal newline), "\anythingother"
  • Adds support for in operator with runtime arrays (#14)

    • 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]
  • Errors are no longer thrown, but instead catched and returned (#7)

  • FIXED VULNERABILITY: Not prone to XSS anymore (#17j, #18j)
  • FIXED VULNERABILITY: More robust against prototype attacks (#19j, #20j)
  • Adds TypeScript type definitions
  • Adds syntax for arrays: (a, b, c)
  • Adds the of property accessor: a of b translates to data.b.a
  • Adds the ability to customize the prop function (#27j, #28j)

0.5.4

  • The original version by Joe Walnes
  • KNOWN VULNERABILITY: Quotes can be exploited for XSS, see #17j, #18j
  • KNOWN VULNERABILITY: Prototypes are accessible from expressions