npm.io
1.2.4 • Published 2 years ago

@types/loopbench

Licence
MIT
Version
1.2.4
Deps
1
Size
7 kB
Vulns
0
Weekly
0
Stars
51.4K

Installation

npm install --save @types/loopbench

Summary

This package contains type definitions for loopbench (https://github.com/mcollina/loopbench#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/loopbench.

index.d.ts

/// <reference types="node" />

import { EventEmitter } from "events";

export = loopbench;

/**
 * Creates a new instance of loopbench.
 */
declare function loopbench(options?: loopbench.Options): loopbench.LoopBench;

declare namespace loopbench {
    interface Options {
        /**
         * The interval at which the eventLoop should be sampled, defaults to `5`.
         */
        sampleInterval?: number | undefined;
        /**
         * The maximum amount of delay that is tolerated before `overLimit` becomes true,
         * and the `load` event is emitted, defaults to `42`.
         */
        limit?: number | undefined;
    }

    /**
     * Events:
     * - `load`, emitted when `instance.delay > instance.limit`
     * - `unload`, emitted when `overLimit` goes from `true` and `false`
     */
    interface LoopBench extends EventEmitter {
        /**
         * The delay in milliseconds (and fractions) from the expected run. It might be negative (in older nodes).
         */
        readonly delay: number;

        /**
         * The maximum amount of delay that is tolerated before `overLimit` becomes true,
         * and the `load` event is emitted.
         */
        readonly limit: number;

        /**
         * Is `true` if the `instance.delay > instance.limit`.
         */
        readonly overLimit: boolean;

        /**
         * Stops the sampling.
         */
        stop(): void;

        addListener(event: "load" | "unload", listener: () => void): this;
        on(event: "load" | "unload", listener: () => void): this;
        once(event: "load" | "unload", listener: () => void): this;
        removeListener(event: "load" | "unload", listener: () => void): this;
        off(event: "load" | "unload", listener: () => void): this;
        removeAllListeners(event?: "load" | "unload"): this;
        listeners(event: "load" | "unload"): Array<() => void>;
        rawListeners(event: "load" | "unload"): Array<() => void>;
        emit(event: "load" | "unload"): boolean;
        listenerCount(type: "load" | "unload"): number;
        prependListener(event: "load" | "unload", listener: () => void): this;
        prependOnceListener(event: "load" | "unload", listener: () => void): this;
        eventNames(): Array<"load" | "unload">;
    }
}

Additional Details

  • Last updated: Tue, 07 Nov 2023 0938 GMT
  • Dependencies: @types/node

Credits

These definitions were written by BendingBender.