roll-parser - v3.4.0
    Preparing search index...

    Type Alias RollResult

    RollResult: Readonly<
        {
            degree?: DegreeOfSuccess;
            expression: string;
            failures?: number;
            natural?: number;
            notation: string;
            parts: RollPart;
            rendered: string;
            rolls: DieResult[];
            successes?: number;
            total: number;
        },
    >

    Complete roll result with all metadata — what roll and evaluate return.

    The top level is Readonly — a result describes one completed evaluation and is never re-targeted. The rolls array and the parts tree stay mutable so consumers can annotate or re-sort their own views.

    Fully JSON-serializable; this is exactly what the CLI's --json flag emits.

    import { roll } from 'roll-parser';
    import { createMockRng } from 'roll-parser/testing';

    const result = roll('3d6', { rng: createMockRng([4, 2, 6]) });

    JSON.stringify(result);
    // {
    // "total": 12,
    // "notation": "3d6",
    // "expression": "3d6",
    // "rendered": "3d6[4, 2, 6] = 12",
    // "rolls": [
    // { "sides": 6, "result": 4, "modifiers": ["kept"], "critical": false, "fumble": false },
    // { "sides": 6, "result": 2, "modifiers": ["kept"], "critical": false, "fumble": false },
    // { "sides": 6, "result": 6, "modifiers": ["kept"], "critical": true, "fumble": false }
    // ],
    // "parts": {
    // "type": "dice", "count": 3, "sides": 6,
    // "rolls": [ ...the same three objects... ],
    // "total": 12, "start": 0, "end": 3
    // }
    // }