Releases: cshaa/filtrex
v3.1.0
v3.0.0
Breaking Changes
- Trying to access properties that aren't present in the
dataobject now produces an error (#22) - Logical values are no longer converted to
1and0, proper booleans are returned instead (#27) - Corrected the precedence of exponentiation (#41, #43)
- Modulo now always returns a positive number (#36)
- Removed
randomfrom 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 ofif..then..else(#34) - Modulo operator
%is now deprecated in favor ofmod(#48)
New Features
-
Chained comparisons are now possible:
x>y>z, meaningx>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:
-awill result inoperators['-'](a)a - bwill result inoperators['-'](a, b).
- The supported operators are
-
Errors are now i18n-friendly (#35)
-
err.I18N_STRINGwill 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.funcNameanderr.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 modifydata(#38)- When using unquoted symbols, constants shadow data properties, ie.
2*piwill resolve as2*constants.piif it is defined - Quoted symbols always resolve as data properties, ie.
2*'pi'will always resolve as2*data.pi
- When using unquoted symbols, constants shadow data properties, ie.
-
Optionally, you use dot as a property accessor (#44)
- The available predefined
propfunctions are:useOptionalChaining,useDotAccessOperatoranduseDotAccessOperatorAndOptionalChaining customPropnow has additional argumenttype: 'unescaped' | 'single-quoted'
- The available predefined
v2.2.0
Minor improvements
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
inoperator with runtime arrays.value in arraywill return1when the value is present in the array and0otherwisearray in arraywill return1when the first array is a subset of the second one,0otherwisearray in valueandvalue in valuetechnically also work, they convertvalueto[value].
-
Changed the
compileExpressionmethod's call signature- Breaking change.
- Previously the method had up to three parameters:
expression,extraFunctionsandcustomProp. - Now the method has two parameters:
expressionandoptions, whereoptions = { 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
First publish from @m93a.