@spotlab/range 0.1.0 → 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 CHANGED
@@ -10,8 +10,13 @@ import { initRange, parseRange, formatRange } from "@spotlab/range";
10
10
  await initRange(); // once, at startup; idempotent, returns the same promise
11
11
  const hands = parseRange("AKs:0.5,QQ"); // synchronous from here on
12
12
  formatRange(hands); // "AKs:0.5,QQ"
13
+ formatRange(parseRange("AA,KK,QQ,A5s-A2s:0.5")); // "QQ+,A5s-A2s:0.5"
13
14
  ```
14
15
 
16
+ The grammar (hand tokens, combos, suitless combos, `22+` / `TT-77` shorthand)
17
+ and the canonical rendering rules are documented in the
18
+ [`spotlab-range` README](../../crates/spotlab-range#grammar).
19
+
15
20
  ## Why an explicit `initRange()`
16
21
 
17
22
  Instantiating a wasm module is asynchronous, and top-level `await` is not
package/dist/index.d.ts CHANGED
@@ -4,8 +4,7 @@ export declare const RANKS: readonly string[];
4
4
  export declare const SUITS: readonly string[];
5
5
  export declare const COMBOS: readonly string[];
6
6
  export { SpotlabInputError, RangeInitError, RangeNotInitializedError, } from './errors.js';
7
- export { Hand } from './types.js';
8
- export type { HandFrequency } from './types.js';
7
+ export type { Hand, HandFrequency } from './types.js';
9
8
  /** Parse a range string into its expanded hand-keyed form. */
10
9
  export declare function parseRange(input: string): HandFrequency[];
11
10
  /** Render a hand-keyed range back to its compacted string form. */
@@ -19,5 +18,14 @@ export declare function handsOfCombo(combo: string): Hand[];
19
18
  * serializes the underlying Rust map as a JS `Map`, not a plain object.
20
19
  */
21
20
  export declare function toComboWeights(hands: HandFrequency[]): Map<string, number>;
21
+ /**
22
+ * Expand per-combo weights to a hand-keyed range: every hand of each combo
23
+ * takes that combo's weight, and zero-weight combos are dropped. The inverse
24
+ * of `toComboWeights` — `toComboWeights(expandComboWeights(m))` gives back `m`,
25
+ * up to float rounding — though not the other way round, since the collapse
26
+ * averages over a combo's hands. Throws `SpotlabInputError` for a key that
27
+ * isn't a combo or a weight outside `[0, 1]`, as `parseRange` does.
28
+ */
29
+ export declare function expandComboWeights(weights: Map<string, number>): HandFrequency[];
22
30
  /** Every hand in the deck at weight 1 — the unconstrained range. */
23
31
  export declare function fullRange(): HandFrequency[];