Changelog
1.0.0-beta.13 (September 10, 2024)
($a, $a) => expr
is now prohibited?:
)and
, or
and ??
operatorsfunction
expressions in stat mode in some casescomparator function
in some scenariosnumbers()
, avg()
, count()
, sum()
, median()
, variance()
, stdev()
and percentile()
package.json
and dist/*
Changelog
1.0.0-beta.12 (July 2, 2024)
_
as numeric separator for all kinds of number, e.g. 1_000
, 0xa0b1_c2d3
{
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()`
}
Changelog
1.0.0-beta.11 (May 19, 2024)
lastIndexOf()
method behavior when fromIndex
is zero; previously, the search incorrectly started from the end of an array instead of the zero positiongroup()
method to include elements with an empty array as a key in the group with key: undefined
; previously, such elements were omitted from the resultfrom
is greater than to
and step
is not specified, step
defaults to -1
(i.e. $[3:1]
is the same as $[1:3:-1]
)from
is greater than to
and step
is specified, the sign of the step
is inverted (i.e. $[5:1:-2]
is the same as $[1:5:2]
)Changelog
1.0.0-beta.10 (December 6, 2023)
$arg => expr
and ($a, $b) => expr
forms to be supportedthis
in custom methods and assertions defined as functions to include a context
reference to the query context. Additionally, introduced this.method(name, ...args)
and this.assertion(name, ...args)
methods to call a custom method or use an assertion.$$
and #
in custom methods and assertions defined as strings (Jora queries).| expr
is now a valid query$
was used as an object entry, e.g. { $, prop: 1 }
pick()
method when used with a function to apply bool()
to the result of the functionChangelog
1.0.0-beta.9 (October 29, 2023)
<expr>
.has.and.is
is now a valid query, while has.and
is not valid due to the missing dot before has
.null
, undefined
, true
, false
, NaN
and Infinity
), 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"] }
is
operator in tolerant mode when right part is emptyhas
operator suggestionsif
, then
and else
keyword tokens in parserChangelog
1.0.0-beta.8 (September 21, 2023)
setup()
function to take options
parameter instead of custom methods dictionary, i.e. setup(methods)
→ setup({ methods })
assertions
option for jora()
and setup()
functions to specify additional assertion functions, i.e. jora(..., { assetions })
and setup({ assertions })
setup()
and query()
functions throws when a custom method or an assertion has the same name as built-in onevalue
property (i.e. jora(query, { stat: true })().value
)SortingFunction
AST node type into CompareFunction
Unary
AST node type into Prefix
Assertion
and Postfix
AST node types??
)is
operatorreplace()
methodmin()
and max()
methodsnumbers()
, sum()
, avg()
, count()
, variance()
, stdev()
, percentile()
(with alias p()
) and median()
methodsindexOf()
and lastIndexOf()
methodstoLowerCase()
, toUpperCase()
and trim()
methodsabs()
, 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()
and trunc()
(see details in docs):
can be omitted if the last part is excluded. For instance, the following are now valid syntaxes: expr ? : []
, expr ? 1
, and expr?
. When omitted, the default structure will be: $ ? $ : undefined
a + b desc
is now a valid definition, whereas previously it required parentheses: (a + b) desc
(since evaluated as a + (b desc)
).=> a | b
now evaluates as => (a | b)
instead of (=> a) | b
as before, meaning it returns a function instead of the value of b
.split()
method to support arrays, in that case pattern
can be a function or any valuein
, not in
, has
and has no
operators to handle NaN
values correctly, e.g. NaN in [1, NaN, 3]
returns true
nowChangelog
1.0.0-beta.7 (July 12, 2022)
syntax.tokenize()
method to use a tolerant parser when tolerantMode
parameter is true
[]
, .[]
, ()
, .()
and ..()
when their body starts with an operator, a keyword, etc.'foo'
in .[field='foo']
)Pick
nodes when query is a complex expression, e.g. a function (#35)Block
nodes with empty body in strict parse mode\0
in strings as a null character for a parity with JavaScriptIndentifier
node 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 modePlaceholder
node typeBlock
node to store a Placeholder
node instead of null
when block's body is emptyChangelog
1.0.0-beta.6 (April 18, 2022)
jora.setup()
g
, m
, s
and u
flags in regexp literalsMethod "foo" is not defined
instead of m.foo is not a function
match()
method to work well for RegExp with g
flag and for strings when matchAll
is truesort()
method to perform a stable sort for old js-engines and always place undefined
values last=
and !=
operators by avoiding unfold array valuesin
, not in
, has
and has no
operators to exclude literal values only| in <string or number>
and <string or number> has |
stat()
API method to return values
as is, i.e. a Set
instance instead of its materialization as an array. Mutations of sets (values
and related
) should be avoided since they are shared between all stat API methods calls.suggestion()
API method to get options
as 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, 0
or a positive number) for value list sorting, makes sence when limit
is usedfilter
(default: function
) – a filter function factory (pattern => value => <expr>
) to discard values from the result when returns a falsy value (default is equivalent to patttern => value => String(value).toLowerCase().includes(pattern)
)suggestion()
API 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
^10.12.0 || ^12.20.0 || ^14.13.0 || >=15.0.0
jora.min.js
jora.js
format from CJS to IIFE and applied minificationjora.esm.js
(minified ESM module)jora.js.map
& jora.esm.js.map
Changelog
1.0.0-beta.5 (November 10, 2020)
'hello\x20world'
Infinity
and NaN
literals\r\n
, \u2028
and \u2029
)$
when a value is definedChangelog
1.0.0-beta.4 (November 4, 2020)
{ $a: 42; foo: $a * 2, $a }
results in { foo: 84, a: 42 }
setup()
API method to create a query function with defined custom methods oncesyntax.suggest(source, parseResult)
method to get suggestion ranges based on AST and sourcesyntax.tokenize(source, tolerantMode = false)
method