- Change links to
github.com/m93a
togithub.com/cshaa
(#62) - Quality of life improvements in the codebase
- Migrate from
yarn
topnpm
- Update dependencies
- Format everything using
prettier
- Migrate from
- 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
and0
, 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)
- The ternary operator
? :
is now deprecated in favor ofif..then..else
(#34) - Modulo operator
%
is now deprecated in favor ofmod
(#48)
-
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:
-a
will result inoperators['-'](a)
a - b
will result inoperators['-'](a, b)
.
- The supported operators are
-
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
anderr.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*pi
will resolve as2*constants.pi
if 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
prop
functions are:useOptionalChaining
,useDotAccessOperator
anduseDotAccessOperatorAndOptionalChaining
customProp
now has additional argumenttype: 'unescaped' | 'single-quoted'
- The available predefined
- TODO: these will be the steps you need to take for the smoothest ride
-
BREAKING CHANGE: Changes the
compileExpression
method's call signature- Previously the method had up to three parameters:
expression
,extraFunctions
andcustomProp
- Now the method has two parameters:
expression
andoptions
, whereoptions = { extraFunctions, customProp }
- Previously the method had up to three parameters:
-
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 return1
when the value is present in the array and0
otherwisearray in array
will return1
when the first array is a subset of the second one,0
otherwisearray in value
andvalue in value
technically also work, they convertvalue
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 todata.b.a
- Adds the ability to customize the
prop
function (#27j, #28j)
- The original version by Joe Walnes
- KNOWN VULNERABILITY: Quotes can be exploited for XSS, see #17j, #18j
- KNOWN VULNERABILITY: Prototypes are accessible from expressions