UNPKG

1.89 kBSource Map (JSON)View Raw
1{
2 "version": 3,
3 "sources": ["../src/index.ts"],
4 "sourcesContent": ["import 'debug'\nimport DebugNode from './node'\n\nconst cache: any[] = []\n\nconst MAX_LOGS = 100\n\nexport default function Debug(namespace: string): debug.Debugger {\n const debug: debug.Debugger = DebugNode(namespace, (...args) => {\n cache.push(args)\n // keeping 100 logs is just a heuristic. The real truncating comes later\n if (cache.length > MAX_LOGS) {\n cache.shift()\n }\n })\n\n return debug\n}\nexport { Debug }\n\nDebug.enable = (namespace: string): void => {\n DebugNode.enable(namespace)\n}\n\nDebug.enabled = (namespace: string): boolean => DebugNode.enabled(namespace)\n\n// https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers\n// we need some space for other characters, so we go for 30k here\nexport function getLogs(numChars = 7500): string {\n // flatmap on text level\n const output = cache\n .map((c) =>\n c\n .map((item) => {\n if (typeof item === 'string') {\n return item\n }\n\n return JSON.stringify(item)\n })\n .join(' '),\n )\n .join('\\n')\n\n if (output.length < numChars) {\n return output\n }\n\n return output.slice(-numChars)\n}\n"],
5 "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAO;AACP,kBAAsB;AAEtB,MAAM,QAAe;AAErB,MAAM,WAAW;AAEF,eAAe,WAAmC;AAC/D,QAAM,QAAwB,yBAAU,WAAW,IAAI,SAAS;AAC9D,UAAM,KAAK;AAEX,QAAI,MAAM,SAAS,UAAU;AAC3B,YAAM;AAAA;AAAA;AAIV,SAAO;AAAA;AAIT,MAAM,SAAS,CAAC,cAA4B;AAC1C,sBAAU,OAAO;AAAA;AAGnB,MAAM,UAAU,CAAC,cAA+B,oBAAU,QAAQ;AAI3D,iBAAiB,WAAW,MAAc;AAE/C,QAAM,SAAS,MACZ,IAAI,CAAC,MACJ,EACG,IAAI,CAAC,SAAS;AACb,QAAI,OAAO,SAAS,UAAU;AAC5B,aAAO;AAAA;AAGT,WAAO,KAAK,UAAU;AAAA,KAEvB,KAAK,OAET,KAAK;AAER,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO;AAAA;AAGT,SAAO,OAAO,MAAM,CAAC;AAAA;",
6 "names": []
7}