syphonx-core
Version:
SyphonX is a template-driven solution for extracting data from HTML in a highly efficient way. It combines the power of jQuery, Regular Expressions, and Javascript into a declarative template-driven format that extracts and reshapes HTML data into JSON.
30 lines • 1.46 kB
JavaScript
;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.selectorStatements = exports.selectorStatement = void 0;
function selectorStatement(query) {
var valid = query instanceof Array && query.length > 0 && typeof query[0] === "string" && query.slice(1).every(function (op) { return op instanceof Array; });
if (!valid) {
return "INVALID: ".concat(JSON.stringify(query));
}
var selector = query[0];
var ops = query.slice(1);
return __spreadArray(["$(\"".concat(selector, "\")")], ops.map(function (op) { return "".concat(op[0], "(").concat(op.slice(1).map(function (param) { return JSON.stringify(param); }).join(", "), ")"); }), true).join(".");
}
exports.selectorStatement = selectorStatement;
function selectorStatements(query) {
if (query && query.length > 0)
return "".concat(selectorStatement(query[0])).concat(query.length > 1 ? " (+".concat(query.length - 1, " more))") : "");
else
return "(none)";
}
exports.selectorStatements = selectorStatements;
//# sourceMappingURL=selector.js.map