1.0.6 • Published 6 months ago

@types/mock-raf v1.0.6

Weekly downloads
964
License
MIT
Repository
github
Last release
6 months ago

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

// Type definitions for mock-raf 1.0
// Project: https://github.com/FormidableLabs/mock-raf
// Definitions by: Daniel Pereira <https://github.com/djpereira>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

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: Thu, 08 Jul 2021 18:50:53 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Daniel Pereira.

1.0.6

6 months ago

1.0.5

7 months ago

1.0.4

8 months ago

1.0.3

3 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago