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

0.1.6 • Public • Published

Installation

npm install --save @types/reservoir

Summary

This package contains type definitions for reservoir (https://github.com/imbcmdth/reservoir).

Details

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

index.d.ts

export as namespace Reservoir;
export = Reservoir;

/**
 * Create a new reservoir sampler.
 *
 * @param reservoirSize is the maximum size of the reservoir. This is the number of elements
 *   to be randomly chosen from the input provided to it using pushSome. Default is 1.
 * @param randomNumberGenerator is an optional random number generating function to use in
 *   place of the default Math.random.
 */
declare function Reservoir<T>( // eslint-disable-line @definitelytyped/no-unnecessary-generics
    reservoirSize?: number,
    randomNumberGenerator?: () => number,
): Reservoir.ReservoirArray<T>;

/*~ If you want to expose types from your module as well, you can
 *~ place them in this block. Often you will want to describe the
 *~ shape of the return type of the function; that type should
 *~ be declared in here, as this example shows.
 */
declare namespace Reservoir {
    interface ReservoirArray<T> extends Array<T> {
        /**
         * datum: one or more elements to consider for inclusion into the reservoir.
         * Returns the current length of the reservoir.
         */
        pushSome(...datum: T[]): number;
    }
}

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: none

Credits

These definitions were written by Dan Vanderkam.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/reservoir

Weekly Downloads

4

Version

0.1.6

License

MIT

Unpacked Size

4.82 kB

Total Files

5

Last publish

Collaborators

  • types