ayakashi
Version:
The next generation web scraping framework
36 lines (35 loc) • 1.42 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.attachQuery = void 0;
const query_1 = require("../query/query");
const debug_1 = __importDefault(require("debug"));
const d = debug_1.default("ayakashi:prelude:select");
function attachQuery(ayakashiInstance, window) {
ayakashiInstance.select = function (propId) {
const query = query_1.createQuery(ayakashiInstance, { propId, window });
ayakashiInstance.propRefs[query.id] = query;
d(`registering prop: ${query.id}`);
return query;
};
ayakashiInstance.selectOne = function (propId) {
const query = query_1.createQuery(ayakashiInstance, { propId, window });
query.limit(1);
ayakashiInstance.propRefs[query.id] = query;
d(`registering prop: ${query.id}`);
return query;
};
//alias of selectOne
ayakashiInstance.selectFirst = ayakashiInstance.selectOne;
ayakashiInstance.selectLast = function (propId) {
const query = query_1.createQuery(ayakashiInstance, { propId, window });
query.limit(1);
query.order("desc");
ayakashiInstance.propRefs[query.id] = query;
d(`registering prop: ${query.id}`);
return query;
};
}
exports.attachQuery = attachQuery;