@jmespath-community/jmespath
Version:
Typescript implementation of the JMESPath Community specification
67 lines • 3.17 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.jmespath = exports.TreeInterpreter = exports.Scope = 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_OBJECT = exports.TYPE_ARRAY_NUMBER = exports.TYPE_ARRAY_ARRAY = exports.TYPE_ARRAY = exports.TYPE_ANY = void 0;
const Parser_1 = __importDefault(require("./Parser"));
const Lexer_1 = __importDefault(require("./Lexer"));
const TreeInterpreter_1 = __importDefault(require("./TreeInterpreter"));
const Runtime_1 = require("./Runtime");
const Scope_1 = require("./Scope");
exports.TYPE_ANY = Runtime_1.InputArgument.TYPE_ANY;
exports.TYPE_ARRAY = Runtime_1.InputArgument.TYPE_ARRAY;
exports.TYPE_ARRAY_ARRAY = Runtime_1.InputArgument.TYPE_ARRAY_ARRAY;
exports.TYPE_ARRAY_NUMBER = Runtime_1.InputArgument.TYPE_ARRAY_NUMBER;
exports.TYPE_ARRAY_OBJECT = Runtime_1.InputArgument.TYPE_ARRAY_OBJECT;
exports.TYPE_ARRAY_STRING = Runtime_1.InputArgument.TYPE_ARRAY_STRING;
exports.TYPE_BOOLEAN = Runtime_1.InputArgument.TYPE_BOOLEAN;
exports.TYPE_EXPREF = Runtime_1.InputArgument.TYPE_EXPREF;
exports.TYPE_NULL = Runtime_1.InputArgument.TYPE_NULL;
exports.TYPE_NUMBER = Runtime_1.InputArgument.TYPE_NUMBER;
exports.TYPE_OBJECT = Runtime_1.InputArgument.TYPE_OBJECT;
exports.TYPE_STRING = Runtime_1.InputArgument.TYPE_STRING;
function compile(expression, options) {
const nodeTree = Parser_1.default.parse(expression, options);
return nodeTree;
}
exports.compile = compile;
function tokenize(expression, options) {
return Lexer_1.default.tokenize(expression, options);
}
exports.tokenize = tokenize;
const registerFunction = (functionName,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
customFunction, signature) => {
TreeInterpreter_1.default.runtime.registerFunction(functionName, customFunction, signature);
};
exports.registerFunction = registerFunction;
function search(data, expression, options) {
const nodeTree = Parser_1.default.parse(expression, options);
return TreeInterpreter_1.default.search(nodeTree, data);
}
exports.search = search;
function Scope() {
return new Scope_1.ScopeChain();
}
exports.Scope = Scope;
exports.TreeInterpreter = TreeInterpreter_1.default;
exports.jmespath = {
compile,
registerFunction: exports.registerFunction,
search,
tokenize,
TreeInterpreter: exports.TreeInterpreter,
TYPE_ANY: exports.TYPE_ANY,
TYPE_ARRAY_NUMBER: exports.TYPE_ARRAY_NUMBER,
TYPE_ARRAY_STRING: exports.TYPE_ARRAY_STRING,
TYPE_ARRAY: exports.TYPE_ARRAY,
TYPE_BOOLEAN: exports.TYPE_BOOLEAN,
TYPE_EXPREF: exports.TYPE_EXPREF,
TYPE_NULL: exports.TYPE_NULL,
TYPE_NUMBER: exports.TYPE_NUMBER,
TYPE_OBJECT: exports.TYPE_OBJECT,
TYPE_STRING: exports.TYPE_STRING,
};
exports.default = exports.jmespath;
//# sourceMappingURL=index.js.map