Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metrichor/jmespath

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metrichor/jmespath - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

dist/jmespath.esm.min.js

20

dist/lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.jmespath = exports.TreeInterpreter = exports.search = exports.registerFunction = exports.tokenize = exports.compile = exports.TYPE_STRING = exports.TYPE_OBJECT = exports.TYPE_NUMBER = exports.TYPE_NULL = exports.TYPE_EXPREF = exports.TYPE_BOOLEAN = exports.TYPE_ARRAY_STRING = exports.TYPE_ARRAY_NUMBER = exports.TYPE_ARRAY = exports.TYPE_ANY = void 0;
var Parser_1 = require("./Parser");
var Lexer_1 = require("./Lexer");
var TreeInterpreter_1 = require("./TreeInterpreter");
var index_1 = require("./typings/index");
const Parser_1 = require("./Parser");
const Lexer_1 = require("./Lexer");
const TreeInterpreter_1 = require("./TreeInterpreter");
const index_1 = require("./typings/index");
exports.TYPE_ANY = index_1.InputArgument.TYPE_ANY;

@@ -19,3 +19,3 @@ exports.TYPE_ARRAY = index_1.InputArgument.TYPE_ARRAY;

function compile(expression) {
var nodeTree = Parser_1.default.parse(expression);
const nodeTree = Parser_1.default.parse(expression);
return nodeTree;

@@ -28,7 +28,7 @@ }

