Skip to content

1.0.0-beta.8 Assertions and lots of new query methods

Compare
Choose a tag to compare
@lahmatiy lahmatiy released this 22 Sep 01:08
  • Reduced parser size by 10Kb
  • Changed setup() function to take options parameter instead of custom methods dictionary, i.e. setup(methods)setup({ methods })
  • Added assertions option for jora() and setup() functions to specify additional assertion functions, i.e. jora(..., { assetions }) and setup({ assertions })
  • Forbidden to override built-in methods and assertions, now setup() and query() 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 value property (i.e. jora(query, { stat: true })().value)
  • Renamed SortingFunction AST node type into CompareFunction
  • Renamed Unary AST node type into Prefix
  • Added Assertion and Postfix AST node types
  • Added nullish coalescing operator (??)
  • Added is operator
  • Added replace() method
  • Added min() and max() methods
  • Added numbers(), sum(), avg(), count(), variance(), stdev(), percentile() (with alias p()) and median() methods
  • Added indexOf() and lastIndexOf() methods
  • Added toLowerCase(), toUpperCase() and trim() 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() and trunc() (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, and expr?. 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 desc is now a valid definition, whereas previously it required parentheses: (a + b) desc (since evaluated as a + (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 | b now evaluates as => (a | b) instead of (=> a) | b as before, meaning it returns a function instead of the value of b.
  • Changed split() method to support arrays, in that case pattern can be a function or any value
  • Fixed in, not in, has and has no operators to handle NaN values correctly, e.g. NaN in [1, NaN, 3] returns true now