When entering a clock, the current state of the global is saved If another clock was already entered, it will revert back to that when exiting.

When we exit, if the monkey-patched global proxies get called, they will revert back to whatever the saved value was when they were patched. If that is another exited clock, it will proxy back to its original saved state, and so on, eventually hitting the original global state again if all clocks in the stack have been exited.

interface Saved {
    Date: DateConstructor | {
        UTC(year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
        now(): number;
        parse(s: string): number;
        new (...args: any[]): {
            getVarDate: (() => VarDate);
            [toPrimitive](hint: "default"): string;
            [toPrimitive](hint: "string"): string;
            [toPrimitive](hint: "number"): number;
            [toPrimitive](hint: string): string | number;
            getDate(): number;
            getDay(): number;
            getFullYear(): number;
            getHours(): number;
            getMilliseconds(): number;
            getMinutes(): number;
            getMonth(): number;
            getSeconds(): number;
            getTime(): number;
            getTimezoneOffset(): number;
            getUTCDate(): number;
            getUTCDay(): number;
            getUTCFullYear(): number;
            getUTCHours(): number;
            getUTCMilliseconds(): number;
            getUTCMinutes(): number;
            getUTCMonth(): number;
            getUTCSeconds(): number;
            setDate(date: number): number;
            setFullYear(year: number, month?: number, date?: number): number;
            setHours(hours: number, min?: number, sec?: number, ms?: number): number;
            setMilliseconds(ms: number): number;
            setMinutes(min: number, sec?: number, ms?: number): number;
            setMonth(month: number, date?: number): number;
            setSeconds(sec: number, ms?: number): number;
            setTime(time: number): number;
            setUTCDate(date: number): number;
            setUTCFullYear(year: number, month?: number, date?: number): number;
            setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number;
            setUTCMilliseconds(ms: number): number;
            setUTCMinutes(min: number, sec?: number, ms?: number): number;
            setUTCMonth(month: number, date?: number): number;
            setUTCSeconds(sec: number, ms?: number): number;
            toDateString(): string;
            toISOString(): string;
            toJSON(key?: any): string;
            toLocaleDateString(): string;
            toLocaleDateString(locales?: string | string[], options?: DateTimeFormatOptions): string;
            toLocaleDateString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string;
            toLocaleString(): string;
            toLocaleString(locales?: string | string[], options?: DateTimeFormatOptions): string;
            toLocaleString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string;
            toLocaleTimeString(): string;
            toLocaleTimeString(locales?: string | string[], options?: DateTimeFormatOptions): string;
            toLocaleTimeString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string;
            toString(): string;
            toTimeString(): string;
            toUTCString(): string;
            valueOf(): number;
        };
    };
    clearImmediate: ((immediateId: undefined | Immediate) => void);
    clearInterval: {
        (id: undefined | number): void;
        (intervalId:
            | undefined
            | string
            | number
            | Timeout): void;
    };
    clearTimeout: {
        (id: undefined | number): void;
        (timeoutId:
            | undefined
            | string
            | number
            | Timeout): void;
    };
    performance: {
        now: (() => number);
    };
    process: {
        hrtime: {
            bigint(): bigint;
            (t?: [number, number]): [number, number];
        };
    };
    setImmediate: SetImmediate;
    setInterval: SetInterval;
    setTimeout: SetTimeout;
}

Properties

Date: DateConstructor | {
    UTC(year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
    now(): number;
    parse(s: string): number;
    new (...args: any[]): {
        getVarDate: (() => VarDate);
        [toPrimitive](hint: "default"): string;
        [toPrimitive](hint: "string"): string;
        [toPrimitive](hint: "number"): number;
        [toPrimitive](hint: string): string | number;
        getDate(): number;
        getDay(): number;
        getFullYear(): number;
        getHours(): number;
        getMilliseconds(): number;
        getMinutes(): number;
        getMonth(): number;
        getSeconds(): number;
        getTime(): number;
        getTimezoneOffset(): number;
        getUTCDate(): number;
        getUTCDay(): number;
        getUTCFullYear(): number;
        getUTCHours(): number;
        getUTCMilliseconds(): number;
        getUTCMinutes(): number;
        getUTCMonth(): number;
        getUTCSeconds(): number;
        setDate(date: number): number;
        setFullYear(year: number, month?: number, date?: number): number;
        setHours(hours: number, min?: number, sec?: number, ms?: number): number;
        setMilliseconds(ms: number): number;
        setMinutes(min: number, sec?: number, ms?: number): number;
        setMonth(month: number, date?: number): number;
        setSeconds(sec: number, ms?: number): number;
        setTime(time: number): number;
        setUTCDate(date: number): number;
        setUTCFullYear(year: number, month?: number, date?: number): number;
        setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number;
        setUTCMilliseconds(ms: number): number;
        setUTCMinutes(min: number, sec?: number, ms?: number): number;
        setUTCMonth(month: number, date?: number): number;
        setUTCSeconds(sec: number, ms?: number): number;
        toDateString(): string;
        toISOString(): string;
        toJSON(key?: any): string;
        toLocaleDateString(): string;
        toLocaleDateString(locales?: string | string[], options?: DateTimeFormatOptions): string;
        toLocaleDateString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string;
        toLocaleString(): string;
        toLocaleString(locales?: string | string[], options?: DateTimeFormatOptions): string;
        toLocaleString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string;
        toLocaleTimeString(): string;
        toLocaleTimeString(locales?: string | string[], options?: DateTimeFormatOptions): string;
        toLocaleTimeString(locales?: LocalesArgument, options?: DateTimeFormatOptions): string;
        toString(): string;
        toTimeString(): string;
        toUTCString(): string;
        valueOf(): number;
    };
}
clearImmediate: ((immediateId: undefined | Immediate) => void)

Type declaration

    • (immediateId): void
    • Cancels an Immediate object created by setImmediate().

      Parameters

      • immediateId: undefined | Immediate

      Returns void

      v0.9.1

clearInterval: {
    (id: undefined | number): void;
    (intervalId:
        | undefined
        | string
        | number
        | Timeout): void;
}

Type declaration

    • (id): void
    • Parameters

      • id: undefined | number

      Returns void

    • (intervalId): void
    • Cancels a Timeout object created by setInterval().

      Parameters

      • intervalId:
            | undefined
            | string
            | number
            | Timeout

      Returns void

      v0.0.1

clearTimeout: {
    (id: undefined | number): void;
    (timeoutId:
        | undefined
        | string
        | number
        | Timeout): void;
}

Type declaration

    • (id): void
    • Parameters

      • id: undefined | number

      Returns void

    • (timeoutId): void
    • Cancels a Timeout object created by setTimeout().

      Parameters

      • timeoutId:
            | undefined
            | string
            | number
            | Timeout

      Returns void

      v0.0.1

performance: {
    now: (() => number);
}
process: {
    hrtime: {
        bigint(): bigint;
        (t?: [number, number]): [number, number];
    };
}
setImmediate: SetImmediate
setInterval: SetInterval
setTimeout: SetTimeout