good-spatula
Version:
Light weight and reliable binding of htmlparser2, css-select and dom-serializer.
15 lines (12 loc) • 335 B
JavaScript
const _ = require('lodash');
const _select = require('css-select');
module.exports = (spatula, getDom) => (selector) => {
const dom = getDom();
if (_.isNil(dom)) {
return undefined;
}
if (selector === '' || _.isNil(selector)) {
return spatula(dom);
}
return spatula(_select(selector, dom));
}