# @types/roll

> TypeScript definitions for roll

Latest version **1.2.3** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/roll
pnpm add @types/roll
yarn add @types/roll
bun add @types/roll
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2023-11-07 |
| First published | 2018-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51450 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/roll
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/roll
- npm.io page: https://npm.io/package/@types/roll

## Recent versions

- 1.2.3 (latest) — 2023-11-07
- 1.2.0 (ts2.0) — 2018-04-26
- 1.2.2 — 2023-10-18
- 1.2.1 — 2023-09-27

## README

# 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](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/roll/index.d.ts)
````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](https://github.com/icopp).

---
_Source: https://npm.io/package/@types/roll · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
