Files
MangaCircus/scraper/sources/common.js
T

13 lines
427 B
JavaScript

'use strict';
const { ArchiveControlError } = require('../lib/control');
function controlledHttp(http, shouldStop) {
return { async get(...args) {
const check = () => { const reason = shouldStop?.(); if (reason) throw new ArchiveControlError(reason === true ? 'paused' : String(reason)); };
check(); const response = await http.get(...args); check(); return response;
} };
}
module.exports = { controlledHttp };