UNPKG

dicewerx

Version:

Standard dice notation parser and evaluator, written in TypeScript

31 lines (30 loc) 1.2 kB
export declare const toRollReg: RegExp; export declare const xReg: RegExp; export declare const opReg: RegExp; /** * Returns a string representation of dice to be rolled * @remarks * Expects to see an expression like 4d6 or 1d20. * Will throw an error on bad input * @param expression - The string to parse for a dice expression * @returns A string representation of dice to be rolled */ export declare function getDice(expression: string): string; /** * Returns a string representation of die to be drop * @param expression - The string to parse for a drop expression * @returns A string representation of dice to be dropped */ export declare function getDrop(expression: string): string; /** * Returns a string representation of a dice operator * @param expression - The string to parse for a operator expression * @returns A string representation of operator to apply */ export declare function getOperator(expression: string): string; /** * Evaluates standard dice notation and returns the result of the rolls * @param expression - The dice notation string to parse * @returns The result of the parsed die roll. */ export declare function evaluate(expression: string): number;