crawlkit
Version:
A crawler based on Phantom. Allows discovery of dynamic content and supports custom scrapers.
22 lines (19 loc) • 615 B
JavaScript
// eslint-disable-line
const NanoTimer = require('nanotimer');
const juration = require('juration');
/**
* Runs a function and times it
*
* @private
* @param {!Object} logger A {@link logger} object
* @param {!Function} runFn The function to run
* @return {Function} a function to start the processing. Takes an optional callback parameter.
*/
module.exports = (logger, runFn) => (cb) => {
new NanoTimer().time(runFn, '', 's', (time) => {
logger.info(`Finished. Took ${juration.stringify(time) || 'less than a second'}.`);
if (typeof cb === 'function') {
cb();
}
});
};
;