• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WolferyScripting / resclient-ts / #25

24 Aug 2025 12:37PM UTC coverage: 51.153% (+0.9%) from 50.293%
#25

push

DonovanDMC
1.1.0

227 of 281 branches covered (80.78%)

Branch coverage included in aggregate %.

1570 of 3232 relevant lines covered (48.58%)

10.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.02
/lib/util/Debug.ts
1
import type { Debug as DebugType } from "debug";
1✔
2
import { formatWithOptions } from "node:util";
1✔
3

1✔
4
// the things I do for esm first with cjs support
1✔
5
let debug: DebugType | undefined | null;
1✔
6
function getDebug(): Promise<DebugType | null> | DebugType | null {
38✔
7
    if (debug !== undefined) return debug;
38✔
8
    try {
2✔
9
        // eslint-disable-next-line unicorn/prefer-module
2✔
10
        if (typeof require === "undefined") {
2✔
11
            return import("debug").then(mod => (debug = mod.default)).catch(() => (debug = null));
2✔
12
        } else {
38!
13
        // eslint-disable-next-line @typescript-eslint/no-var-requires, unicorn/prefer-module
×
14
            debug = (require("debug") as { default: DebugType; }).default;
×
15
        }
×
16
    } catch {
38!
17
        debug = null;
×
18
    }
×
19
    return debug;
×
20
}
×
21

1✔
22
let depth = 2;
1✔
23
export function Debug(namspace: string, arg0: unknown, ...args: Array<unknown>): void {
1✔
24
    const log = (dt: DebugType): void => dt(`wolferyjs:${namspace}`)(formatWithOptions({ colors: true, showHidden: false, depth }, arg0, ...args));
38✔
25
    const d = getDebug();
38✔
26
    if (d instanceof Promise) {
38✔
27
        void d.then(dt => {
2✔
28
            if (dt) {
2✔
29
                log(dt);
2✔
30
            }
2✔
31
        });
2✔
32
    } else if (d) {
38✔
33
        log(d);
36✔
34
    }
36✔
35
}
38✔
36

1✔
37
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1✔
38
export function createDebug(namespace: string): (formatter: any, ...args: Array<any>) => void {
1✔
39
    const d = getDebug();
×
40
    if (!d || d instanceof Promise) {
×
41
        return () => {}; // noop
×
42
    }
×
43
    return d(`resclient:${namespace}`);
×
44
}
×
45

1✔
46
/**
1✔
47
 * Set the inspection depth for debug messages.
1✔
48
 * @param d The depth.
1✔
49
 */
1✔
50
export function setDebugDepth(d: number): void {
1✔
51
    depth = d;
×
52
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc