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.
16 lines • 723 B
JavaScript
export function selectorStatement(query) {
const valid = query instanceof Array && query.length > 0 && typeof query[0] === "string" && query.slice(1).every(op => op instanceof Array);
if (!valid) {
return `INVALID: ${JSON.stringify(query)}`;
}
const selector = query[0];
const ops = query.slice(1);
return [`$("${selector}")`, ...ops.map(op => `${op[0]}(${op.slice(1).map(param => JSON.stringify(param)).join(", ")})`)].join(".");
}
export function selectorStatements(query) {
if (query && query.length > 0)
return `${selectorStatement(query[0])}${query.length > 1 ? ` (+${query.length - 1} more))` : ""}`;
else
return "(none)";
}
//# sourceMappingURL=selector.js.map