import { execFile } from "node:child_process"; import LRUCache from "lru-cache"; const cache = new LRUCache({ max: 500, ttl: 1000 * 60 * 5, }); export default async function bgpq4(asSet: string): Promise { if (cache.has(asSet)) return cache.get(asSet) as number[]; const answer: { as: number[] } = await new Promise((resolve) => { execFile("bgpq4", ["-tjl", "as", "-L", "6", asSet], (error, stdout) => { if (error) { throw error; } resolve(JSON.parse(stdout)); }); }); cache.set(asSet, answer.as); return answer.as; }