Releases: discoveryjs/jora
Releases · discoveryjs/jora
1.0.0-beta.15
- Removed the mistakenly included
src/index.tsfrom the package, as it could cause build warnings
1.0.0-beta.14
- Fixed missed range for argument in
$arg => ...function notation - Fixed a JavaScript injection vulnerability in queries using escape sequences, such as
{ \u005balert\u00281\u0029\u005d: 'test' }. Now, Jora decodes escape sequences during query compilation depending on context and properly escapes or validates values from the AST when adding them into the query code. This approach also preserves authored escaping of identifiers during parse and stringify round-trips.
1.0.0-beta.13
- Disallowed duplicate parameter names in function definitions, i.e.,
($a, $a) => expris now prohibited - Improved suggestions for the ternary operator (
?:) - Fixed suggestions for
and,orand??operators - Fixed a compilation error for the generated code of
functionexpressions in stat mode in some cases - Fixed a runtime error for a
comparator functionin some scenarios - Fixed support for TypedArrays with slice notation and methods such as
numbers(),avg(),count(),sum(),median(),variance(),stdev()andpercentile() - Added missing package exports for
package.jsonanddist/*
1.0.0-beta.12
- Added support for
_as numeric separator for all kinds of number, e.g.1_000,0xa0b1_c2d3 - Extended shorthand syntax to define object entries (see Shorthand syntax for entries)
{ sum(), // equavalent to: `sum: sum()` foo.[x > 5], // equavalent to: `foo: foo | .[x > 5]` baz is number ?: 0, // equavalent to: `baz: baz | is number ?: 0` $var.size() // equavalent to: `var: var | .size()` } - Improved error handling for variable references, including providing query's range of the problem reference in errors
- Fixed acessing to global variables when a variable has no definition
1.0.0-beta.11
- Added support for treating TypedArrays as regular arrays
- Fixed
lastIndexOf()method behavior whenfromIndexis zero; previously, the search incorrectly started from the end of an array instead of the zero position - Fixed
group()method to include elements with an empty array as a key in the group withkey: undefined; previously, such elements were omitted from the result - Modified the behavior of slice notation:
- When the value is a string, the result remains a string (was an array of chars)
- When
fromis greater thantoandstepis not specified,stepdefaults to-1(i.e.$[3:1]is the same as$[1:3:-1]) - When
fromis greater thantoandstepis specified, the sign of thestepis inverted (i.e.$[5:1:-2]is the same as$[1:5:2])
1.0.0-beta.10
- Introduced basic support for function arguments in the syntax, allowing
$arg => exprand($a, $b) => exprforms to be supported - Changed the behavior of
thisin custom methods and assertions defined as functions to include acontextreference to the query context. Additionally, introducedthis.method(name, ...args)andthis.assertion(name, ...args)methods to call a custom method or use an assertion. - Added support for special variables
$$and#in custom methods and assertions defined as strings (Jora queries). - Updated the pipeline operator grammar to allow starting a query with it, e.g.
| expris now a valid query - Fixed a query compilation error when
$was used as an object entry, e.g.{ $, prop: 1 } - Fixed bracket notation and
pick()method when used with a function to applybool()to the result of the function - Reverted the precedence of the pipeline operator to be lower than that of the ternary operator for consistency with other operators
1.0.0-beta.9
- Removed support for a legacy syntax for functions, i.e.
<expr> - Changed the precedence of the pipeline operator to match that of the ternary operator to prevent parsing errors in certain cases
- Disallowed whitespace between a method name and open parenthesis
- Allowed keywords as a property getter in query chains when a dot is before the keyword. For example,
.has.and.isis now a valid query, whilehas.andis not valid due to the missing dot beforehas. - Added support for keyword literals (
null,undefined,true,false,NaNandInfinity), numbers and strings as property name in an object literal when a value is not specified, i.e.{ null }is the same as{ "null": $["null"] } - Added suggestions listing for keyword literals as property name in an object literal
- Fixed suggestions listing inside empty parentheses
- Fixed suggestions listing for
isoperator in tolerant mode when right part is empty - Fixed duplicates in
hasoperator suggestions - Removed missed experimental
if,thenandelsekeyword tokens in parser
1.0.0-beta.8 Assertions and lots of new query methods
- Reduced parser size by 10Kb
- Changed
setup()function to takeoptionsparameter instead of custom methods dictionary, i.e.setup(methods)→setup({ methods }) - Added
assertionsoption forjora()andsetup()functions to specify additional assertion functions, i.e.jora(..., { assetions })andsetup({ assertions }) - Forbidden to override built-in methods and assertions, now
setup()andquery()functions throws when a custom method or an assertion has the same name as built-in one - Extended query result object in stat mode to provide a result value of the query execution as
valueproperty (i.e.jora(query, { stat: true })().value) - Renamed
SortingFunctionAST node type intoCompareFunction - Renamed
UnaryAST node type intoPrefix - Added
AssertionandPostfixAST node types - Added nullish coalescing operator (
??) - Added
isoperator - Added
replace()method - Added
min()andmax()methods - Added
numbers(),sum(),avg(),count(),variance(),stdev(),percentile()(with aliasp()) andmedian()methods - Added
indexOf()andlastIndexOf()methods - Added
toLowerCase(),toUpperCase()andtrim()methods - Added math methods
abs(),acos(),acosh(),asin(),asinh(),atan(),atan2(),atanh(),cbrt(),ceil(),clz32(),cos(),cosh(),exp(),expm1(),floor(),fround(),hypot(),imul(),ln()(Math.log()in JavaScript),log10(),ln1p()(Math.log1p()in JavaScript),log2(),pow(),round(),sign(),sin(),sinh(),sqrt(),tan(),tanh()andtrunc()(see details in docs) - Modified the ternary operator to allow optional components. The
:can be omitted if the last part is excluded. For instance, the following are now valid syntaxes:expr ? : [],expr ? 1, andexpr?. When omitted, the default structure will be:$ ? $ : undefined - Changed the comparator function grammar to allow any expression in the definition, not just a query chain. This eliminates the need for parentheses in many cases. For example,
a + b descis now a valid definition, whereas previously it required parentheses:(a + b) desc(since evaluated asa + (b desc)). - Changed precedence of function definitions to be lower than that of the pipeline operator and comparator function definitions (i.e., the lowest precedence). For example, the expression
=> a | bnow evaluates as=> (a | b)instead of(=> a) | bas before, meaning it returns a function instead of the value ofb. - Changed
split()method to support arrays, in that casepatterncan be a function or any value - Fixed
in,not in,hasandhas nooperators to handleNaNvalues correctly, e.g.NaN in [1, NaN, 3]returnstruenow
1.0.0-beta.7
- Fixed
syntax.tokenize()method to use a tolerant parser whentolerantModeparameter istrue - Fixed parsing failures in tolerant mode on blocks
[],.[],(),.()and..()when their body starts with an operator, a keyword, etc. - Fixed suggestions when pattern is a single quoted string (i.e. for
'foo'in.[field='foo']) - Fixed suggestions for
Picknodes when query is a complex expression, e.g. a function (#35) - Fixed suggestions for
Blocknodes with empty body in strict parse mode - Fixed processing
\0in strings as a null character for a parity with JavaScript - Fixed
Indentifiernode to store an empty string as a name instead of_for placeholder identifiers in tolerant parse mode. This fixes the problem of restoring a query from an AST after parsing in tolerant mode - Added
Placeholdernode type - Changed
Blocknode to store aPlaceholdernode instead ofnullwhen block's body is empty
1.0.0-beta.6 Dual package, new stat API, suggestions and error precision improvements, and more
- Added support for custom methods as a string (jora query) in
jora.setup() - Added a check for all methods are defined on query compilation step to avoid runtime exceptions
- Allowed
g,m,sanduflags in regexp literals - Improved error message when a methods is not defined, i.e.
Method "foo" is not definedinstead ofm.foo is not a function - Improved error locations in string literals
- Disallowed a backslash before closing quote or apostrophe in string literals
- Fixed
match()method to work well for RegExp withgflag and for strings whenmatchAllis true - Fixed
sort()method to perform a stable sort for old js-engines and always placeundefinedvalues last - Fixed range in details for bad input errors
- Fixed suggestion support in template literals (#33)
- Fixed suggestions for
=and!=operators by avoiding unfold array values - Fixed suggestions for arrays in
in,not in,hasandhas nooperators to exclude literal values only - Removed value suggestions in cases
| in <string or number>and<string or number> has | - Fixed a call stack overflow exception when too many (over ~110k) suggestion values for a range
- BREAKING Reworked stat API:
- Changed
stat()method result value to returnvaluesas is, i.e. aSetinstance instead of its materialization as an array. Mutations of sets (valuesandrelated) should be avoided since they are shared between all stat API methods calls. - Changed a signature of
suggestion()method to getoptionsas a second argument (optional), with the following options:limit(default:Infinity) – a max number of the values that should be returned for each value type ("property","value"or"variable")sort(default:false) – a comparator function (should take 2 arguments and return a negative number,0or a positive number) for value list sorting, makes sence whenlimitis usedfilter(default:function) – a filter function factory (pattern => value => <expr>) to discard values from the result when returns a falsy value (default is equivalent topatttern => value => String(value).toLowerCase().includes(pattern))
- Changed
suggestion()method result to return values grouped by a type:suggestion(): Array<{ type: 'property' | 'value' | 'variable', from: number, to: number, text: string, suggestions: Array<string | number> }> | null
- All the changes are targeted to improve performance and memory consumption when a query is performing to a huge datasets (hundreds of thousands of values). As a result a suggestions fetching is boosted up to 30-40 times for such cases.
- Changed
- Converted to Dual Package, i.e. ESM and CommonJS support
- Changed Node.js support to
^10.12.0 || ^12.20.0 || ^14.13.0 || >=15.0.0 - Changed dist modules:
- Removed
jora.min.js - Changed
jora.jsformat from CJS to IIFE and applied minification - Added
jora.esm.js(minified ESM module) - Added source maps
jora.js.map&jora.esm.js.map
- Removed