exports.tokenize = tokenize;
exports.registerFunction = function (functionName, customFunction, signature) {
exports.registerFunction = (functionName, customFunction, signature) => {
TreeInterpreter_1.default.runtime.registerFunction(functionName, customFunction, signature);
};
function search(data, expression) {
var nodeTree = Parser_1.default.parse(expression);
const nodeTree = Parser_1.default.parse(expression);
return TreeInterpreter_1.default.search(nodeTree, data);

@@ -39,6 +39,6 @@ }

exports.jmespath = {
compile: compile,
compile,
registerFunction: exports.registerFunction,
search: search,
tokenize: tokenize,
search,
tokenize,
TreeInterpreter: exports.TreeInterpreter,

@@ -45,0 +45,0 @@ TYPE_ANY: exports.TYPE_ANY,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lexer = exports.basicTokens = void 0;
var typings_1 = require("./typings");
var utils_1 = require("./utils");
const typings_1 = require("./typings");
const utils_1 = require("./utils");
exports.basicTokens = {

@@ -18,3 +18,3 @@ '(': typings_1.Token.TOK_LPAREN,

};
var operatorStartToken = {
const operatorStartToken = {
'!': true,

@@ -25,3 +25,3 @@ '<': true,

};
var skipChars = {
const skipChars = {
'\t': true,

@@ -32,12 +32,12 @@ '\n': true,

};
var StreamLexer = /** @class */ (function () {
function StreamLexer() {
class StreamLexer {
constructor() {
this._current = 0;
}
StreamLexer.prototype.tokenize = function (stream) {
var tokens = [];
tokenize(stream) {
const tokens = [];
this._current = 0;
var start;
var identifier;
var token;
let start;
let identifier;
let token;
while (this._current < stream.length) {

@@ -48,3 +48,3 @@ if (utils_1.isAlpha(stream[this._current])) {

tokens.push({
start: start,
start,
type: typings_1.Token.TOK_UNQUOTEDIDENTIFIER,

@@ -74,3 +74,3 @@ value: identifier,

tokens.push({
start: start,
start,
type: typings_1.Token.TOK_QUOTEDIDENTIFIER,

@@ -80,7 +80,7 @@ value: identifier,

}
else if (stream[this._current] === "'") {
else if (stream[this._current] === `'`) {
start = this._current;
identifier = this.consumeRawStringLiteral(stream);
tokens.push({
start: start,
start,
type: typings_1.Token.TOK_LITERAL,

@@ -92,5 +92,5 @@ value: identifier,

start = this._current;
var literal = this.consumeLiteral(stream);
const literal = this.consumeLiteral(stream);
tokens.push({
start: start,
start,
type: typings_1.Token.TOK_LITERAL,

@@ -112,6 +112,6 @@ value: literal,

this._current += 1;
tokens.push({ start: start, type: typings_1.Token.TOK_AND, value: '&&' });
tokens.push({ start, type: typings_1.Token.TOK_AND, value: '&&' });
}
else {
tokens.push({ start: start, type: typings_1.Token.TOK_EXPREF, value: '&' });
tokens.push({ start, type: typings_1.Token.TOK_EXPREF, value: '&' });
}

@@ -124,10 +124,10 @@ }

this._current += 1;
tokens.push({ start: start, type: typings_1.Token.TOK_OR, value: '||' });
tokens.push({ start, type: typings_1.Token.TOK_OR, value: '||' });
}
else {
tokens.push({ start: start, type: typings_1.Token.TOK_PIPE, value: '|' });
tokens.push({ start, type: typings_1.Token.TOK_PIPE, value: '|' });
}
}
else {
var error = new Error("Unknown character: " + stream[this._current]);
const error = new Error(`Unknown character: ${stream[this._current]}`);
error.name = 'LexerError';

@@ -138,5 +138,5 @@ throw error;

return tokens;
};
StreamLexer.prototype.consumeUnquotedIdentifier = function (stream) {
var start = this._current;
}
consumeUnquotedIdentifier(stream) {
const start = this._current;
this._current += 1;

@@ -147,9 +147,9 @@ while (this._current < stream.length && utils_1.isAlphaNum(stream[this._current])) {

return stream.slice(start, this._current);
};
StreamLexer.prototype.consumeQuotedIdentifier = function (stream) {
var start = this._current;
}
consumeQuotedIdentifier(stream) {
const start = this._current;
this._current += 1;
var maxLength = stream.length;
const maxLength = stream.length;
while (stream[this._current] !== '"' && this._current < maxLength) {
var current = this._current;
let current = this._current;
if (stream[current] === '\\' && (stream[current + 1] === '\\' || stream[current + 1] === '"')) {

@@ -165,10 +165,10 @@ current += 2;

return JSON.parse(stream.slice(start, this._current));
};
StreamLexer.prototype.consumeRawStringLiteral = function (stream) {
var start = this._current;
}
consumeRawStringLiteral(stream) {
const start = this._current;
this._current += 1;
var maxLength = stream.length;
while (stream[this._current] !== "'" && this._current < maxLength) {
var current = this._current;
if (stream[current] === '\\' && (stream[current + 1] === '\\' || stream[current + 1] === "'")) {
const maxLength = stream.length;
while (stream[this._current] !== `'` && this._current < maxLength) {
let current = this._current;
if (stream[current] === '\\' && (stream[current + 1] === '\\' || stream[current + 1] === `'`)) {
current += 2;

@@ -182,31 +182,31 @@ }

this._current += 1;
var literal = stream.slice(start + 1, this._current - 1);
return literal.replace("\\'", "'");
};
StreamLexer.prototype.consumeNumber = function (stream) {
var start = this._current;
const literal = stream.slice(start + 1, this._current - 1);
return literal.replace(`\\'`, `'`);
}
consumeNumber(stream) {
const start = this._current;
this._current += 1;
var maxLength = stream.length;
const maxLength = stream.length;
while (utils_1.isNum(stream[this._current]) && this._current < maxLength) {
this._current += 1;
}
var value = parseInt(stream.slice(start, this._current), 10);
return { start: start, value: value, type: typings_1.Token.TOK_NUMBER };
};
StreamLexer.prototype.consumeLBracket = function (stream) {
var start = this._current;
const value = parseInt(stream.slice(start, this._current), 10);
return { start, value, type: typings_1.Token.TOK_NUMBER };
}
consumeLBracket(stream) {
const start = this._current;
this._current += 1;
if (stream[this._current] === '?') {
this._current += 1;
return { start: start, type: typings_1.Token.TOK_FILTER, value: '[?' };
return { start, type: typings_1.Token.TOK_FILTER, value: '[?' };
}
if (stream[this._current] === ']') {
this._current += 1;
return { start: start, type: typings_1.Token.TOK_FLATTEN, value: '[]' };
return { start, type: typings_1.Token.TOK_FLATTEN, value: '[]' };
}
return { start: start, type: typings_1.Token.TOK_LBRACKET, value: '[' };
};
StreamLexer.prototype.consumeOperator = function (stream) {
var start = this._current;
var startingChar = stream[start];
return { start, type: typings_1.Token.TOK_LBRACKET, value: '[' };
}
consumeOperator(stream) {
const start = this._current;
const startingChar = stream[start];
this._current += 1;

@@ -216,5 +216,5 @@ if (startingChar === '!') {

this._current += 1;
return { start: start, type: typings_1.Token.TOK_NE, value: '!=' };
return { start, type: typings_1.Token.TOK_NE, value: '!=' };
}
return { start: start, type: typings_1.Token.TOK_NOT, value: '!' };
return { start, type: typings_1.Token.TOK_NOT, value: '!' };
}

@@ -224,5 +224,5 @@ if (startingChar === '<') {

this._current += 1;
return { start: start, type: typings_1.Token.TOK_LTE, value: '<=' };
return { start, type: typings_1.Token.TOK_LTE, value: '<=' };
}
return { start: start, type: typings_1.Token.TOK_LT, value: '<' };
return { start, type: typings_1.Token.TOK_LT, value: '<' };
}

@@ -232,17 +232,17 @@ if (startingChar === '>') {

this._current += 1;
return { start: start, type: typings_1.Token.TOK_GTE, value: '>=' };
return { start, type: typings_1.Token.TOK_GTE, value: '>=' };
}
return { start: start, type: typings_1.Token.TOK_GT, value: '>' };
return { start, type: typings_1.Token.TOK_GT, value: '>' };
}
if (startingChar === '=' && stream[this._current] === '=') {
this._current += 1;
return { start: start, type: typings_1.Token.TOK_EQ, value: '==' };
return { start, type: typings_1.Token.TOK_EQ, value: '==' };
}
};
StreamLexer.prototype.consumeLiteral = function (stream) {
}
consumeLiteral(stream) {
this._current += 1;
var start = this._current;
var maxLength = stream.length;
const start = this._current;
const maxLength = stream.length;
while (stream[this._current] !== '`' && this._current < maxLength) {
var current = this._current;
let current = this._current;
if (stream[current] === '\\' && (stream[current + 1] === '\\' || stream[current + 1] === '`')) {

@@ -256,12 +256,12 @@ current += 2;

}
var literalString = utils_1.trimLeft(stream.slice(start, this._current));
let literalString = utils_1.trimLeft(stream.slice(start, this._current));
literalString = literalString.replace('\\`', '`');
var literal = this.looksLikeJSON(literalString) ? JSON.parse(literalString) : JSON.parse("\"" + literalString + "\"");
const literal = this.looksLikeJSON(literalString) ? JSON.parse(literalString) : JSON.parse(`"${literalString}"`);
this._current += 1;
return literal;
};
StreamLexer.prototype.looksLikeJSON = function (literalString) {
var startingChars = '[{"';
var jsonLiterals = ['true', 'false', 'null'];
var numberLooking = '-0123456789';
}
looksLikeJSON(literalString) {
const startingChars = '[{"';
const jsonLiterals = ['true', 'false', 'null'];
const numberLooking = '-0123456789';
if (literalString === '') {

@@ -286,7 +286,6 @@ return false;

return false;
};
return StreamLexer;
}());
}
}
exports.Lexer = new StreamLexer();
exports.default = exports.Lexer;
//# sourceMappingURL=Lexer.js.map
"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = void 0;
var typings_1 = require("./typings");
var Lexer_1 = require("./Lexer");
var bindingPower = (_a = {},
_a[typings_1.Token.TOK_EOF] = 0,
_a[typings_1.Token.TOK_UNQUOTEDIDENTIFIER] = 0,
_a[typings_1.Token.TOK_QUOTEDIDENTIFIER] = 0,
_a[typings_1.Token.TOK_RBRACKET] = 0,
_a[typings_1.Token.TOK_RPAREN] = 0,
_a[typings_1.Token.TOK_COMMA] = 0,
_a[typings_1.Token.TOK_RBRACE] = 0,
_a[typings_1.Token.TOK_NUMBER] = 0,
_a[typings_1.Token.TOK_CURRENT] = 0,
_a[typings_1.Token.TOK_EXPREF] = 0,
_a[typings_1.Token.TOK_PIPE] = 1,
_a[typings_1.Token.TOK_OR] = 2,
_a[typings_1.Token.TOK_AND] = 3,
_a[typings_1.Token.TOK_EQ] = 5,
_a[typings_1.Token.TOK_GT] = 5,
_a[typings_1.Token.TOK_LT] = 5,
_a[typings_1.Token.TOK_GTE] = 5,
_a[typings_1.Token.TOK_LTE] = 5,
_a[typings_1.Token.TOK_NE] = 5,
_a[typings_1.Token.TOK_FLATTEN] = 9,
_a[typings_1.Token.TOK_STAR] = 20,
_a[typings_1.Token.TOK_FILTER] = 21,
_a[typings_1.Token.TOK_DOT] = 40,
_a[typings_1.Token.TOK_NOT] = 45,
_a[typings_1.Token.TOK_LBRACE] = 50,
_a[typings_1.Token.TOK_LBRACKET] = 55,
_a[typings_1.Token.TOK_LPAREN] = 60,
_a);
var TokenParser = /** @class */ (function () {
function TokenParser() {
const typings_1 = require("./typings");
const Lexer_1 = require("./Lexer");
const bindingPower = {
[typings_1.Token.TOK_EOF]: 0,
[typings_1.Token.TOK_UNQUOTEDIDENTIFIER]: 0,
[typings_1.Token.TOK_QUOTEDIDENTIFIER]: 0,
[typings_1.Token.TOK_RBRACKET]: 0,
[typings_1.Token.TOK_RPAREN]: 0,
[typings_1.Token.TOK_COMMA]: 0,
[typings_1.Token.TOK_RBRACE]: 0,
[typings_1.Token.TOK_NUMBER]: 0,
[typings_1.Token.TOK_CURRENT]: 0,
[typings_1.Token.TOK_EXPREF]: 0,
[typings_1.Token.TOK_PIPE]: 1,
[typings_1.Token.TOK_OR]: 2,
[typings_1.Token.TOK_AND]: 3,
[typings_1.Token.TOK_EQ]: 5,
[typings_1.Token.TOK_GT]: 5,
[typings_1.Token.TOK_LT]: 5,
[typings_1.Token.TOK_GTE]: 5,
[typings_1.Token.TOK_LTE]: 5,
[typings_1.Token.TOK_NE]: 5,
[typings_1.Token.TOK_FLATTEN]: 9,
[typings_1.Token.TOK_STAR]: 20,
[typings_1.Token.TOK_FILTER]: 21,
[typings_1.Token.TOK_DOT]: 40,
[typings_1.Token.TOK_NOT]: 45,
[typings_1.Token.TOK_LBRACE]: 50,
[typings_1.Token.TOK_LBRACKET]: 55,
[typings_1.Token.TOK_LPAREN]: 60,
};
class TokenParser {
constructor() {
this.index = 0;
this.tokens = [];
}
TokenParser.prototype.parse = function (expression) {
parse(expression) {
this.loadTokens(expression);
this.index = 0;
var ast = this.expression(0);
const ast = this.expression(0);
if (this.lookahead(0) !== typings_1.Token.TOK_EOF) {
var token = this.lookaheadToken(0);
this.errorToken(token, "Unexpected token type: " + token.type + ", value: " + token.value);
const token = this.lookaheadToken(0);
this.errorToken(token, `Unexpected token type: ${token.type}, value: ${token.value}`);
}
return ast;
};
TokenParser.prototype.loadTokens = function (expression) {
this.tokens = __spreadArrays(Lexer_1.default.tokenize(expression), [{ type: typings_1.Token.TOK_EOF, value: '', start: expression.length }]);
};
TokenParser.prototype.expression = function (rbp) {
var leftToken = this.lookaheadToken(0);
}
loadTokens(expression) {
this.tokens = [...Lexer_1.default.tokenize(expression), { type: typings_1.Token.TOK_EOF, value: '', start: expression.length }];
}
expression(rbp) {
const leftToken = this.lookaheadToken(0);
this.advance();
var left = this.nud(leftToken);
var currentTokenType = this.lookahead(0);
let left = this.nud(leftToken);
let currentTokenType = this.lookahead(0);
while (rbp < bindingPower[currentTokenType]) {

@@ -72,16 +64,16 @@ this.advance();

return left;
};
TokenParser.prototype.lookahead = function (offset) {
}
lookahead(offset) {
return this.tokens[this.index + offset].type;
};
TokenParser.prototype.lookaheadToken = function (offset) {
}
lookaheadToken(offset) {
return this.tokens[this.index + offset];
};
TokenParser.prototype.advance = function () {
}
advance() {
this.index += 1;
};
TokenParser.prototype.nud = function (token) {
var left;
var right;
var expression;
}
nud(token) {
let left;
let right;
let expression;
switch (token.type) {

@@ -93,3 +85,3 @@ case typings_1.Token.TOK_LITERAL:

case typings_1.Token.TOK_QUOTEDIDENTIFIER:
var node = { type: 'Field', name: token.value };
const node = { type: 'Field', name: token.value };
if (this.lookahead(0) === typings_1.Token.TOK_LPAREN) {

@@ -139,3 +131,3 @@ throw new Error('Quoted identifier not allowed for function names.');

case typings_1.Token.TOK_LPAREN:
var args = [];
const args = [];
while (this.lookahead(0) !== typings_1.Token.TOK_RPAREN) {

@@ -156,8 +148,8 @@ if (this.lookahead(0) === typings_1.Token.TOK_CURRENT) {

}
};
TokenParser.prototype.led = function (tokenName, left) {
var right;
}
led(tokenName, left) {
let right;
switch (tokenName) {
case typings_1.Token.TOK_DOT:
var rbp = bindingPower.Dot;
const rbp = bindingPower.Dot;
if (this.lookahead(0) !== typings_1.Token.TOK_STAR) {

@@ -180,5 +172,5 @@ right = this.parseDotRHS(rbp);

case typings_1.Token.TOK_LPAREN:
var name_1 = left.name;
var args = [];
var expression = void 0;
const name = left.name;
const args = [];
let expression;
while (this.lookahead(0) !== typings_1.Token.TOK_RPAREN) {

@@ -198,6 +190,6 @@ if (this.lookahead(0) === typings_1.Token.TOK_CURRENT) {

this.match(typings_1.Token.TOK_RPAREN);
var node = { name: name_1, type: 'Function', children: args };
const node = { name, type: 'Function', children: args };
return node;
case typings_1.Token.TOK_FILTER:
var condition = this.expression(0);
const condition = this.expression(0);
this.match(typings_1.Token.TOK_RBRACKET);

@@ -209,4 +201,4 @@ right =

case typings_1.Token.TOK_FLATTEN:
var leftNode = { type: typings_1.Token.TOK_FLATTEN, children: [left] };
var rightNode = this.parseProjectionRHS(bindingPower.Flatten);
const leftNode = { type: typings_1.Token.TOK_FLATTEN, children: [left] };
const rightNode = this.parseProjectionRHS(bindingPower.Flatten);
return { type: 'Projection', children: [leftNode, rightNode] };

@@ -221,3 +213,3 @@ case typings_1.Token.TOK_EQ:

case typings_1.Token.TOK_LBRACKET:
var token = this.lookaheadToken(0);
const token = this.lookaheadToken(0);
if (token.type === typings_1.Token.TOK_NUMBER || token.type === typings_1.Token.TOK_COLON) {

@@ -234,4 +226,4 @@ right = this.parseIndexExpression();

}
};
TokenParser.prototype.match = function (tokenType) {
}
match(tokenType) {
if (this.lookahead(0) === tokenType) {

@@ -242,17 +234,16 @@ this.advance();

else {
var token = this.lookaheadToken(0);
this.errorToken(token, "Expected " + tokenType + ", got: " + token.type);
const token = this.lookaheadToken(0);
this.errorToken(token, `Expected ${tokenType}, got: ${token.type}`);
}
};
TokenParser.prototype.errorToken = function (token, message) {
if (message === void 0) { message = ''; }
var error = new Error(message || "Invalid token (" + token.type + "): \"" + token.value + "\"");
}
errorToken(token, message = '') {
const error = new Error(message || `Invalid token (${token.type}): "${token.value}"`);
error.name = 'ParserError';
throw error;
};
TokenParser.prototype.parseIndexExpression = function () {
}
parseIndexExpression() {
if (this.lookahead(0) === typings_1.Token.TOK_COLON || this.lookahead(1) === typings_1.Token.TOK_COLON) {
return this.parseSliceExpression();
}
var node = {
const node = {
type: 'Index',

@@ -264,5 +255,5 @@ value: this.lookaheadToken(0).value,

return node;
};
TokenParser.prototype.projectIfSlice = function (left, right) {
var indexExpr = { type: 'IndexExpression', children: [left, right] };
}
projectIfSlice(left, right) {
const indexExpr = { type: 'IndexExpression', children: [left, right] };
if (right.type === 'Slice') {

@@ -275,7 +266,7 @@ return {

return indexExpr;
};
TokenParser.prototype.parseSliceExpression = function () {
var parts = [null, null, null];
var index = 0;
var currentTokenType = this.lookahead(0);
}
parseSliceExpression() {
const parts = [null, null, null];
let index = 0;
let currentTokenType = this.lookahead(0);
while (currentTokenType !== typings_1.Token.TOK_RBRACKET && index < 3) {

@@ -291,4 +282,4 @@ if (currentTokenType === typings_1.Token.TOK_COLON) {

else {
var token = this.lookaheadToken(0);
this.errorToken(token, "Syntax error, unexpected token: " + token.value + "(" + token.type + ")");
const token = this.lookaheadToken(0);
this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
}

@@ -302,10 +293,10 @@ currentTokenType = this.lookahead(0);

};
};
TokenParser.prototype.parseComparator = function (left, comparator) {
var right = this.expression(bindingPower[comparator]);
}
parseComparator(left, comparator) {
const right = this.expression(bindingPower[comparator]);
return { type: 'Comparator', name: comparator, children: [left, right] };
};
TokenParser.prototype.parseDotRHS = function (rbp) {
var lookahead = this.lookahead(0);
var exprTokens = [typings_1.Token.TOK_UNQUOTEDIDENTIFIER, typings_1.Token.TOK_QUOTEDIDENTIFIER, typings_1.Token.TOK_STAR];
}
parseDotRHS(rbp) {
const lookahead = this.lookahead(0);
const exprTokens = [typings_1.Token.TOK_UNQUOTEDIDENTIFIER, typings_1.Token.TOK_QUOTEDIDENTIFIER, typings_1.Token.TOK_STAR];
if (exprTokens.includes(lookahead)) {

@@ -322,6 +313,6 @@ return this.expression(rbp);

}
var token = this.lookaheadToken(0);
this.errorToken(token, "Syntax error, unexpected token: " + token.value + "(" + token.type + ")");
};
TokenParser.prototype.parseProjectionRHS = function (rbp) {
const token = this.lookaheadToken(0);
this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
}
parseProjectionRHS(rbp) {
if (bindingPower[this.lookahead(0)] < 10) {

@@ -340,9 +331,9 @@ return { type: 'Identity' };

}
var token = this.lookaheadToken(0);
this.errorToken(token, "Syntax error, unexpected token: " + token.value + "(" + token.type + ")");
};
TokenParser.prototype.parseMultiselectList = function () {
var expressions = [];
const token = this.lookaheadToken(0);
this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
}
parseMultiselectList() {
const expressions = [];
while (this.lookahead(0) !== typings_1.Token.TOK_RBRACKET) {
var expression = this.expression(0);
const expression = this.expression(0);
expressions.push(expression);

@@ -358,10 +349,10 @@ if (this.lookahead(0) === typings_1.Token.TOK_COMMA) {

return { type: 'MultiSelectList', children: expressions };
};
TokenParser.prototype.parseMultiselectHash = function () {
var pairs = [];
var identifierTypes = [typings_1.Token.TOK_UNQUOTEDIDENTIFIER, typings_1.Token.TOK_QUOTEDIDENTIFIER];
var keyToken;
var keyName;
var value;
var node;
}
parseMultiselectHash() {
const pairs = [];
const identifierTypes = [typings_1.Token.TOK_UNQUOTEDIDENTIFIER, typings_1.Token.TOK_QUOTEDIDENTIFIER];
let keyToken;
let keyName;
let value;
let node;
// tslint:disable-next-line: prettier

@@ -371,3 +362,3 @@ for (;;) {

if (!identifierTypes.includes(keyToken.type)) {
throw new Error("Expecting an identifier token, got: " + keyToken.type);
throw new Error(`Expecting an identifier token, got: ${keyToken.type}`);
}

@@ -378,3 +369,3 @@ keyName = keyToken.value;

value = this.expression(0);
node = { value: value, type: 'KeyValuePair', name: keyName };
node = { value, type: 'KeyValuePair', name: keyName };
pairs.push(node);

@@ -390,7 +381,6 @@ if (this.lookahead(0) === typings_1.Token.TOK_COMMA) {

return { type: 'MultiSelectHash', children: pairs };
};
return TokenParser;
}());
}
}
exports.Parser = new TokenParser();
exports.default = exports.Parser;
//# sourceMappingURL=Parser.js.map
"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Runtime = void 0;
var typings_1 = require("./typings");
var utils_1 = require("./utils");
var Runtime = /** @class */ (function () {
function Runtime(interpreter) {
var _a;
var _this = this;
this.TYPE_NAME_TABLE = (_a = {},
_a[typings_1.InputArgument.TYPE_NUMBER] = 'number',
_a[typings_1.InputArgument.TYPE_ANY] = 'any',
_a[typings_1.InputArgument.TYPE_STRING] = 'string',
_a[typings_1.InputArgument.TYPE_ARRAY] = 'array',
_a[typings_1.InputArgument.TYPE_OBJECT] = 'object',
_a[typings_1.InputArgument.TYPE_BOOLEAN] = 'boolean',
_a[typings_1.InputArgument.TYPE_EXPREF] = 'expression',
_a[typings_1.InputArgument.TYPE_NULL] = 'null',
_a[typings_1.InputArgument.TYPE_ARRAY_NUMBER] = 'Array<number>',
_a[typings_1.InputArgument.TYPE_ARRAY_STRING] = 'Array<string>',
_a);
this.functionAbs = function (_a) {
var inputValue = _a[0];
const typings_1 = require("./typings");
const utils_1 = require("./utils");
class Runtime {
constructor(interpreter) {
this.TYPE_NAME_TABLE = {
[typings_1.InputArgument.TYPE_NUMBER]: 'number',
[typings_1.InputArgument.TYPE_ANY]: 'any',
[typings_1.InputArgument.TYPE_STRING]: 'string',
[typings_1.InputArgument.TYPE_ARRAY]: 'array',
[typings_1.InputArgument.TYPE_OBJECT]: 'object',
[typings_1.InputArgument.TYPE_BOOLEAN]: 'boolean',
[typings_1.InputArgument.TYPE_EXPREF]: 'expression',
[typings_1.InputArgument.TYPE_NULL]: 'null',
[typings_1.InputArgument.TYPE_ARRAY_NUMBER]: 'Array<number>',
[typings_1.InputArgument.TYPE_ARRAY_STRING]: 'Array<string>',
};
this.functionAbs = ([inputValue]) => {
return Math.abs(inputValue);
};
this.functionAvg = function (_a) {
var inputArray = _a[0];
var sum = 0;
for (var i = 0; i < inputArray.length; i += 1) {
this.functionAvg = ([inputArray]) => {
let sum = 0;
for (let i = 0; i < inputArray.length; i += 1) {
sum += inputArray[i];

@@ -41,28 +30,24 @@ }

};
this.functionCeil = function (_a) {
var inputValue = _a[0];
this.functionCeil = ([inputValue]) => {
return Math.ceil(inputValue);
};
this.functionContains = function (resolvedArgs) {
var searchable = resolvedArgs[0], searchValue = resolvedArgs[1];
this.functionContains = resolvedArgs => {
const [searchable, searchValue] = resolvedArgs;
return searchable.includes(searchValue);
};
this.functionEndsWith = function (resolvedArgs) {
var searchStr = resolvedArgs[0], suffix = resolvedArgs[1];
this.functionEndsWith = resolvedArgs => {
const [searchStr, suffix] = resolvedArgs;
return searchStr.includes(suffix, searchStr.length - suffix.length);
};
this.functionFloor = function (_a) {
var inputValue = _a[0];
this.functionFloor = ([inputValue]) => {
return Math.floor(inputValue);
};
this.functionJoin = function (resolvedArgs) {
var joinChar = resolvedArgs[0], listJoin = resolvedArgs[1];
this.functionJoin = resolvedArgs => {
const [joinChar, listJoin] = resolvedArgs;
return listJoin.join(joinChar);
};
this.functionKeys = function (_a) {
var inputObject = _a[0];
this.functionKeys = ([inputObject]) => {
return Object.keys(inputObject);
};
this.functionLength = function (_a) {
var inputValue = _a[0];
this.functionLength = ([inputValue]) => {
if (!utils_1.isObject(inputValue)) {

@@ -73,10 +58,10 @@ return inputValue.length;

};
this.functionMap = function (resolvedArgs) {
if (!_this._interpreter)
this.functionMap = (resolvedArgs) => {
if (!this._interpreter)
return [];
var mapped = [];
var interpreter = _this._interpreter;
var exprefNode = resolvedArgs[0];
var elements = resolvedArgs[1];
for (var i = 0; i < elements.length; i += 1) {
const mapped = [];
const interpreter = this._interpreter;
const exprefNode = resolvedArgs[0];
const elements = resolvedArgs[1];
for (let i = 0; i < elements.length; i += 1) {
mapped.push(interpreter.visit(exprefNode, elements[i]));

@@ -86,13 +71,12 @@ }

};
this.functionMax = function (_a) {
var inputValue = _a[0];
this.functionMax = ([inputValue]) => {
if (!inputValue.length)
return null;
var typeName = _this.getTypeName(inputValue[0]);
const typeName = this.getTypeName(inputValue[0]);
if (typeName === typings_1.InputArgument.TYPE_NUMBER) {
return Math.max.apply(Math, inputValue);
return Math.max(...inputValue);
}
var elements = inputValue;
var maxElement = elements[0];
for (var i = 1; i < elements.length; i += 1) {
const elements = inputValue;
let maxElement = elements[0];
for (let i = 1; i < elements.length; i += 1) {
if (maxElement.localeCompare(elements[i]) < 0) {

@@ -104,10 +88,10 @@ maxElement = elements[i];

};
this.functionMaxBy = function (resolvedArgs) {
var exprefNode = resolvedArgs[1];
var resolvedArray = resolvedArgs[0];
var keyFunction = _this.createKeyFunction(exprefNode, [typings_1.InputArgument.TYPE_NUMBER, typings_1.InputArgument.TYPE_STRING]);
var maxNumber = -Infinity;
var maxRecord;
var current;
for (var i = 0; i < resolvedArray.length; i += 1) {
this.functionMaxBy = (resolvedArgs) => {
const exprefNode = resolvedArgs[1];
const resolvedArray = resolvedArgs[0];
const keyFunction = this.createKeyFunction(exprefNode, [typings_1.InputArgument.TYPE_NUMBER, typings_1.InputArgument.TYPE_STRING]);
let maxNumber = -Infinity;
let maxRecord;
let current;
for (let i = 0; i < resolvedArray.length; i += 1) {
current = keyFunction && keyFunction(resolvedArray[i]);

@@ -121,6 +105,6 @@ if (current !== undefined && current > maxNumber) {

};
this.functionMerge = function (resolvedArgs) {
var merged = {};
for (var i = 0; i < resolvedArgs.length; i += 1) {
var current = resolvedArgs[i];
this.functionMerge = resolvedArgs => {
let merged = {};
for (let i = 0; i < resolvedArgs.length; i += 1) {
const current = resolvedArgs[i];
merged = Object.assign(merged, current);

@@ -133,13 +117,12 @@ // for (const key in current) {

};
this.functionMin = function (_a) {
var inputValue = _a[0];
this.functionMin = ([inputValue]) => {
if (!inputValue.length)
return null;
var typeName = _this.getTypeName(inputValue[0]);
const typeName = this.getTypeName(inputValue[0]);
if (typeName === typings_1.InputArgument.TYPE_NUMBER) {
return Math.min.apply(Math, inputValue);
return Math.min(...inputValue);
}
var elements = inputValue;
var minElement = elements[0];
for (var i = 1; i < elements.length; i += 1) {
const elements = inputValue;
let minElement = elements[0];
for (let i = 1; i < elements.length; i += 1) {
if (elements[i].localeCompare(minElement) < 0) {

@@ -151,10 +134,10 @@ minElement = elements[i];

};
this.functionMinBy = function (resolvedArgs) {
var exprefNode = resolvedArgs[1];
var resolvedArray = resolvedArgs[0];
var keyFunction = _this.createKeyFunction(exprefNode, [typings_1.InputArgument.TYPE_NUMBER, typings_1.InputArgument.TYPE_STRING]);
var minNumber = Infinity;
var minRecord;
var current;
for (var i = 0; i < resolvedArray.length; i += 1) {
this.functionMinBy = (resolvedArgs) => {
const exprefNode = resolvedArgs[1];
const resolvedArray = resolvedArgs[0];
const keyFunction = this.createKeyFunction(exprefNode, [typings_1.InputArgument.TYPE_NUMBER, typings_1.InputArgument.TYPE_STRING]);
let minNumber = Infinity;
let minRecord;
let current;
for (let i = 0; i < resolvedArray.length; i += 1) {
current = keyFunction && keyFunction(resolvedArray[i]);

@@ -168,5 +151,5 @@ if (current !== undefined && current < minNumber) {

};
this.functionNotNull = function (resolvedArgs) {
for (var i = 0; i < resolvedArgs.length; i += 1) {
if (_this.getTypeName(resolvedArgs[i]) !== typings_1.InputArgument.TYPE_NULL) {
this.functionNotNull = (resolvedArgs) => {
for (let i = 0; i < resolvedArgs.length; i += 1) {
if (this.getTypeName(resolvedArgs[i]) !== typings_1.InputArgument.TYPE_NULL) {
return resolvedArgs[i];

@@ -177,9 +160,8 @@ }

};
this.functionReverse = function (_a) {
var inputValue = _a[0];
var typeName = _this.getTypeName(inputValue);
this.functionReverse = ([inputValue]) => {
const typeName = this.getTypeName(inputValue);
if (typeName === typings_1.InputArgument.TYPE_STRING) {
var originalStr = inputValue;
var reversedStr = '';
for (var i = originalStr.length - 1; i >= 0; i -= 1) {
const originalStr = inputValue;
let reversedStr = '';
for (let i = originalStr.length - 1; i >= 0; i -= 1) {
reversedStr += originalStr[i];

@@ -189,35 +171,34 @@ }

}
var reversedArray = inputValue.slice(0);
const reversedArray = inputValue.slice(0);
reversedArray.reverse();
return reversedArray;
};
this.functionSort = function (_a) {
var inputValue = _a[0];
return __spreadArrays(inputValue).sort();
this.functionSort = ([inputValue]) => {
return [...inputValue].sort();
};
this.functionSortBy = function (resolvedArgs) {
if (!_this._interpreter)
this.functionSortBy = (resolvedArgs) => {
if (!this._interpreter)
return [];
var sortedArray = resolvedArgs[0].slice(0);
const sortedArray = resolvedArgs[0].slice(0);
if (sortedArray.length === 0) {
return sortedArray;
}
var interpreter = _this._interpreter;
var exprefNode = resolvedArgs[1];
var requiredType = _this.getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
const interpreter = this._interpreter;
const exprefNode = resolvedArgs[1];
const requiredType = this.getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
if (requiredType !== undefined && ![typings_1.InputArgument.TYPE_NUMBER, typings_1.InputArgument.TYPE_STRING].includes(requiredType)) {
throw new Error("TypeError: unexpected type (" + _this.TYPE_NAME_TABLE[requiredType] + ")");
throw new Error(`TypeError: unexpected type (${this.TYPE_NAME_TABLE[requiredType]})`);
}
var decorated = [];
for (var i = 0; i < sortedArray.length; i += 1) {
const decorated = [];
for (let i = 0; i < sortedArray.length; i += 1) {
decorated.push([i, sortedArray[i]]);
}
decorated.sort(function (a, b) {
var exprA = interpreter.visit(exprefNode, a[1]);
var exprB = interpreter.visit(exprefNode, b[1]);
if (_this.getTypeName(exprA) !== requiredType) {
throw new Error("TypeError: expected (" + _this.TYPE_NAME_TABLE[requiredType] + "), received " + _this.TYPE_NAME_TABLE[_this.getTypeName(exprA)]);
decorated.sort((a, b) => {
const exprA = interpreter.visit(exprefNode, a[1]);
const exprB = interpreter.visit(exprefNode, b[1]);
if (this.getTypeName(exprA) !== requiredType) {
throw new Error(`TypeError: expected (${this.TYPE_NAME_TABLE[requiredType]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(exprA)]}`);
}
else if (_this.getTypeName(exprB) !== requiredType) {
throw new Error("TypeError: expected (" + _this.TYPE_NAME_TABLE[requiredType] + "), received " + _this.TYPE_NAME_TABLE[_this.getTypeName(exprB)]);
else if (this.getTypeName(exprB) !== requiredType) {
throw new Error(`TypeError: expected (${this.TYPE_NAME_TABLE[requiredType]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(exprB)]}`);
}

@@ -229,3 +210,3 @@ if (exprA > exprB) {

});
for (var j = 0; j < decorated.length; j += 1) {
for (let j = 0; j < decorated.length; j += 1) {
sortedArray[j] = decorated[j][1];

@@ -235,13 +216,10 @@ }

};
this.functionStartsWith = function (_a) {
var searchable = _a[0], searchStr = _a[1];
this.functionStartsWith = ([searchable, searchStr]) => {
return searchable.startsWith(searchStr);
};
this.functionSum = function (_a) {
var inputValue = _a[0];
return inputValue.reduce(function (x, y) { return x + y; }, 0);
this.functionSum = ([inputValue]) => {
return inputValue.reduce((x, y) => x + y, 0);
};
this.functionToArray = function (_a) {
var inputValue = _a[0];
if (_this.getTypeName(inputValue) === typings_1.InputArgument.TYPE_ARRAY) {
this.functionToArray = ([inputValue]) => {
if (this.getTypeName(inputValue) === typings_1.InputArgument.TYPE_ARRAY) {
return inputValue;

@@ -251,6 +229,5 @@ }

};
this.functionToNumber = function (_a) {
var inputValue = _a[0];
var typeName = _this.getTypeName(inputValue);
var convertedValue;
this.functionToNumber = ([inputValue]) => {
const typeName = this.getTypeName(inputValue);
let convertedValue;
if (typeName === typings_1.InputArgument.TYPE_NUMBER) {

@@ -267,5 +244,4 @@ return inputValue;

};
this.functionToString = function (_a) {
var inputValue = _a[0];
if (_this.getTypeName(inputValue) === typings_1.InputArgument.TYPE_STRING) {
this.functionToString = ([inputValue]) => {
if (this.getTypeName(inputValue) === typings_1.InputArgument.TYPE_STRING) {
return inputValue;

@@ -275,5 +251,4 @@ }

};
this.functionType = function (_a) {
var inputValue = _a[0];
switch (_this.getTypeName(inputValue)) {
this.functionType = ([inputValue]) => {
switch (this.getTypeName(inputValue)) {
case typings_1.InputArgument.TYPE_NUMBER:

@@ -297,4 +272,3 @@ return 'number';

};
this.functionValues = function (_a) {
var inputObject = _a[0];
this.functionValues = ([inputObject]) => {
return Object.values(inputObject);

@@ -541,5 +515,5 @@ };

}
Runtime.prototype.registerFunction = function (name, customFunction, signature) {
registerFunction(name, customFunction, signature) {
if (name in this.functionTable) {
throw new Error("Function already defined: " + name + "()");
throw new Error(`Function already defined: ${name}()`);
}

@@ -550,18 +524,17 @@ this.functionTable[name] = {

};
};
Runtime.prototype.callFunction = function (name, resolvedArgs) {
var functionEntry = this.functionTable[name];
}
callFunction(name, resolvedArgs) {
const functionEntry = this.functionTable[name];
if (functionEntry === undefined) {
throw new Error("Unknown function: " + name + "()");
throw new Error(`Unknown function: ${name}()`);
}
this.validateArgs(name, resolvedArgs, functionEntry._signature);
return functionEntry._func.call(this, resolvedArgs);
};
Runtime.prototype.validateArgs = function (name, args, signature) {
var _this = this;
var pluralized;
}
validateArgs(name, args, signature) {
let pluralized;
if (signature[signature.length - 1].variadic) {
if (args.length < signature.length) {
pluralized = signature.length > 1;
throw new Error("ArgumentError: " + name + "() takes at least " + signature.length + " argument" + ((pluralized && 's') || '') + " but received " + args.length);
throw new Error(`ArgumentError: ${name}() takes at least ${signature.length} argument${(pluralized && 's') || ''} but received ${args.length}`);
}

@@ -571,12 +544,12 @@ }

pluralized = signature.length > 1;
throw new Error("ArgumentError: " + name + "() takes " + signature.length + " argument" + ((pluralized && 's') || '') + " but received " + args.length);
throw new Error(`ArgumentError: ${name}() takes ${signature.length} argument${(pluralized && 's') || ''} but received ${args.length}`);
}
var currentSpec;
var actualType;
var typeMatched;
for (var i = 0; i < signature.length; i += 1) {
let currentSpec;
let actualType;
let typeMatched;
for (let i = 0; i < signature.length; i += 1) {
typeMatched = false;
currentSpec = signature[i].types;
actualType = this.getTypeName(args[i]);
var j = void 0;
let j;
for (j = 0; j < currentSpec.length; j += 1) {

@@ -589,12 +562,12 @@ if (actualType !== undefined && this.typeMatches(actualType, currentSpec[j], args[i])) {

if (!typeMatched) {
var expected = currentSpec
.map(function (typeIdentifier) {
return _this.TYPE_NAME_TABLE[typeIdentifier];
const expected = currentSpec
.map((typeIdentifier) => {
return this.TYPE_NAME_TABLE[typeIdentifier];
})
.join(' | ');
throw new Error("TypeError: " + name + "() expected argument " + (i + 1) + " to be type (" + expected + ") but received type " + this.TYPE_NAME_TABLE[actualType] + " instead.");
throw new Error(`TypeError: ${name}() expected argument ${i + 1} to be type (${expected}) but received type ${this.TYPE_NAME_TABLE[actualType]} instead.`);
}
}
};
Runtime.prototype.typeMatches = function (actual, expected, argValue) {
}
typeMatches(actual, expected, argValue) {
if (expected === typings_1.InputArgument.TYPE_ANY) {

@@ -610,3 +583,3 @@ return true;

if (actual === typings_1.InputArgument.TYPE_ARRAY) {
var subtype = void 0;
let subtype;
if (expected === typings_1.InputArgument.TYPE_ARRAY_NUMBER) {

@@ -618,4 +591,4 @@ subtype = typings_1.InputArgument.TYPE_NUMBER;

}
for (var i = 0; i < argValue.length; i += 1) {
var typeName = this.getTypeName(argValue[i]);
for (let i = 0; i < argValue.length; i += 1) {
const typeName = this.getTypeName(argValue[i]);
if (typeName !== undefined && subtype !== undefined && !this.typeMatches(typeName, subtype, argValue[i])) {

@@ -632,4 +605,4 @@ return false;

return false;
};
Runtime.prototype.getTypeName = function (obj) {
}
getTypeName(obj) {
switch (Object.prototype.toString.call(obj)) {

@@ -654,14 +627,13 @@ case '[object String]':

}
};
Runtime.prototype.createKeyFunction = function (exprefNode, allowedTypes) {
var _this = this;
}
createKeyFunction(exprefNode, allowedTypes) {
if (!this._interpreter)
return;
var interpreter = this._interpreter;
var keyFunc = function (x) {
var current = interpreter.visit(exprefNode, x);
if (!allowedTypes.includes(_this.getTypeName(current))) {
var msg = "TypeError: expected one of (" + allowedTypes
.map(function (t) { return _this.TYPE_NAME_TABLE[t]; })
.join(' | ') + "), received " + _this.TYPE_NAME_TABLE[_this.getTypeName(current)];
const interpreter = this._interpreter;
const keyFunc = (x) => {
const current = interpreter.visit(exprefNode, x);
if (!allowedTypes.includes(this.getTypeName(current))) {
const msg = `TypeError: expected one of (${allowedTypes
.map(t => this.TYPE_NAME_TABLE[t])
.join(' | ')}), received ${this.TYPE_NAME_TABLE[this.getTypeName(current)]}`;
throw new Error(msg);

@@ -672,6 +644,5 @@ }

return keyFunc;
};
return Runtime;
}());
}
}
exports.Runtime = Runtime;
//# sourceMappingURL=Runtime.js.map
"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TreeInterpreterInstance = exports.TreeInterpreter = void 0;
var typings_1 = require("./typings");
var utils_1 = require("./utils");
var Runtime_1 = require("./Runtime");
var TreeInterpreter = /** @class */ (function () {
function TreeInterpreter() {
const typings_1 = require("./typings");
const utils_1 = require("./utils");
const Runtime_1 = require("./Runtime");
class TreeInterpreter {
constructor() {
this.runtime = new Runtime_1.Runtime(this);
}
TreeInterpreter.prototype.search = function (node, value) {
search(node, value) {
return this.visit(node, value);
};
TreeInterpreter.prototype.visit = function (node, value) {
var matched;
var current;
var result;
var first;
var second;
var field;
var left;
var right;
var collected;
var i;
var base;
}
visit(node, value) {
let matched;
let current;
let result;
let first;
let second;
let field;
let left;
let right;
let collected;
let i;
let base;
switch (node.type) {

@@ -63,3 +56,3 @@ case 'Field':

}
var index = node.value;
let index = node.value;
if (index < 0) {

@@ -77,8 +70,8 @@ index = value.length + index;

}
var sliceParams = __spreadArrays(node.children);
var computed = this.computeSliceParams(value.length, sliceParams);
var start = computed[0], stop_1 = computed[1], step = computed[2];
const sliceParams = [...node.children];
const computed = this.computeSliceParams(value.length, sliceParams);
const [start, stop, step] = computed;
result = [];
if (step > 0) {
for (i = start; i < stop_1; i += step) {
for (i = start; i < stop; i += step) {
result.push(value[i]);

@@ -88,3 +81,3 @@ }

else {
for (i = start; i > stop_1; i += step) {
for (i = start; i > stop; i += step) {
result.push(value[i]);

@@ -113,3 +106,3 @@ }

collected = [];
var values = utils_1.objValues(base);
const values = utils_1.objValues(base);
for (i = 0; i < values.length; i += 1) {

@@ -127,4 +120,4 @@ current = this.visit(node.children[1], values[i]);

}
var filtered = [];
var finalResults = [];
const filtered = [];
const finalResults = [];
for (i = 0; i < base.length; i += 1) {

@@ -136,3 +129,3 @@ matched = this.visit(node.children[2], base[i]);

}
for (var j = 0; j < filtered.length; j += 1) {
for (let j = 0; j < filtered.length; j += 1) {
current = this.visit(node.children[1], filtered[j]);

@@ -167,15 +160,15 @@ if (current !== null) {

default:
throw new Error("Unknown comparator: " + node.name);
throw new Error(`Unknown comparator: ${node.name}`);
}
return result;
case typings_1.Token.TOK_FLATTEN:
var original = this.visit(node.children[0], value);
const original = this.visit(node.children[0], value);
if (!Array.isArray(original)) {
return null;
}
var merged = [];
let merged = [];
for (i = 0; i < original.length; i += 1) {
current = original[i];
if (Array.isArray(current)) {
merged = __spreadArrays(merged, current);
merged = [...merged, ...current];
}

@@ -203,3 +196,3 @@ else {

collected = {};
var child = void 0;
let child;
for (i = 0; i < node.children.length; i += 1) {

@@ -233,4 +226,4 @@ child = node.children[i];

case 'Function':
var resolvedArgs = [];
for (var j = 0; j < node.children.length; j += 1) {
const resolvedArgs = [];
for (let j = 0; j < node.children.length; j += 1) {
resolvedArgs.push(this.visit(node.children[j], value));

@@ -240,11 +233,11 @@ }

case 'ExpressionReference':
var refNode = node.children[0];
const refNode = node.children[0];
refNode.jmespathType = typings_1.Token.TOK_EXPREF;
return refNode;
default:
throw new Error("Unknown node type: " + node.type);
throw new Error(`Unknown node type: ${node.type}`);
}
};
TreeInterpreter.prototype.computeSliceParams = function (arrayLength, sliceParams) {
var start = sliceParams[0], stop = sliceParams[1], step = sliceParams[2];
}
computeSliceParams(arrayLength, sliceParams) {
let [start, stop, step] = sliceParams;
if (step === null) {

@@ -254,13 +247,13 @@ step = 1;

else if (step === 0) {
var error = new Error('Invalid slice, step cannot be 0');
const error = new Error('Invalid slice, step cannot be 0');
error.name = 'RuntimeError';
throw error;
}
var stepValueNegative = step < 0 ? true : false;
const stepValueNegative = step < 0 ? true : false;
start = start === null ? (stepValueNegative ? arrayLength - 1 : 0) : this.capSliceRange(arrayLength, start, step);
stop = stop === null ? (stepValueNegative ? -1 : arrayLength) : this.capSliceRange(arrayLength, stop, step);
return [start, stop, step];
};
TreeInterpreter.prototype.capSliceRange = function (arrayLength, actualValue, step) {
var nextActualValue = actualValue;
}
capSliceRange(arrayLength, actualValue, step) {
let nextActualValue = actualValue;
if (nextActualValue < 0) {

@@ -276,5 +269,4 @@ nextActualValue += arrayLength;

return nextActualValue;
};
return TreeInterpreter;
}());
}
}
exports.TreeInterpreter = TreeInterpreter;

@@ -281,0 +273,0 @@ exports.TreeInterpreterInstance = new TreeInterpreter();

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAlphaNum = exports.isNum = exports.isAlpha = exports.trimLeft = exports.objValues = exports.isFalse = exports.strictDeepEqual = exports.isObject = void 0;
exports.isObject = function (obj) {
exports.isObject = (obj) => {
return obj !== null && Object.prototype.toString.call(obj) === '[object Object]';
};
exports.strictDeepEqual = function (first, second) {
exports.strictDeepEqual = (first, second) => {
if (first === second) {
return true;
}
var firstType = Object.prototype.toString.call(first);
const firstType = Object.prototype.toString.call(first);
if (firstType !== Object.prototype.toString.call(second)) {

@@ -19,3 +19,3 @@ return false;

}
for (var i = 0; i < first.length; i += 1) {
for (let i = 0; i < first.length; i += 1) {
if (!exports.strictDeepEqual(first[i], second[i])) {

@@ -28,4 +28,4 @@ return false;

if (exports.isObject(first)) {
var keysSeen = {};
for (var key in first) {
const keysSeen = {};
for (const key in first) {
if (Object.hasOwnProperty.call(first, key)) {

@@ -38,3 +38,3 @@ if (!exports.strictDeepEqual(first[key], second[key])) {

}
for (var key2 in second) {
for (const key2 in second) {
if (Object.hasOwnProperty.call(second, key2)) {

@@ -50,3 +50,3 @@ if (keysSeen[key2] !== true) {

};
exports.isFalse = function (obj) {
exports.isFalse = (obj) => {
if (obj === '' || obj === false || obj === null || obj === undefined) {

@@ -59,3 +59,3 @@ return true;

if (exports.isObject(obj)) {
for (var key in obj) {
for (const key in obj) {
if (obj.hasOwnProperty(key)) {

@@ -69,6 +69,6 @@ return false;

};
exports.objValues = function (obj) {
var keys = Object.keys(obj);
var values = [];
for (var i = 0; i < keys.length; i += 1) {
exports.objValues = (obj) => {
const keys = Object.keys(obj);
const values = [];
for (let i = 0; i < keys.length; i += 1) {
values.push(obj[keys[i]]);

@@ -79,18 +79,18 @@ }

exports.trimLeft = typeof String.prototype.trimLeft === 'function'
? function (str) {
? (str) => {
return str.trimLeft();
}
: function (str) {
var match = /^\s*(.*)/.exec(str);
: (str) => {
const match = /^\s*(.*)/.exec(str);
return (match && match[1]);
};
exports.isAlpha = function (ch) {
exports.isAlpha = (ch) => {
// tslint:disable-next-line: strict-comparisons
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch === '_';
};
exports.isNum = function (ch) {
exports.isNum = (ch) => {
// tslint:disable-next-line: strict-comparisons
return (ch >= '0' && ch <= '9') || ch === '-';
};
exports.isAlphaNum = function (ch) {
exports.isAlphaNum = (ch) => {
// tslint:disable-next-line: strict-comparisons

@@ -97,0 +97,0 @@ return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch === '_';

import { ExpressionNodeTree, LexerToken, JSONValue, InputArgument, InputSignature, RuntimeFunction } from './typings/index';
export type { FunctionSignature, RuntimeFunction, InputSignature } from './typings/index';
export declare const TYPE_ANY = InputArgument.TYPE_ANY;

@@ -3,0 +4,0 @@ export declare const TYPE_ARRAY = InputArgument.TYPE_ARRAY;

{
"name": "@metrichor/jmespath",
"description": "Typescript implementation of the JMESPath spec (100% compliant)",
"version": "0.1.3",
"version": "0.1.4",
"author": {

@@ -44,3 +44,3 @@ "name": "Oxford Nanopore Technologies",

"perf": "node scripts/perf.js",
"build": "tsc --module commonjs && rollup -c rollup.config.ts",
"build": "tsc --outDir dist/lib -d --module commonjs --declarationDir dist/types && rollup -c rollup.config.ts",
"start": "rollup -c rollup.config.ts -w",

@@ -63,11 +63,12 @@ "test": "jest --coverage",

"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-json": "^4.0.3",
"@rollup/plugin-node-resolve": "^7.1.3",
"@types/jest": "^25.2.2",
"@types/node": "^14.0.1",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@commitlint/cli": "^9.1.2",
"@commitlint/config-conventional": "^9.1.1",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-typescript": "^5.0.2",
"@types/jest": "^26.0.5",
"@types/node": "^14.0.23",
"@typescript-eslint/eslint-plugin": "^3.6.1",
"@typescript-eslint/parser": "^3.6.1",
"benchmark": "^2.1.4",

@@ -78,25 +79,25 @@ "colors": "^1.4.0",

"cz-conventional-changelog": "^3.2.0",
"eslint": "^7.0.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"jest": "^26.0.1",
"jest-cli": "^26.0.1",
"jest-config": "^26.0.1",
"lint-staged": "^10.2.2",
"jest": "^26.1.0",
"jest-cli": "^26.1.0",
"jest-config": "^26.1.0",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"prettier-eslint": "^9.0.1",
"prettier-eslint": "^11.0.0",
"prompt": "^1.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.10.2",
"rollup": "^2.22.1",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-typescript": "^1.0.1",
"semantic-release": "^17.0.7",
"rollup-plugin-terser": "^6.1.0",
"semantic-release": "^17.1.1",
"shelljs": "^0.8.4",
"ts-jest": "^25.5.1",
"ts-node": "^8.10.1",
"typedoc": "^0.17.6",
"typescript": "^3.9.2"
"ts-jest": "^26.1.3",
"ts-node": "^8.10.2",
"typedoc": "^0.17.8",
"typescript": "^3.9.7"
},
"dependencies": {}
}

@@ -131,3 +131,2 @@ ![Node.js CI](https://github.com/nanoporetech/jmespath-ts/workflows/Node.js%20CI/badge.svg?branch=master)

```

@@ -134,0 +133,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc