'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 };