import {Topic} from "../../types.js" import {nap} from "../toolbox/nap.js" import {Method} from "renraku/dist/interfaces.js" const lag = Promise>(func: T, duration: number) => { return async function(...args: any[]) { const ms = duration + (Math.random() * duration) await nap(ms) return func.apply(this, args) } } export function mockLatency(duration: number, topic: T) { for (const [key, value] of Object.entries(topic)) { topic[key] = lag(value, duration) } }