@yipe/dice 0.2.22 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/builder/index.cjs +392 -295
- package/dist/builder/index.cjs.map +1 -1
- package/dist/builder/index.d.cts +9 -9
- package/dist/builder/index.d.ts +9 -9
- package/dist/builder/index.js +392 -296
- package/dist/builder/index.js.map +1 -1
- package/dist/index.cjs +356 -256
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +356 -257
- package/dist/index.js.map +1 -1
- package/dist/{pmf-BC1poIqF.d.cts → pmf-DqUCnYN9.d.cts} +89 -10
- package/dist/{pmf-BC1poIqF.d.ts → pmf-DqUCnYN9.d.ts} +89 -10
- package/package.json +11 -13
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import { P as PMF } from './pmf-
|
|
2
|
-
export { B as Bin, C as CritConfig,
|
|
1
|
+
import { P as PMF } from './pmf-DqUCnYN9.cjs';
|
|
2
|
+
export { B as Bin, C as CritConfig, a as DamageDistribution, D as DiceQuery, E as EPS, L as LRUCache, O as OutcomeLabelMap, b as OutcomeSnapshot, c as OutcomeType, R as Rounding, S as Snapshot, o as onAnyHit, d as onCritOnly, e as onHitOnly, f as onMissDamageOnly, g as onMissOnly, h as onPotentCantripOnly, i as onSaveFailOnly, j as onSaveHalfOnly, p as pmfCache } from './pmf-DqUCnYN9.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a dice expression cannot be parsed.
|
|
6
|
+
*
|
|
7
|
+
* Extends the built-in {@link Error}, so existing `catch (e)` / message checks
|
|
8
|
+
* continue to work, while callers can now narrow with `instanceof DiceParseError`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* try {
|
|
12
|
+
* parse("d6@3");
|
|
13
|
+
* } catch (e) {
|
|
14
|
+
* if (e instanceof DiceParseError) {
|
|
15
|
+
* // e.expression === "d6@3"
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
declare class DiceParseError extends Error {
|
|
20
|
+
/** The original expression that failed to parse, when available. */
|
|
21
|
+
readonly expression?: string;
|
|
22
|
+
/** The underlying error that triggered this one, when available. */
|
|
23
|
+
readonly cause?: unknown;
|
|
24
|
+
constructor(message: string, options?: {
|
|
25
|
+
expression?: string;
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
3
29
|
|
|
4
30
|
/** Enable or disable the internal parse cache. */
|
|
5
31
|
declare function setCachingEnabled(enabled: boolean): void;
|
|
@@ -50,4 +76,4 @@ declare class Mixture<L extends string = string> {
|
|
|
50
76
|
static mix<L extends string = string>(items: Array<[label: L, pmf: PMF, weight: number]>, eps?: number): PMF;
|
|
51
77
|
}
|
|
52
78
|
|
|
53
|
-
export { Mixture, PMF, clearParserCache, getCachingEnabled, parse, setCachingEnabled };
|
|
79
|
+
export { DiceParseError, Mixture, PMF, clearParserCache, getCachingEnabled, parse, setCachingEnabled };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import { P as PMF } from './pmf-
|
|
2
|
-
export { B as Bin, C as CritConfig,
|
|
1
|
+
import { P as PMF } from './pmf-DqUCnYN9.js';
|
|
2
|
+
export { B as Bin, C as CritConfig, a as DamageDistribution, D as DiceQuery, E as EPS, L as LRUCache, O as OutcomeLabelMap, b as OutcomeSnapshot, c as OutcomeType, R as Rounding, S as Snapshot, o as onAnyHit, d as onCritOnly, e as onHitOnly, f as onMissDamageOnly, g as onMissOnly, h as onPotentCantripOnly, i as onSaveFailOnly, j as onSaveHalfOnly, p as pmfCache } from './pmf-DqUCnYN9.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a dice expression cannot be parsed.
|
|
6
|
+
*
|
|
7
|
+
* Extends the built-in {@link Error}, so existing `catch (e)` / message checks
|
|
8
|
+
* continue to work, while callers can now narrow with `instanceof DiceParseError`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* try {
|
|
12
|
+
* parse("d6@3");
|
|
13
|
+
* } catch (e) {
|
|
14
|
+
* if (e instanceof DiceParseError) {
|
|
15
|
+
* // e.expression === "d6@3"
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
declare class DiceParseError extends Error {
|
|
20
|
+
/** The original expression that failed to parse, when available. */
|
|
21
|
+
readonly expression?: string;
|
|
22
|
+
/** The underlying error that triggered this one, when available. */
|
|
23
|
+
readonly cause?: unknown;
|
|
24
|
+
constructor(message: string, options?: {
|
|
25
|
+
expression?: string;
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
3
29
|
|
|
4
30
|
/** Enable or disable the internal parse cache. */
|
|
5
31
|
declare function setCachingEnabled(enabled: boolean): void;
|
|
@@ -50,4 +76,4 @@ declare class Mixture<L extends string = string> {
|
|
|
50
76
|
static mix<L extends string = string>(items: Array<[label: L, pmf: PMF, weight: number]>, eps?: number): PMF;
|
|
51
77
|
}
|
|
52
78
|
|
|
53
|
-
export { Mixture, PMF, clearParserCache, getCachingEnabled, parse, setCachingEnabled };
|
|
79
|
+
export { DiceParseError, Mixture, PMF, clearParserCache, getCachingEnabled, parse, setCachingEnabled };
|