@types/mock-raf
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Installation

npm install --save @types/mock-raf

Summary

This package contains type definitions for mock-raf (https://github.com/FormidableLabs/mock-raf).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mock-raf.

index.d.ts

declare namespace MockRaf {
    interface Options {
        /** The time that should pass during each requestAnimationFrame step in milliseconds. Default is roughly equivalent to default browser behavior. */
        time?: number | undefined;

        /** The number of steps to take. */
        count?: number | undefined;
    }

    /** Creates a mockRaf instance, exposing the functions you'll use to interact with the mock. */
    interface Creator {
        /**
         * Returns the current now value of the mock. Starts at 0 and increases with each step() taken.
         * Useful for stubbing out performance.now() or a polyfill when using requestAnimationFrame with timers.
         */
        now(): number;

        /** Replacement for requestAnimationFrame or a polyfill.Adds a callback to be fired on the next step. */
        raf(callback: FrameRequestCallback): number;

        /** Replacement for cancelAnimationFrame or a polyfill.Removes all currently scheduled requestAnimationFrame callbacks from the queue. */
        cancel(handle: number): void;

        /** Takes requestAnimationFrame steps. Fires currently queued callbacks for each step and increments now time for each step. The primary way to interact with a mockRaf instance for testing. */
        step(options?: Options): void;
    }
}

declare function MockRaf(): MockRaf.Creator;

export = MockRaf;

Additional Details

  • Last updated: Tue, 07 Nov 2023 09:09:39 GMT
  • Dependencies: none

Credits

These definitions were written by Daniel Pereira.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/mock-raf

Weekly Downloads

5,444

Version

1.0.6

License

MIT

Unpacked Size

5.31 kB

Total Files

5

Last publish

Collaborators

  • types