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

1.2.3 • Public • Published

Installation

npm install --save @types/roll

Summary

This package contains type definitions for roll (https://github.com/troygoode/node-roll/).

Details

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

index.d.ts

type RollTransformation = RollTransformationKey | [RollTransformationKey, number] | ((results: number[]) => number[]);

type RollTransformationKey = "sum" | "add" | "subtract" | "multiply" | "divide" | "best-of" | "worst-of";

interface RollObject {
    quantity: number;
    sides: number;
    transformations: RollTransformation[];
    toString: () => string;
}

interface RollOutput {
    input: RollObject;
    calculations: number[];
    rolled: number[];
    result: number;
}

declare class InvalidInputError extends Error {
    name: "InvalidInputError";
}

declare class Roll {
    static InvalidInputError: InvalidInputError;

    constructor(seed?: () => number);

    /**
     * Validate user input
     */
    validate(input: string): boolean;

    /**
     * Parse a string into a roll object
     * @throws InvalidInputError
     */
    parse(input: string): {
        quantity: number;
        sides: number;
        transformations: RollTransformation[];
        toString: () => string;
    };

    /**
     * Roll based on a string or roll object
     */
    roll(input: string | RollObject): RollOutput;
}

export = Roll;

Additional Details

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

Credits

These definitions were written by icopp.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/roll

Weekly Downloads

233

Version

1.2.3

License

MIT

Unpacked Size

4.75 kB

Total Files

5

Last publish

Collaborators

  • types