UNPKG

@studyportals/sp-hs-misc

Version:

Miscellaneous code used in HouseStark's projects

22 lines 783 B
import { Throttleable } from "../utils/throttleable.class"; export class ThrottledRequestSenderDecorator { constructor(target, throttler) { this.target = target; this.throttler = throttler; } async sendAndExtractBody(request) { return this.createAndEnqueueTask(() => this.target.sendAndExtractBody(request)); } async send(request) { return this.createAndEnqueueTask(() => this.target.send(request)); } createAndEnqueueTask(actionFn) { const task = this.createTask(actionFn); this.throttler.enqueueTask(task); return task.createObservingPromise(); } createTask(actionFn) { return new Throttleable(actionFn); } } //# sourceMappingURL=throttled-request-sender-decorator.class.js.map