@mark1russell7/coeval 0.26.0 → 0.26.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/coeval",
4
- "version": "0.26.0",
4
+ "version": "0.26.1",
5
5
  "description": "coeval: the kernel of declarative languages. Documents in envelopes, a ladder that finds the evaluator, kind contracts, compiled plans, a static kit, a formula kit and a run side with capabilities.",
6
6
  "type": "module",
7
7
  "main": "./build/index.js",
@@ -46,6 +46,9 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
+ "dependencies": {
50
+ "@mark1russell7/rigor-generators": "^0.1.8"
51
+ },
49
52
  "scripts": {
50
53
  "build": "tsdown",
51
54
  "test": "vitest run",
package/src/generate.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type Json, type Key, docEquals, isEnvelope, typePath } from "./doc.ts";
2
2
  import { type Kind, type ScopeRule, type Shape, type World, type WorldEntry, isAlias, isKind, isNamespace, lookupKind } from "./world.ts";
3
3
  import { pathMatches } from "./parts.ts";
4
+ import { mulberry32 } from "@mark1russell7/rigor-generators";
4
5
  import { ROOTS, type Root } from "./deref.ts";
5
6
 
6
7
  /** A source of random numbers with a seed. The same seed gives the same numbers. */
@@ -16,20 +17,14 @@ export interface Random {
16
17
  }
17
18
 
18
19
  /**
19
- * This function makes a source of random numbers with a seed (the algorithm mulberry32). It needs no package.
20
+ * This function makes a source of random numbers with a seed. The numbers come from `mulberry32` of
21
+ * `@mark1russell7/rigor-generators` (K248, D191). The draws `int`, `chance` and `pick` keep the rules of the core.
20
22
  *
21
23
  * @param seed - The seed: a whole number.
22
24
  * @returns The source.
23
25
  */
24
26
  export function random(seed: number): Random {
25
- let state = seed >>> 0;
26
- const next = (): number => {
27
- state = (state + 0x6d2b79f5) >>> 0;
28
- let t = state;
29
- t = Math.imul(t ^ (t >>> 15), t | 1);
30
- t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
31
- return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
32
- };
27
+ const next = mulberry32(seed);
33
28
  const int = (below: number): number => Math.floor(next() * below);
34
29
  return { next, int, chance: (p) => next() < p, pick: (items) => items[int(items.length)] as never };
35
30
  }