@mark1russell7/vex-domains 0.2.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/LICENSE +21 -21
- package/README.md +41 -0
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +16 -2
- package/src/ndvector.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Mark Russell
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mark Russell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @mark1russell7/vex-domains
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@mark1russell7/vex-domains) [](https://github.com/mark1russell7/vex/blob/main/LICENSE)
|
|
4
|
+
|
|
5
|
+
Domains for [Vex](https://mark1russell7.github.io/vex/), the typed spreadsheet formulas over TypeScript objects. A domain tells Vex which values belong to it, which ops they have, and which laws the ops obey.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @mark1russell7/vex @mark1russell7/vex-domains
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Domains
|
|
14
|
+
|
|
15
|
+
| Domain | Values | Example ops |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `Vec2Domain` | `Vec2`: a 2D vector | `add`, `subtract`, `scale`, `length`, `distance`, `dot`, `rotate`, `allPositive` |
|
|
18
|
+
| `NDVectorDomain` | `NDVector`: a vector with named components | `add`, `subtract`, `scale`, `dot` |
|
|
19
|
+
| `NumDomain` | numbers | `add`, `multiply`, `min`, `max`, `sqrt`, `floor`, `gt` |
|
|
20
|
+
| `BoolDomain` | booleans | `and`, `or`, `xor`, `not` |
|
|
21
|
+
| `ColorDomain` | `Color`: an RGB color | `mix`, `add`, `multiply`, `luminance` |
|
|
22
|
+
| `AngleDomain` | `Angle`: an angle | `add`, `normalize`, `sin`, `cos`, `degrees` |
|
|
23
|
+
| `FnDomain`, `MaybeDomain` | Two example domains: function wrappers and `Maybe` | `invoke`, `map`, `chain`, `valueOr` |
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
The far corner of each box: its position plus its size.
|
|
28
|
+
|
|
29
|
+
```ts doctest
|
|
30
|
+
import { space, vex } from "@mark1russell7/vex";
|
|
31
|
+
import { Vec2, Vec2Domain } from "@mark1russell7/vex-domains";
|
|
32
|
+
|
|
33
|
+
const root = vex(Vec2Domain).over(space.record({ A: { position: new Vec2(2, 2), size: new Vec2(5, 4) } }));
|
|
34
|
+
root.from("position")._.add("size").at("A"); // => { tag: "some", value: new Vec2(7, 6) }
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The [domains page](https://mark1russell7.github.io/vex/reference/domains/) lists each op with its laws.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
package/build/index.js
CHANGED
|
@@ -285,7 +285,7 @@ var NDVector = class NDVector {
|
|
|
285
285
|
}
|
|
286
286
|
/** The value of a component, or 0 if the vector does not have it. */
|
|
287
287
|
get(k) {
|
|
288
|
-
return Object.hasOwn(this.c, k) ? this.c[k]
|
|
288
|
+
return Object.hasOwn(this.c, k) ? Number(this.c[k]) : 0;
|
|
289
289
|
}
|
|
290
290
|
set(k, v) {
|
|
291
291
|
return new NDVector({
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/vec2.ts","../src/ndvector.ts","../src/scalars.ts","../src/color.ts","../src/angle.ts","../src/wrappers.ts"],"sourcesContent":["import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\n\n/**\n * An immutable 2D vector. The methods live on the prototype, so a vector costs two numbers. Division is real\n * division: a division by zero gives an infinite component, and the domain check turns it into `#NUM!`.\n */\nexport class Vec2 {\n readonly x: number;\n readonly y: number;\n\n constructor(x: number, y: number) {\n this.x = x;\n this.y = y;\n }\n\n /** This function makes a vector. */\n static of(x: number, y: number): Vec2 {\n return new Vec2(x, y);\n }\n /** This function makes a vector with the same value in both components. */\n static scalar(n: number): Vec2 {\n return new Vec2(n, n);\n }\n /** The zero vector. */\n static readonly zero: Vec2 = new Vec2(0, 0);\n /** The vector of ones. */\n static readonly one: Vec2 = new Vec2(1, 1);\n\n add(o: Vec2): Vec2 {\n return new Vec2(this.x + o.x, this.y + o.y);\n }\n subtract(o: Vec2): Vec2 {\n return new Vec2(this.x - o.x, this.y - o.y);\n }\n /** The component-wise product. */\n multiply(o: Vec2): Vec2 {\n return new Vec2(this.x * o.x, this.y * o.y);\n }\n /** The component-wise quotient. A zero component of `o` gives an infinite component. */\n divide(o: Vec2): Vec2 {\n return new Vec2(this.x / o.x, this.y / o.y);\n }\n /** The component-wise minimum. */\n min(o: Vec2): Vec2 {\n return new Vec2(Math.min(this.x, o.x), Math.min(this.y, o.y));\n }\n /** The component-wise maximum. */\n max(o: Vec2): Vec2 {\n return new Vec2(Math.max(this.x, o.x), Math.max(this.y, o.y));\n }\n scale(k: number): Vec2 {\n return new Vec2(this.x * k, this.y * k);\n }\n negate(): Vec2 {\n return new Vec2(-this.x, -this.y);\n }\n halve(): Vec2 {\n return this.scale(0.5);\n }\n abs(): Vec2 {\n return new Vec2(Math.abs(this.x), Math.abs(this.y));\n }\n round(): Vec2 {\n return new Vec2(Math.round(this.x), Math.round(this.y));\n }\n floor(): Vec2 {\n return new Vec2(Math.floor(this.x), Math.floor(this.y));\n }\n ceil(): Vec2 {\n return new Vec2(Math.ceil(this.x), Math.ceil(this.y));\n }\n clamp(lo: number, hi: number): Vec2 {\n return new Vec2(Math.min(hi, Math.max(lo, this.x)), Math.min(hi, Math.max(lo, this.y)));\n }\n swap(): Vec2 {\n return new Vec2(this.y, this.x);\n }\n /** The vector turned by `radians`, counterclockwise. */\n rotate(radians: number): Vec2 {\n const c = Math.cos(radians);\n const s = Math.sin(radians);\n return new Vec2(c * this.x - s * this.y, s * this.x + c * this.y);\n }\n /** The vector with length 1. The zero vector stays zero. */\n normalize(): Vec2 {\n const len = this.length();\n return len === 0 ? this : this.scale(1 / len);\n }\n /** The linear interpolation from this vector to `o`. */\n lerp(o: Vec2, t: number): Vec2 {\n return new Vec2(this.x + (o.x - this.x) * t, this.y + (o.y - this.y) * t);\n }\n length(): number {\n return Math.hypot(this.x, this.y);\n }\n lengthSq(): number {\n return this.x * this.x + this.y * this.y;\n }\n distance(o: Vec2): number {\n return Math.hypot(this.x - o.x, this.y - o.y);\n }\n dot(o: Vec2): number {\n return this.x * o.x + this.y * o.y;\n }\n /** The z component of the 3D cross product. */\n cross(o: Vec2): number {\n return this.x * o.y - this.y * o.x;\n }\n /** The angle of the vector, in radians, from the x axis. */\n angle(): number {\n return Math.atan2(this.y, this.x);\n }\n /** The product of the components: the area of a size vector. */\n area(): number {\n return this.x * this.y;\n }\n /** The sum of the components. */\n sum(): number {\n return this.x + this.y;\n }\n minComponent(): number {\n return Math.min(this.x, this.y);\n }\n maxComponent(): number {\n return Math.max(this.x, this.y);\n }\n equals(o: Vec2): boolean {\n return this.x === o.x && this.y === o.y;\n }\n anyNonPositive(): boolean {\n return this.x <= 0 || this.y <= 0;\n }\n allPositive(): boolean {\n return this.x > 0 && this.y > 0;\n }\n anyNegative(): boolean {\n return this.x < 0 || this.y < 0;\n }\n allNonNegative(): boolean {\n return this.x >= 0 && this.y >= 0;\n }\n anyZero(): boolean {\n return this.x === 0 || this.y === 0;\n }\n allZero(): boolean {\n return this.x === 0 && this.y === 0;\n }\n anyLessThan(n: number): boolean {\n return this.x < n || this.y < n;\n }\n allLessThan(n: number): boolean {\n return this.x < n && this.y < n;\n }\n anyGreaterThan(n: number): boolean {\n return this.x > n || this.y > n;\n }\n allGreaterThan(n: number): boolean {\n return this.x > n && this.y > n;\n }\n toJSON(): { readonly x: number; readonly y: number } {\n return { x: this.x, y: this.y };\n }\n toString(): string {\n return `(${this.x}, ${this.y})`;\n }\n}\n\ntype Vec2OpNames =\n | \"add\" | \"subtract\" | \"multiply\" | \"divide\" | \"min\" | \"max\" | \"scale\" | \"negate\" | \"halve\" | \"abs\" | \"round\" | \"floor\"\n | \"ceil\" | \"clamp\" | \"swap\" | \"rotate\" | \"normalize\" | \"lerp\" | \"length\" | \"lengthSq\" | \"distance\" | \"dot\" | \"cross\"\n | \"angle\" | \"area\" | \"sum\" | \"minComponent\" | \"maxComponent\" | \"equals\" | \"anyNonPositive\" | \"allPositive\"\n | \"anyNegative\" | \"allNonNegative\" | \"anyZero\" | \"allZero\" | \"anyLessThan\" | \"allLessThan\" | \"anyGreaterThan\"\n | \"allGreaterThan\";\n\n/** The ops of `Vec2Domain`. */\nexport type Vec2Ops = OpTable<Vec2, Vec2OpNames, \"add\" | \"subtract\" | \"multiply\" | \"divide\" | \"min\" | \"max\">;\n\n/** The domain of 2D vectors. A number argument of a component-wise op lifts to a vector with that value twice. */\nexport const Vec2Domain: Domain<\"Vec2\", Vec2, Vec2Ops> = defineDomain<\"Vec2\", Vec2, Vec2Ops>({\n name: \"Vec2\",\n is: (u: unknown): u is Vec2 => u instanceof Vec2,\n fromScalar: (n: number): Vec2 => Vec2.scalar(n),\n valid: (v: Vec2): boolean => Number.isFinite(v.x) && Number.isFinite(v.y),\n show: (v: Vec2): string => v.toString(),\n encode: (v: Vec2): readonly [number, number] => [v.x, v.y],\n decode: (u: unknown): Vec2 => {\n const [x, y] = Array.isArray(u) ? (u as readonly unknown[]) : [];\n return new Vec2(typeof x === \"number\" ? x : Number.NaN, typeof y === \"number\" ? y : Number.NaN);\n },\n ops: {\n add: { laws: [\"commutative\", \"associative\"], identity: () => Vec2.zero, liftScalar: true, params: [\"domain\"] },\n subtract: { liftScalar: true, params: [\"domain\"] },\n multiply: { laws: [\"commutative\", \"associative\"], identity: () => Vec2.one, liftScalar: true, params: [\"domain\"] },\n divide: { liftScalar: true, params: [\"domain\"] },\n min: { laws: [\"commutative\", \"associative\", \"idempotent\"], liftScalar: true, params: [\"domain\"] },\n max: { laws: [\"commutative\", \"associative\", \"idempotent\"], liftScalar: true, params: [\"domain\"] },\n scale: { params: [\"number\"] },\n negate: {},\n halve: {},\n abs: {},\n round: {},\n floor: {},\n ceil: {},\n clamp: { params: [\"number\", \"number\"] },\n swap: {},\n rotate: { params: [\"number\"] },\n normalize: {},\n lerp: { params: [\"domain\", \"number\"] },\n length: {},\n lengthSq: {},\n distance: { params: [\"domain\"] },\n dot: { laws: [\"commutative\"], params: [\"domain\"] },\n cross: { params: [\"domain\"] },\n angle: {},\n area: {},\n sum: {},\n minComponent: {},\n maxComponent: {},\n equals: { laws: [\"commutative\"], params: [\"domain\"] },\n anyNonPositive: {},\n allPositive: {},\n anyNegative: {},\n allNonNegative: {},\n anyZero: {},\n allZero: {},\n anyLessThan: { params: [\"number\"] },\n allLessThan: { params: [\"number\"] },\n anyGreaterThan: { params: [\"number\"] },\n allGreaterThan: { params: [\"number\"] },\n },\n});\n","import { defineDomain, type Domain, type FnOp, type OpTable } from \"@mark1russell7/vex\";\n\n/**\n * An immutable vector with named components. The type parameter `K` is the set of component names. Ops that\n * combine two vectors use the union of their names, and a missing component counts as 0. The constructor\n * keeps each number, also a number that is not finite: the domain check reports such a value as `#NUM!`.\n */\nexport class NDVector<K extends string = string> {\n /** The components: name to number. */\n readonly c: Readonly<Record<K, number>>;\n\n constructor(c: Readonly<Record<K, number>>) {\n this.c = Object.freeze({ ...c });\n }\n\n /** This function makes a vector from name and value pairs. */\n static of<K extends string>(entries: readonly (readonly [K, number])[]): NDVector<K> {\n const c = {} as Record<K, number>;\n for (const [k, v] of entries) c[k] = v;\n return new NDVector(c);\n }\n /** This function makes the zero vector over the names `keys`. */\n static zero<K extends string>(keys: readonly K[] = []): NDVector<K> {\n return NDVector.of(keys.map((k) => [k, 0] as const));\n }\n\n /** The names of the components. */\n keys(): readonly K[] {\n return Object.keys(this.c) as K[];\n }\n /** The value of a component, or 0 if the vector does not have it. */\n get(k: string): number {\n return Object.hasOwn(this.c, k) ? (this.c as Readonly<Record<string, number>>)[k] ?? 0 : 0;\n }\n set<K2 extends string>(k: K2, v: number): NDVector<K | K2> {\n return new NDVector({ ...this.c, [k]: v } as Record<K | K2, number>);\n }\n map(f: (name: K, v: number) => number): NDVector<K> {\n const c = {} as Record<K, number>;\n for (const k of this.keys()) c[k] = f(k, this.get(k));\n return new NDVector(c);\n }\n /** The vector with only the names in `keys`. A zero component is dropped, unless `keepZeros` is true. */\n pick<K2 extends K>(keys: readonly K2[], keepZeros = false): NDVector<K2> {\n const c = {} as Record<K2, number>;\n for (const k of keys) {\n const v = this.get(k);\n if (keepZeros || v !== 0) c[k] = v;\n }\n return new NDVector(c);\n }\n /** The vector with the names in `keys` added. A new component is 0. */\n withKeys<K2 extends string>(keys: readonly K2[]): NDVector<K | K2> {\n const c = { ...this.c } as Record<K | K2, number>;\n for (const k of keys) if (!Object.hasOwn(c, k)) c[k] = 0;\n return new NDVector(c);\n }\n #combine<K2 extends string>(o: NDVector<K2>, f: (a: number, b: number) => number): NDVector<K | K2> {\n const c = {} as Record<K | K2, number>;\n for (const k of new Set<K | K2>([...this.keys(), ...o.keys()])) c[k] = f(this.get(k), o.get(k));\n return new NDVector(c);\n }\n add<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => a + b);\n }\n subtract<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => a - b);\n }\n /** The component-wise product. */\n multiply<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => a * b);\n }\n /** Of each component, the value of this vector if it is not 0, else the value of `o`. */\n mergePreferNonZero<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => (a !== 0 ? a : b));\n }\n scale(k: number): NDVector<K> {\n return this.map((_n, v) => v * k);\n }\n clamp(lo: number, hi: number): NDVector<K> {\n return this.map((_n, v) => Math.min(hi, Math.max(lo, v)));\n }\n dot(o: NDVector): number {\n let s = 0;\n for (const k of new Set<string>([...this.keys(), ...o.keys()])) s += this.get(k) * o.get(k);\n return s;\n }\n /** The L2 length. */\n length(): number {\n return Math.sqrt(this.keys().reduce((s, k) => s + this.get(k) ** 2, 0));\n }\n /** The L1 norm. */\n norm1(): number {\n return this.keys().reduce((s, k) => s + Math.abs(this.get(k)), 0);\n }\n /** The largest absolute component. */\n normInf(): number {\n return this.keys().reduce((m, k) => Math.max(m, Math.abs(this.get(k))), 0);\n }\n equals(o: NDVector): boolean {\n const keys = new Set<string>([...this.keys(), ...o.keys()]);\n for (const k of keys) if (this.get(k) !== o.get(k)) return false;\n return true;\n }\n /** True if each component is a finite number. */\n isFinite(): boolean {\n return this.keys().every((k) => Number.isFinite(this.get(k)));\n }\n toJSON(): Readonly<Record<K, number>> {\n return { ...this.c };\n }\n toString(): string {\n return `NDVector(${JSON.stringify(this.c)})`;\n }\n}\n\ntype NDOpNames =\n | \"add\" | \"subtract\" | \"multiply\" | \"mergePreferNonZero\" | \"scale\" | \"clamp\" | \"dot\" | \"length\" | \"norm1\" | \"normInf\"\n | \"equals\" | \"pick\" | \"withKeys\" | \"get\" | \"set\";\n\n/** The ops of `NDVectorDomain`. No op lifts numbers. */\nexport type NDVectorOps = OpTable<NDVector, NDOpNames>;\n\n/** The ops of `LiftedNDVectorDomain`. */\nexport type LiftedNDVectorOps = OpTable<NDVector, NDOpNames, \"add\" | \"subtract\" | \"multiply\" | \"dot\">;\n\nconst ndOps = {\n add: { laws: [\"commutative\", \"associative\"], identity: (): NDVector => NDVector.zero(), params: [\"domain\"] },\n subtract: { params: [\"domain\"] },\n multiply: { laws: [\"commutative\", \"associative\"], params: [\"domain\"] },\n mergePreferNonZero: { laws: [\"associative\", \"idempotent\"], params: [\"domain\"] },\n scale: { params: [\"number\"] },\n clamp: { params: [\"number\", \"number\"] },\n dot: { laws: [\"commutative\"], params: [\"domain\"] },\n length: {},\n norm1: {},\n normInf: {},\n equals: { laws: [\"commutative\"], params: [\"domain\"] },\n pick: {},\n withKeys: {},\n get: { params: [\"string\"] },\n set: { params: [\"string\", \"number\"] },\n} as const satisfies NDVectorOps;\n\nconst isNDVector = (u: unknown): u is NDVector => u instanceof NDVector;\n\n/** The domain of named-component vectors. A number argument is an error here: use `LiftedNDVectorDomain` to lift. */\nexport const NDVectorDomain: Domain<\"NDVector\", NDVector, NDVectorOps> = defineDomain<\"NDVector\", NDVector, NDVectorOps>({\n name: \"NDVector\",\n is: isNDVector,\n valid: (v: NDVector): boolean => v.isFinite(),\n show: (v: NDVector): string => v.toString(),\n encode: (v: NDVector): unknown => v.toJSON(),\n decode: (u: unknown): NDVector => new NDVector(u as Readonly<Record<string, number>>),\n ops: ndOps,\n});\n\n/**\n * The domain of named-component vectors with scalar lifting. A number argument of `add`, `subtract`,\n * `multiply` or `dot` becomes the vector `{ scalar: n }`. This domain is independent of `NDVectorDomain`:\n * the two can be in one program, and neither changes the other.\n */\nexport const LiftedNDVectorDomain: Domain<\"NDVector(lifted)\", NDVector, LiftedNDVectorOps> = defineDomain<\"NDVector(lifted)\", NDVector, LiftedNDVectorOps>({\n name: \"NDVector(lifted)\",\n is: isNDVector,\n fromScalar: (n: number): NDVector => new NDVector({ scalar: n }),\n valid: (v: NDVector): boolean => v.isFinite(),\n show: (v: NDVector): string => v.toString(),\n ops: {\n ...ndOps,\n add: { ...ndOps.add, liftScalar: true },\n subtract: { ...ndOps.subtract, liftScalar: true },\n multiply: { ...ndOps.multiply, liftScalar: true },\n dot: { ...ndOps.dot, liftScalar: true },\n },\n});\n\n/** A plain record whose values are finite numbers. */\nexport type NumRecord = Readonly<Record<string, number>>;\n\n/** The ops of `NumRecordDomain`. */\nexport type NumRecordOps = {\n readonly toNDVector: FnOp<NumRecord, (r: NumRecord) => NDVector>;\n};\n\nconst isNumRecord = (u: unknown): u is NumRecord => {\n if (typeof u !== \"object\" || u === null || Array.isArray(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return (proto === Object.prototype || proto === null) && Object.values(u).every((v) => typeof v === \"number\" && Number.isFinite(v));\n};\n\n/** The domain of plain number records. Its op `toNDVector` builds a vector from fields, for example from `rec()`. */\nexport const NumRecordDomain: Domain<\"NumRecord\", NumRecord, NumRecordOps> = defineDomain<\"NumRecord\", NumRecord, NumRecordOps>({\n name: \"NumRecord\",\n is: isNumRecord,\n ops: {\n toNDVector: { fn: (r: NumRecord): NDVector => new NDVector(r) },\n },\n});\n","import { defineDomain, type Domain, type FnOp } from \"@mark1russell7/vex\";\n\ntype NumFn1 = (a: number) => number;\ntype NumFn2 = (a: number, b: number) => number;\ntype NumFn3 = (a: number, b: number, c: number) => number;\ntype NumTest = (a: number, b: number) => boolean;\n\n/** The ops of `NumDomain`. */\nexport type NumOps = {\n readonly add: FnOp<number, NumFn2>;\n readonly subtract: FnOp<number, NumFn2>;\n readonly multiply: FnOp<number, NumFn2>;\n readonly divide: FnOp<number, NumFn2>;\n readonly mod: FnOp<number, NumFn2>;\n readonly pow: FnOp<number, NumFn2>;\n readonly min: FnOp<number, NumFn2>;\n readonly max: FnOp<number, NumFn2>;\n readonly clamp: FnOp<number, NumFn3>;\n readonly abs: FnOp<number, NumFn1>;\n readonly negate: FnOp<number, NumFn1>;\n readonly sqrt: FnOp<number, NumFn1>;\n readonly floor: FnOp<number, NumFn1>;\n readonly ceil: FnOp<number, NumFn1>;\n readonly round: FnOp<number, NumFn1>;\n readonly gt: FnOp<number, NumTest>;\n readonly gte: FnOp<number, NumTest>;\n readonly lt: FnOp<number, NumTest>;\n readonly lte: FnOp<number, NumTest>;\n readonly eq: FnOp<number, NumTest>;\n};\n\n/** The domain of numbers. A result that is not a finite number is the error `#NUM!`. */\nexport const NumDomain: Domain<\"Num\", number, NumOps> = defineDomain<\"Num\", number, NumOps>({\n name: \"Num\",\n is: (u: unknown): u is number => typeof u === \"number\",\n valid: (n: number): boolean => Number.isFinite(n),\n show: (n: number): string => String(n),\n ops: {\n add: { fn: (a: number, b: number): number => a + b, laws: [\"commutative\", \"associative\"], identity: (): number => 0, params: [\"number\"] },\n subtract: { fn: (a: number, b: number): number => a - b, params: [\"number\"] },\n multiply: { fn: (a: number, b: number): number => a * b, laws: [\"commutative\", \"associative\"], identity: (): number => 1, params: [\"number\"] },\n divide: { fn: (a: number, b: number): number => a / b, params: [\"number\"] },\n mod: { fn: (a: number, b: number): number => a % b, params: [\"number\"] },\n pow: { fn: (a: number, b: number): number => a ** b, params: [\"number\"] },\n min: { fn: (a: number, b: number): number => Math.min(a, b), laws: [\"commutative\", \"associative\", \"idempotent\"], params: [\"number\"] },\n max: { fn: (a: number, b: number): number => Math.max(a, b), laws: [\"commutative\", \"associative\", \"idempotent\"], params: [\"number\"] },\n clamp: { fn: (a: number, lo: number, hi: number): number => Math.min(hi, Math.max(lo, a)), params: [\"number\", \"number\"] },\n abs: { fn: (a: number): number => Math.abs(a) },\n negate: { fn: (a: number): number => -a },\n sqrt: { fn: (a: number): number => Math.sqrt(a) },\n floor: { fn: (a: number): number => Math.floor(a) },\n ceil: { fn: (a: number): number => Math.ceil(a) },\n round: { fn: (a: number): number => Math.round(a) },\n gt: { fn: (a: number, b: number): boolean => a > b, params: [\"number\"] },\n gte: { fn: (a: number, b: number): boolean => a >= b, params: [\"number\"] },\n lt: { fn: (a: number, b: number): boolean => a < b, params: [\"number\"] },\n lte: { fn: (a: number, b: number): boolean => a <= b, params: [\"number\"] },\n eq: { fn: (a: number, b: number): boolean => a === b, laws: [\"commutative\"], params: [\"number\"] },\n },\n});\n\ntype BoolFn1 = (a: boolean) => boolean;\ntype BoolFn2 = (a: boolean, b: boolean) => boolean;\n\n/** The ops of `BoolDomain`. */\nexport type BoolOps = {\n readonly and: FnOp<boolean, BoolFn2>;\n readonly or: FnOp<boolean, BoolFn2>;\n readonly xor: FnOp<boolean, BoolFn2>;\n readonly not: FnOp<boolean, BoolFn1>;\n readonly eq: FnOp<boolean, BoolFn2>;\n};\n\n/** The domain of booleans. For lazy logic, use the special forms `and`, `or` and `if` of the IR. */\nexport const BoolDomain: Domain<\"Bool\", boolean, BoolOps> = defineDomain<\"Bool\", boolean, BoolOps>({\n name: \"Bool\",\n is: (u: unknown): u is boolean => typeof u === \"boolean\",\n show: (b: boolean): string => String(b),\n ops: {\n and: { fn: (a: boolean, b: boolean): boolean => a && b, laws: [\"commutative\", \"associative\", \"idempotent\"], identity: (): boolean => true, params: [\"boolean\"] },\n or: { fn: (a: boolean, b: boolean): boolean => a || b, laws: [\"commutative\", \"associative\", \"idempotent\"], identity: (): boolean => false, params: [\"boolean\"] },\n xor: { fn: (a: boolean, b: boolean): boolean => a !== b, laws: [\"commutative\", \"associative\"], identity: (): boolean => false, params: [\"boolean\"] },\n not: { fn: (a: boolean): boolean => !a },\n eq: { fn: (a: boolean, b: boolean): boolean => a === b, laws: [\"commutative\"], params: [\"boolean\"] },\n },\n});\n","import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\n\n/**\n * An immutable RGBA color. The channels have no fixed range: use `clamp` to limit them. `add` adds the color\n * channels and keeps the larger alpha, so `add` is commutative and associative.\n */\nexport class Color {\n readonly r: number;\n readonly g: number;\n readonly b: number;\n readonly a: number;\n\n constructor(r: number, g: number, b: number, a = 1) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = a;\n }\n\n /** This function makes a gray color with the value `n` in each channel. */\n static gray(n: number): Color {\n return new Color(n, n, n, 1);\n }\n /** The black color with alpha 0: the identity of `add`. */\n static readonly none: Color = new Color(0, 0, 0, 0);\n\n /** The channel sum. The alpha is the larger alpha. */\n add(o: Color): Color {\n return new Color(this.r + o.r, this.g + o.g, this.b + o.b, Math.max(this.a, o.a));\n }\n /** Each color channel times `factor`. The alpha does not change. */\n multiply(factor: number): Color {\n return new Color(this.r * factor, this.g * factor, this.b * factor, this.a);\n }\n /** Each color channel in the range from `lo` to `hi`. */\n clamp(lo = 0, hi = 255): Color {\n const c = (x: number): number => Math.min(hi, Math.max(lo, x));\n return new Color(c(this.r), c(this.g), c(this.b), this.a);\n }\n /** The linear mix from this color to `o`. */\n mix(o: Color, t: number): Color {\n const m = (x: number, y: number): number => x + (y - x) * t;\n return new Color(m(this.r, o.r), m(this.g, o.g), m(this.b, o.b), m(this.a, o.a));\n }\n /** The relative luminance (Rec. 709 weights) of the color channels. */\n luminance(): number {\n return 0.2126 * this.r + 0.7152 * this.g + 0.0722 * this.b;\n }\n equals(o: Color): boolean {\n return this.r === o.r && this.g === o.g && this.b === o.b && this.a === o.a;\n }\n toArray(): readonly [number, number, number, number] {\n return [this.r, this.g, this.b, this.a];\n }\n toString(): string {\n return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`;\n }\n}\n\n/** The ops of `ColorDomain`. */\nexport type ColorOps = OpTable<Color, \"add\" | \"multiply\" | \"clamp\" | \"mix\" | \"luminance\" | \"equals\">;\n\n/** The domain of colors. */\nexport const ColorDomain: Domain<\"Color\", Color, ColorOps> = defineDomain<\"Color\", Color, ColorOps>({\n name: \"Color\",\n is: (u: unknown): u is Color => u instanceof Color,\n fromScalar: (n: number): Color => Color.gray(n),\n valid: (c: Color): boolean => c.toArray().every((x) => Number.isFinite(x)),\n show: (c: Color): string => c.toString(),\n encode: (c: Color): readonly number[] => c.toArray(),\n decode: (u: unknown): Color => {\n const [r, g, b, a] = (Array.isArray(u) ? u : []) as readonly number[];\n return new Color(r ?? Number.NaN, g ?? Number.NaN, b ?? Number.NaN, a ?? 1);\n },\n ops: {\n add: { laws: [\"commutative\", \"associative\"], identity: (): Color => Color.none, params: [\"domain\"] },\n multiply: { params: [\"number\"] },\n clamp: { params: [\"number\", \"number\"] },\n mix: { params: [\"domain\", \"number\"] },\n luminance: {},\n equals: { laws: [\"commutative\"], params: [\"domain\"] },\n },\n});\n","import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\nimport { Vec2 } from \"./vec2.ts\";\n\n/** An immutable angle in radians. */\nexport class Angle {\n readonly radians: number;\n\n constructor(radians: number) {\n this.radians = radians;\n }\n\n /** This function makes an angle from degrees. */\n static fromDegrees(deg: number): Angle {\n return new Angle((deg * Math.PI) / 180);\n }\n /** The zero angle: the identity of `add`. */\n static readonly zero: Angle = new Angle(0);\n\n add(o: Angle): Angle {\n return new Angle(this.radians + o.radians);\n }\n subtract(o: Angle): Angle {\n return new Angle(this.radians - o.radians);\n }\n scale(k: number): Angle {\n return new Angle(this.radians * k);\n }\n /** The same angle in the range from -π (included) to π (not included). */\n normalize(): Angle {\n const twoPi = Math.PI * 2;\n return new Angle((((this.radians + Math.PI) % twoPi) + twoPi) % twoPi - Math.PI);\n }\n /** The vector with this angle and the length `length`. The result is a `Vec2`, so a chain continues in that domain. */\n toVec2(length = 1): Vec2 {\n return new Vec2(Math.cos(this.radians) * length, Math.sin(this.radians) * length);\n }\n sin(): number {\n return Math.sin(this.radians);\n }\n cos(): number {\n return Math.cos(this.radians);\n }\n degrees(): number {\n return (this.radians * 180) / Math.PI;\n }\n toString(): string {\n return `${this.radians} rad`;\n }\n}\n\n/** The ops of `AngleDomain`. */\nexport type AngleOps = OpTable<Angle, \"add\" | \"subtract\" | \"scale\" | \"normalize\" | \"toVec2\" | \"sin\" | \"cos\" | \"degrees\", \"add\" | \"subtract\">;\n\n/** The domain of angles. A number argument of `add` or `subtract` lifts to an angle in radians. */\nexport const AngleDomain: Domain<\"Angle\", Angle, AngleOps> = defineDomain<\"Angle\", Angle, AngleOps>({\n name: \"Angle\",\n is: (u: unknown): u is Angle => u instanceof Angle,\n fromScalar: (n: number): Angle => new Angle(n),\n valid: (a: Angle): boolean => Number.isFinite(a.radians),\n show: (a: Angle): string => a.toString(),\n encode: (a: Angle): number => a.radians,\n decode: (u: unknown): Angle => new Angle(typeof u === \"number\" ? u : Number.NaN),\n ops: {\n add: { laws: [\"commutative\", \"associative\"], identity: (): Angle => Angle.zero, liftScalar: true, params: [\"domain\"] },\n subtract: { liftScalar: true, params: [\"domain\"] },\n scale: { params: [\"number\"] },\n normalize: {},\n toVec2: { params: [\"number\"] },\n sin: {},\n cos: {},\n degrees: {},\n },\n});\n","import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\n\n/** A wrapper around a function. Its op `invoke` calls the function. It shows how a domain can hold behavior. */\nexport class Fn {\n readonly fn: (...args: never[]) => unknown;\n\n constructor(fn: (...args: never[]) => unknown) {\n this.fn = fn;\n }\n invoke(...args: readonly unknown[]): unknown {\n return (this.fn as (...a: readonly unknown[]) => unknown)(...args);\n }\n}\n\n/** The ops of `FnDomain`. */\nexport type FnOps = OpTable<Fn, \"invoke\">;\n\n/** The domain of function wrappers. */\nexport const FnDomain: Domain<\"Fn\", Fn, FnOps> = defineDomain<\"Fn\", Fn, FnOps>({\n name: \"Fn\",\n is: (u: unknown): u is Fn => u instanceof Fn,\n ops: { invoke: {} },\n});\n\n/**\n * A value that is there (`top`) or not there (`bottom`). It shows a domain whose ops take functions. A Vex\n * program can also hold this state in its own errors, so most programs do not need this domain.\n */\nexport class Maybe<T> {\n readonly #has: boolean;\n readonly #value: T | undefined;\n\n private constructor(has: boolean, value: T | undefined) {\n this.#has = has;\n this.#value = value;\n }\n static top<T>(value: T): Maybe<T> {\n return new Maybe<T>(true, value);\n }\n static bottom<T = never>(): Maybe<T> {\n return new Maybe<T>(false, undefined);\n }\n isTop(): boolean {\n return this.#has;\n }\n isBottom(): boolean {\n return !this.#has;\n }\n map<U>(f: (value: T) => U): Maybe<U> {\n return this.#has ? Maybe.top(f(this.#value as T)) : Maybe.bottom<U>();\n }\n chain<U>(f: (value: T) => Maybe<U>): Maybe<U> {\n return this.#has ? f(this.#value as T) : Maybe.bottom<U>();\n }\n valueOr<U>(fallback: U): T | U {\n return this.#has ? (this.#value as T) : fallback;\n }\n}\n\n/** The ops of `MaybeDomain`. */\nexport type MaybeOps = OpTable<Maybe<unknown>, \"isTop\" | \"isBottom\" | \"map\" | \"chain\" | \"valueOr\">;\n\n/** The domain of `Maybe` values. */\nexport const MaybeDomain: Domain<\"Maybe\", Maybe<unknown>, MaybeOps> = defineDomain<\"Maybe\", Maybe<unknown>, MaybeOps>({\n name: \"Maybe\",\n is: (u: unknown): u is Maybe<unknown> => u instanceof Maybe,\n ops: { isTop: {}, isBottom: {}, map: {}, chain: {}, valueOr: {} },\n});\n"],"mappings":";;;;;;AAMA,IAAa,OAAb,MAAa,KAAK;CAChB;CACA;CAEA,YAAY,GAAW,GAAW;EAChC,KAAK,IAAI;EACT,KAAK,IAAI;CACX;;CAGA,OAAO,GAAG,GAAW,GAAiB;EACpC,OAAO,IAAI,KAAK,GAAG,CAAC;CACtB;;CAEA,OAAO,OAAO,GAAiB;EAC7B,OAAO,IAAI,KAAK,GAAG,CAAC;CACtB;;CAEA,OAAgB,OAAa,IAAI,KAAK,GAAG,CAAC;;CAE1C,OAAgB,MAAY,IAAI,KAAK,GAAG,CAAC;CAEzC,IAAI,GAAe;EACjB,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;CAC5C;CACA,SAAS,GAAe;EACtB,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;CAC5C;;CAEA,SAAS,GAAe;EACtB,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;CAC5C;;CAEA,OAAO,GAAe;EACpB,OAAO,IAAI,KAAK,KAAK,IAAI,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C;EAAG,SAAS,CAAC;CAAE;AAClE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/vec2.ts","../src/ndvector.ts","../src/scalars.ts","../src/color.ts","../src/angle.ts","../src/wrappers.ts"],"sourcesContent":["import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\n\n/**\n * An immutable 2D vector. The methods live on the prototype, so a vector costs two numbers. Division is real\n * division: a division by zero gives an infinite component, and the domain check turns it into `#NUM!`.\n */\nexport class Vec2 {\n readonly x: number;\n readonly y: number;\n\n constructor(x: number, y: number) {\n this.x = x;\n this.y = y;\n }\n\n /** This function makes a vector. */\n static of(x: number, y: number): Vec2 {\n return new Vec2(x, y);\n }\n /** This function makes a vector with the same value in both components. */\n static scalar(n: number): Vec2 {\n return new Vec2(n, n);\n }\n /** The zero vector. */\n static readonly zero: Vec2 = new Vec2(0, 0);\n /** The vector of ones. */\n static readonly one: Vec2 = new Vec2(1, 1);\n\n add(o: Vec2): Vec2 {\n return new Vec2(this.x + o.x, this.y + o.y);\n }\n subtract(o: Vec2): Vec2 {\n return new Vec2(this.x - o.x, this.y - o.y);\n }\n /** The component-wise product. */\n multiply(o: Vec2): Vec2 {\n return new Vec2(this.x * o.x, this.y * o.y);\n }\n /** The component-wise quotient. A zero component of `o` gives an infinite component. */\n divide(o: Vec2): Vec2 {\n return new Vec2(this.x / o.x, this.y / o.y);\n }\n /** The component-wise minimum. */\n min(o: Vec2): Vec2 {\n return new Vec2(Math.min(this.x, o.x), Math.min(this.y, o.y));\n }\n /** The component-wise maximum. */\n max(o: Vec2): Vec2 {\n return new Vec2(Math.max(this.x, o.x), Math.max(this.y, o.y));\n }\n scale(k: number): Vec2 {\n return new Vec2(this.x * k, this.y * k);\n }\n negate(): Vec2 {\n return new Vec2(-this.x, -this.y);\n }\n halve(): Vec2 {\n return this.scale(0.5);\n }\n abs(): Vec2 {\n return new Vec2(Math.abs(this.x), Math.abs(this.y));\n }\n round(): Vec2 {\n return new Vec2(Math.round(this.x), Math.round(this.y));\n }\n floor(): Vec2 {\n return new Vec2(Math.floor(this.x), Math.floor(this.y));\n }\n ceil(): Vec2 {\n return new Vec2(Math.ceil(this.x), Math.ceil(this.y));\n }\n clamp(lo: number, hi: number): Vec2 {\n return new Vec2(Math.min(hi, Math.max(lo, this.x)), Math.min(hi, Math.max(lo, this.y)));\n }\n swap(): Vec2 {\n return new Vec2(this.y, this.x);\n }\n /** The vector turned by `radians`, counterclockwise. */\n rotate(radians: number): Vec2 {\n const c = Math.cos(radians);\n const s = Math.sin(radians);\n return new Vec2(c * this.x - s * this.y, s * this.x + c * this.y);\n }\n /** The vector with length 1. The zero vector stays zero. */\n normalize(): Vec2 {\n const len = this.length();\n return len === 0 ? this : this.scale(1 / len);\n }\n /** The linear interpolation from this vector to `o`. */\n lerp(o: Vec2, t: number): Vec2 {\n return new Vec2(this.x + (o.x - this.x) * t, this.y + (o.y - this.y) * t);\n }\n length(): number {\n return Math.hypot(this.x, this.y);\n }\n lengthSq(): number {\n return this.x * this.x + this.y * this.y;\n }\n distance(o: Vec2): number {\n return Math.hypot(this.x - o.x, this.y - o.y);\n }\n dot(o: Vec2): number {\n return this.x * o.x + this.y * o.y;\n }\n /** The z component of the 3D cross product. */\n cross(o: Vec2): number {\n return this.x * o.y - this.y * o.x;\n }\n /** The angle of the vector, in radians, from the x axis. */\n angle(): number {\n return Math.atan2(this.y, this.x);\n }\n /** The product of the components: the area of a size vector. */\n area(): number {\n return this.x * this.y;\n }\n /** The sum of the components. */\n sum(): number {\n return this.x + this.y;\n }\n minComponent(): number {\n return Math.min(this.x, this.y);\n }\n maxComponent(): number {\n return Math.max(this.x, this.y);\n }\n equals(o: Vec2): boolean {\n return this.x === o.x && this.y === o.y;\n }\n anyNonPositive(): boolean {\n return this.x <= 0 || this.y <= 0;\n }\n allPositive(): boolean {\n return this.x > 0 && this.y > 0;\n }\n anyNegative(): boolean {\n return this.x < 0 || this.y < 0;\n }\n allNonNegative(): boolean {\n return this.x >= 0 && this.y >= 0;\n }\n anyZero(): boolean {\n return this.x === 0 || this.y === 0;\n }\n allZero(): boolean {\n return this.x === 0 && this.y === 0;\n }\n anyLessThan(n: number): boolean {\n return this.x < n || this.y < n;\n }\n allLessThan(n: number): boolean {\n return this.x < n && this.y < n;\n }\n anyGreaterThan(n: number): boolean {\n return this.x > n || this.y > n;\n }\n allGreaterThan(n: number): boolean {\n return this.x > n && this.y > n;\n }\n toJSON(): { readonly x: number; readonly y: number } {\n return { x: this.x, y: this.y };\n }\n toString(): string {\n return `(${this.x}, ${this.y})`;\n }\n}\n\ntype Vec2OpNames =\n | \"add\" | \"subtract\" | \"multiply\" | \"divide\" | \"min\" | \"max\" | \"scale\" | \"negate\" | \"halve\" | \"abs\" | \"round\" | \"floor\"\n | \"ceil\" | \"clamp\" | \"swap\" | \"rotate\" | \"normalize\" | \"lerp\" | \"length\" | \"lengthSq\" | \"distance\" | \"dot\" | \"cross\"\n | \"angle\" | \"area\" | \"sum\" | \"minComponent\" | \"maxComponent\" | \"equals\" | \"anyNonPositive\" | \"allPositive\"\n | \"anyNegative\" | \"allNonNegative\" | \"anyZero\" | \"allZero\" | \"anyLessThan\" | \"allLessThan\" | \"anyGreaterThan\"\n | \"allGreaterThan\";\n\n/** The ops of `Vec2Domain`. */\nexport type Vec2Ops = OpTable<Vec2, Vec2OpNames, \"add\" | \"subtract\" | \"multiply\" | \"divide\" | \"min\" | \"max\">;\n\n/** The domain of 2D vectors. A number argument of a component-wise op lifts to a vector with that value twice. */\nexport const Vec2Domain: Domain<\"Vec2\", Vec2, Vec2Ops> = defineDomain<\"Vec2\", Vec2, Vec2Ops>({\n name: \"Vec2\",\n is: (u: unknown): u is Vec2 => u instanceof Vec2,\n fromScalar: (n: number): Vec2 => Vec2.scalar(n),\n valid: (v: Vec2): boolean => Number.isFinite(v.x) && Number.isFinite(v.y),\n show: (v: Vec2): string => v.toString(),\n encode: (v: Vec2): readonly [number, number] => [v.x, v.y],\n decode: (u: unknown): Vec2 => {\n const [x, y] = Array.isArray(u) ? (u as readonly unknown[]) : [];\n return new Vec2(typeof x === \"number\" ? x : Number.NaN, typeof y === \"number\" ? y : Number.NaN);\n },\n ops: {\n add: { laws: [\"commutative\", \"associative\"], identity: () => Vec2.zero, liftScalar: true, params: [\"domain\"] },\n subtract: { liftScalar: true, params: [\"domain\"] },\n multiply: { laws: [\"commutative\", \"associative\"], identity: () => Vec2.one, liftScalar: true, params: [\"domain\"] },\n divide: { liftScalar: true, params: [\"domain\"] },\n min: { laws: [\"commutative\", \"associative\", \"idempotent\"], liftScalar: true, params: [\"domain\"] },\n max: { laws: [\"commutative\", \"associative\", \"idempotent\"], liftScalar: true, params: [\"domain\"] },\n scale: { params: [\"number\"] },\n negate: {},\n halve: {},\n abs: {},\n round: {},\n floor: {},\n ceil: {},\n clamp: { params: [\"number\", \"number\"] },\n swap: {},\n rotate: { params: [\"number\"] },\n normalize: {},\n lerp: { params: [\"domain\", \"number\"] },\n length: {},\n lengthSq: {},\n distance: { params: [\"domain\"] },\n dot: { laws: [\"commutative\"], params: [\"domain\"] },\n cross: { params: [\"domain\"] },\n angle: {},\n area: {},\n sum: {},\n minComponent: {},\n maxComponent: {},\n equals: { laws: [\"commutative\"], params: [\"domain\"] },\n anyNonPositive: {},\n allPositive: {},\n anyNegative: {},\n allNonNegative: {},\n anyZero: {},\n allZero: {},\n anyLessThan: { params: [\"number\"] },\n allLessThan: { params: [\"number\"] },\n anyGreaterThan: { params: [\"number\"] },\n allGreaterThan: { params: [\"number\"] },\n },\n});\n","import { defineDomain, type Domain, type FnOp, type OpTable } from \"@mark1russell7/vex\";\n\n/**\n * An immutable vector with named components. The type parameter `K` is the set of component names. Ops that\n * combine two vectors use the union of their names, and a missing component counts as 0. The constructor\n * keeps each number, also a number that is not finite: the domain check reports such a value as `#NUM!`.\n */\nexport class NDVector<K extends string = string> {\n /** The components: name to number. */\n readonly c: Readonly<Record<K, number>>;\n\n constructor(c: Readonly<Record<K, number>>) {\n this.c = Object.freeze({ ...c });\n }\n\n /** This function makes a vector from name and value pairs. */\n static of<K extends string>(entries: readonly (readonly [K, number])[]): NDVector<K> {\n const c = {} as Record<K, number>;\n for (const [k, v] of entries) c[k] = v;\n return new NDVector(c);\n }\n /** This function makes the zero vector over the names `keys`. */\n static zero<K extends string>(keys: readonly K[] = []): NDVector<K> {\n return NDVector.of(keys.map((k) => [k, 0] as const));\n }\n\n /** The names of the components. */\n keys(): readonly K[] {\n return Object.keys(this.c) as K[];\n }\n /** The value of a component, or 0 if the vector does not have it. */\n get(k: string): number {\n return Object.hasOwn(this.c, k) ? Number((this.c as Readonly<Record<string, number>>)[k]) : 0;\n }\n set<K2 extends string>(k: K2, v: number): NDVector<K | K2> {\n return new NDVector({ ...this.c, [k]: v } as Record<K | K2, number>);\n }\n map(f: (name: K, v: number) => number): NDVector<K> {\n const c = {} as Record<K, number>;\n for (const k of this.keys()) c[k] = f(k, this.get(k));\n return new NDVector(c);\n }\n /** The vector with only the names in `keys`. A zero component is dropped, unless `keepZeros` is true. */\n pick<K2 extends K>(keys: readonly K2[], keepZeros = false): NDVector<K2> {\n const c = {} as Record<K2, number>;\n for (const k of keys) {\n const v = this.get(k);\n if (keepZeros || v !== 0) c[k] = v;\n }\n return new NDVector(c);\n }\n /** The vector with the names in `keys` added. A new component is 0. */\n withKeys<K2 extends string>(keys: readonly K2[]): NDVector<K | K2> {\n const c = { ...this.c } as Record<K | K2, number>;\n for (const k of keys) if (!Object.hasOwn(c, k)) c[k] = 0;\n return new NDVector(c);\n }\n #combine<K2 extends string>(o: NDVector<K2>, f: (a: number, b: number) => number): NDVector<K | K2> {\n const c = {} as Record<K | K2, number>;\n for (const k of new Set<K | K2>([...this.keys(), ...o.keys()])) c[k] = f(this.get(k), o.get(k));\n return new NDVector(c);\n }\n add<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => a + b);\n }\n subtract<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => a - b);\n }\n /** The component-wise product. */\n multiply<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => a * b);\n }\n /** Of each component, the value of this vector if it is not 0, else the value of `o`. */\n mergePreferNonZero<K2 extends string>(o: NDVector<K2>): NDVector<K | K2> {\n return this.#combine(o, (a, b) => (a !== 0 ? a : b));\n }\n scale(k: number): NDVector<K> {\n return this.map((_n, v) => v * k);\n }\n clamp(lo: number, hi: number): NDVector<K> {\n return this.map((_n, v) => Math.min(hi, Math.max(lo, v)));\n }\n dot(o: NDVector): number {\n let s = 0;\n for (const k of new Set<string>([...this.keys(), ...o.keys()])) s += this.get(k) * o.get(k);\n return s;\n }\n /** The L2 length. */\n length(): number {\n return Math.sqrt(this.keys().reduce((s, k) => s + this.get(k) ** 2, 0));\n }\n /** The L1 norm. */\n norm1(): number {\n return this.keys().reduce((s, k) => s + Math.abs(this.get(k)), 0);\n }\n /** The largest absolute component. */\n normInf(): number {\n return this.keys().reduce((m, k) => Math.max(m, Math.abs(this.get(k))), 0);\n }\n equals(o: NDVector): boolean {\n const keys = new Set<string>([...this.keys(), ...o.keys()]);\n for (const k of keys) if (this.get(k) !== o.get(k)) return false;\n return true;\n }\n /** True if each component is a finite number. */\n isFinite(): boolean {\n return this.keys().every((k) => Number.isFinite(this.get(k)));\n }\n toJSON(): Readonly<Record<K, number>> {\n return { ...this.c };\n }\n toString(): string {\n return `NDVector(${JSON.stringify(this.c)})`;\n }\n}\n\ntype NDOpNames =\n | \"add\" | \"subtract\" | \"multiply\" | \"mergePreferNonZero\" | \"scale\" | \"clamp\" | \"dot\" | \"length\" | \"norm1\" | \"normInf\"\n | \"equals\" | \"pick\" | \"withKeys\" | \"get\" | \"set\";\n\n/** The ops of `NDVectorDomain`. No op lifts numbers. */\nexport type NDVectorOps = OpTable<NDVector, NDOpNames>;\n\n/** The ops of `LiftedNDVectorDomain`. */\nexport type LiftedNDVectorOps = OpTable<NDVector, NDOpNames, \"add\" | \"subtract\" | \"multiply\" | \"dot\">;\n\nconst ndOps = {\n add: { laws: [\"commutative\", \"associative\"], identity: (): NDVector => NDVector.zero(), params: [\"domain\"] },\n subtract: { params: [\"domain\"] },\n multiply: { laws: [\"commutative\", \"associative\"], params: [\"domain\"] },\n mergePreferNonZero: { laws: [\"associative\", \"idempotent\"], params: [\"domain\"] },\n scale: { params: [\"number\"] },\n clamp: { params: [\"number\", \"number\"] },\n dot: { laws: [\"commutative\"], params: [\"domain\"] },\n length: {},\n norm1: {},\n normInf: {},\n equals: { laws: [\"commutative\"], params: [\"domain\"] },\n pick: {},\n withKeys: {},\n get: { params: [\"string\"] },\n set: { params: [\"string\", \"number\"] },\n} as const satisfies NDVectorOps;\n\nconst isNDVector = (u: unknown): u is NDVector => u instanceof NDVector;\n\n/** The domain of named-component vectors. A number argument is an error here: use `LiftedNDVectorDomain` to lift. */\nexport const NDVectorDomain: Domain<\"NDVector\", NDVector, NDVectorOps> = defineDomain<\"NDVector\", NDVector, NDVectorOps>({\n name: \"NDVector\",\n is: isNDVector,\n valid: (v: NDVector): boolean => v.isFinite(),\n show: (v: NDVector): string => v.toString(),\n encode: (v: NDVector): unknown => v.toJSON(),\n decode: (u: unknown): NDVector => new NDVector(u as Readonly<Record<string, number>>),\n ops: ndOps,\n});\n\n/**\n * The domain of named-component vectors with scalar lifting. A number argument of `add`, `subtract`,\n * `multiply` or `dot` becomes the vector `{ scalar: n }`. This domain is independent of `NDVectorDomain`:\n * the two can be in one program, and neither changes the other.\n */\nexport const LiftedNDVectorDomain: Domain<\"NDVector(lifted)\", NDVector, LiftedNDVectorOps> = defineDomain<\"NDVector(lifted)\", NDVector, LiftedNDVectorOps>({\n name: \"NDVector(lifted)\",\n is: isNDVector,\n fromScalar: (n: number): NDVector => new NDVector({ scalar: n }),\n valid: (v: NDVector): boolean => v.isFinite(),\n show: (v: NDVector): string => v.toString(),\n ops: {\n ...ndOps,\n add: { ...ndOps.add, liftScalar: true },\n subtract: { ...ndOps.subtract, liftScalar: true },\n multiply: { ...ndOps.multiply, liftScalar: true },\n dot: { ...ndOps.dot, liftScalar: true },\n },\n});\n\n/** A plain record whose values are finite numbers. */\nexport type NumRecord = Readonly<Record<string, number>>;\n\n/** The ops of `NumRecordDomain`. */\nexport type NumRecordOps = {\n readonly toNDVector: FnOp<NumRecord, (r: NumRecord) => NDVector>;\n};\n\nconst isNumRecord = (u: unknown): u is NumRecord => {\n if (typeof u !== \"object\" || u === null || Array.isArray(u)) return false;\n const proto: unknown = Object.getPrototypeOf(u);\n return (proto === Object.prototype || proto === null) && Object.values(u).every((v) => typeof v === \"number\" && Number.isFinite(v));\n};\n\n/** The domain of plain number records. Its op `toNDVector` builds a vector from fields, for example from `rec()`. */\nexport const NumRecordDomain: Domain<\"NumRecord\", NumRecord, NumRecordOps> = defineDomain<\"NumRecord\", NumRecord, NumRecordOps>({\n name: \"NumRecord\",\n is: isNumRecord,\n ops: {\n toNDVector: { fn: (r: NumRecord): NDVector => new NDVector(r) },\n },\n});\n","import { defineDomain, type Domain, type FnOp } from \"@mark1russell7/vex\";\n\ntype NumFn1 = (a: number) => number;\ntype NumFn2 = (a: number, b: number) => number;\ntype NumFn3 = (a: number, b: number, c: number) => number;\ntype NumTest = (a: number, b: number) => boolean;\n\n/** The ops of `NumDomain`. */\nexport type NumOps = {\n readonly add: FnOp<number, NumFn2>;\n readonly subtract: FnOp<number, NumFn2>;\n readonly multiply: FnOp<number, NumFn2>;\n readonly divide: FnOp<number, NumFn2>;\n readonly mod: FnOp<number, NumFn2>;\n readonly pow: FnOp<number, NumFn2>;\n readonly min: FnOp<number, NumFn2>;\n readonly max: FnOp<number, NumFn2>;\n readonly clamp: FnOp<number, NumFn3>;\n readonly abs: FnOp<number, NumFn1>;\n readonly negate: FnOp<number, NumFn1>;\n readonly sqrt: FnOp<number, NumFn1>;\n readonly floor: FnOp<number, NumFn1>;\n readonly ceil: FnOp<number, NumFn1>;\n readonly round: FnOp<number, NumFn1>;\n readonly gt: FnOp<number, NumTest>;\n readonly gte: FnOp<number, NumTest>;\n readonly lt: FnOp<number, NumTest>;\n readonly lte: FnOp<number, NumTest>;\n readonly eq: FnOp<number, NumTest>;\n};\n\n/** The domain of numbers. A result that is not a finite number is the error `#NUM!`. */\nexport const NumDomain: Domain<\"Num\", number, NumOps> = defineDomain<\"Num\", number, NumOps>({\n name: \"Num\",\n is: (u: unknown): u is number => typeof u === \"number\",\n valid: (n: number): boolean => Number.isFinite(n),\n show: (n: number): string => String(n),\n ops: {\n add: { fn: (a: number, b: number): number => a + b, laws: [\"commutative\", \"associative\"], identity: (): number => 0, params: [\"number\"] },\n subtract: { fn: (a: number, b: number): number => a - b, params: [\"number\"] },\n multiply: { fn: (a: number, b: number): number => a * b, laws: [\"commutative\", \"associative\"], identity: (): number => 1, params: [\"number\"] },\n divide: { fn: (a: number, b: number): number => a / b, params: [\"number\"] },\n mod: { fn: (a: number, b: number): number => a % b, params: [\"number\"] },\n pow: { fn: (a: number, b: number): number => a ** b, params: [\"number\"] },\n min: { fn: (a: number, b: number): number => Math.min(a, b), laws: [\"commutative\", \"associative\", \"idempotent\"], params: [\"number\"] },\n max: { fn: (a: number, b: number): number => Math.max(a, b), laws: [\"commutative\", \"associative\", \"idempotent\"], params: [\"number\"] },\n clamp: { fn: (a: number, lo: number, hi: number): number => Math.min(hi, Math.max(lo, a)), params: [\"number\", \"number\"] },\n abs: { fn: (a: number): number => Math.abs(a) },\n negate: { fn: (a: number): number => -a },\n sqrt: { fn: (a: number): number => Math.sqrt(a) },\n floor: { fn: (a: number): number => Math.floor(a) },\n ceil: { fn: (a: number): number => Math.ceil(a) },\n round: { fn: (a: number): number => Math.round(a) },\n gt: { fn: (a: number, b: number): boolean => a > b, params: [\"number\"] },\n gte: { fn: (a: number, b: number): boolean => a >= b, params: [\"number\"] },\n lt: { fn: (a: number, b: number): boolean => a < b, params: [\"number\"] },\n lte: { fn: (a: number, b: number): boolean => a <= b, params: [\"number\"] },\n eq: { fn: (a: number, b: number): boolean => a === b, laws: [\"commutative\"], params: [\"number\"] },\n },\n});\n\ntype BoolFn1 = (a: boolean) => boolean;\ntype BoolFn2 = (a: boolean, b: boolean) => boolean;\n\n/** The ops of `BoolDomain`. */\nexport type BoolOps = {\n readonly and: FnOp<boolean, BoolFn2>;\n readonly or: FnOp<boolean, BoolFn2>;\n readonly xor: FnOp<boolean, BoolFn2>;\n readonly not: FnOp<boolean, BoolFn1>;\n readonly eq: FnOp<boolean, BoolFn2>;\n};\n\n/** The domain of booleans. For lazy logic, use the special forms `and`, `or` and `if` of the IR. */\nexport const BoolDomain: Domain<\"Bool\", boolean, BoolOps> = defineDomain<\"Bool\", boolean, BoolOps>({\n name: \"Bool\",\n is: (u: unknown): u is boolean => typeof u === \"boolean\",\n show: (b: boolean): string => String(b),\n ops: {\n and: { fn: (a: boolean, b: boolean): boolean => a && b, laws: [\"commutative\", \"associative\", \"idempotent\"], identity: (): boolean => true, params: [\"boolean\"] },\n or: { fn: (a: boolean, b: boolean): boolean => a || b, laws: [\"commutative\", \"associative\", \"idempotent\"], identity: (): boolean => false, params: [\"boolean\"] },\n xor: { fn: (a: boolean, b: boolean): boolean => a !== b, laws: [\"commutative\", \"associative\"], identity: (): boolean => false, params: [\"boolean\"] },\n not: { fn: (a: boolean): boolean => !a },\n eq: { fn: (a: boolean, b: boolean): boolean => a === b, laws: [\"commutative\"], params: [\"boolean\"] },\n },\n});\n","import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\n\n/**\n * An immutable RGBA color. The channels have no fixed range: use `clamp` to limit them. `add` adds the color\n * channels and keeps the larger alpha, so `add` is commutative and associative.\n */\nexport class Color {\n readonly r: number;\n readonly g: number;\n readonly b: number;\n readonly a: number;\n\n constructor(r: number, g: number, b: number, a = 1) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = a;\n }\n\n /** This function makes a gray color with the value `n` in each channel. */\n static gray(n: number): Color {\n return new Color(n, n, n, 1);\n }\n /** The black color with alpha 0: the identity of `add`. */\n static readonly none: Color = new Color(0, 0, 0, 0);\n\n /** The channel sum. The alpha is the larger alpha. */\n add(o: Color): Color {\n return new Color(this.r + o.r, this.g + o.g, this.b + o.b, Math.max(this.a, o.a));\n }\n /** Each color channel times `factor`. The alpha does not change. */\n multiply(factor: number): Color {\n return new Color(this.r * factor, this.g * factor, this.b * factor, this.a);\n }\n /** Each color channel in the range from `lo` to `hi`. */\n clamp(lo = 0, hi = 255): Color {\n const c = (x: number): number => Math.min(hi, Math.max(lo, x));\n return new Color(c(this.r), c(this.g), c(this.b), this.a);\n }\n /** The linear mix from this color to `o`. */\n mix(o: Color, t: number): Color {\n const m = (x: number, y: number): number => x + (y - x) * t;\n return new Color(m(this.r, o.r), m(this.g, o.g), m(this.b, o.b), m(this.a, o.a));\n }\n /** The relative luminance (Rec. 709 weights) of the color channels. */\n luminance(): number {\n return 0.2126 * this.r + 0.7152 * this.g + 0.0722 * this.b;\n }\n equals(o: Color): boolean {\n return this.r === o.r && this.g === o.g && this.b === o.b && this.a === o.a;\n }\n toArray(): readonly [number, number, number, number] {\n return [this.r, this.g, this.b, this.a];\n }\n toString(): string {\n return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`;\n }\n}\n\n/** The ops of `ColorDomain`. */\nexport type ColorOps = OpTable<Color, \"add\" | \"multiply\" | \"clamp\" | \"mix\" | \"luminance\" | \"equals\">;\n\n/** The domain of colors. */\nexport const ColorDomain: Domain<\"Color\", Color, ColorOps> = defineDomain<\"Color\", Color, ColorOps>({\n name: \"Color\",\n is: (u: unknown): u is Color => u instanceof Color,\n fromScalar: (n: number): Color => Color.gray(n),\n valid: (c: Color): boolean => c.toArray().every((x) => Number.isFinite(x)),\n show: (c: Color): string => c.toString(),\n encode: (c: Color): readonly number[] => c.toArray(),\n decode: (u: unknown): Color => {\n const [r, g, b, a] = (Array.isArray(u) ? u : []) as readonly number[];\n return new Color(r ?? Number.NaN, g ?? Number.NaN, b ?? Number.NaN, a ?? 1);\n },\n ops: {\n add: { laws: [\"commutative\", \"associative\"], identity: (): Color => Color.none, params: [\"domain\"] },\n multiply: { params: [\"number\"] },\n clamp: { params: [\"number\", \"number\"] },\n mix: { params: [\"domain\", \"number\"] },\n luminance: {},\n equals: { laws: [\"commutative\"], params: [\"domain\"] },\n },\n});\n","import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\nimport { Vec2 } from \"./vec2.ts\";\n\n/** An immutable angle in radians. */\nexport class Angle {\n readonly radians: number;\n\n constructor(radians: number) {\n this.radians = radians;\n }\n\n /** This function makes an angle from degrees. */\n static fromDegrees(deg: number): Angle {\n return new Angle((deg * Math.PI) / 180);\n }\n /** The zero angle: the identity of `add`. */\n static readonly zero: Angle = new Angle(0);\n\n add(o: Angle): Angle {\n return new Angle(this.radians + o.radians);\n }\n subtract(o: Angle): Angle {\n return new Angle(this.radians - o.radians);\n }\n scale(k: number): Angle {\n return new Angle(this.radians * k);\n }\n /** The same angle in the range from -π (included) to π (not included). */\n normalize(): Angle {\n const twoPi = Math.PI * 2;\n return new Angle((((this.radians + Math.PI) % twoPi) + twoPi) % twoPi - Math.PI);\n }\n /** The vector with this angle and the length `length`. The result is a `Vec2`, so a chain continues in that domain. */\n toVec2(length = 1): Vec2 {\n return new Vec2(Math.cos(this.radians) * length, Math.sin(this.radians) * length);\n }\n sin(): number {\n return Math.sin(this.radians);\n }\n cos(): number {\n return Math.cos(this.radians);\n }\n degrees(): number {\n return (this.radians * 180) / Math.PI;\n }\n toString(): string {\n return `${this.radians} rad`;\n }\n}\n\n/** The ops of `AngleDomain`. */\nexport type AngleOps = OpTable<Angle, \"add\" | \"subtract\" | \"scale\" | \"normalize\" | \"toVec2\" | \"sin\" | \"cos\" | \"degrees\", \"add\" | \"subtract\">;\n\n/** The domain of angles. A number argument of `add` or `subtract` lifts to an angle in radians. */\nexport const AngleDomain: Domain<\"Angle\", Angle, AngleOps> = defineDomain<\"Angle\", Angle, AngleOps>({\n name: \"Angle\",\n is: (u: unknown): u is Angle => u instanceof Angle,\n fromScalar: (n: number): Angle => new Angle(n),\n valid: (a: Angle): boolean => Number.isFinite(a.radians),\n show: (a: Angle): string => a.toString(),\n encode: (a: Angle): number => a.radians,\n decode: (u: unknown): Angle => new Angle(typeof u === \"number\" ? u : Number.NaN),\n ops: {\n add: { laws: [\"commutative\", \"associative\"], identity: (): Angle => Angle.zero, liftScalar: true, params: [\"domain\"] },\n subtract: { liftScalar: true, params: [\"domain\"] },\n scale: { params: [\"number\"] },\n normalize: {},\n toVec2: { params: [\"number\"] },\n sin: {},\n cos: {},\n degrees: {},\n },\n});\n","import { defineDomain, type Domain, type OpTable } from \"@mark1russell7/vex\";\n\n/** A wrapper around a function. Its op `invoke` calls the function. It shows how a domain can hold behavior. */\nexport class Fn {\n readonly fn: (...args: never[]) => unknown;\n\n constructor(fn: (...args: never[]) => unknown) {\n this.fn = fn;\n }\n invoke(...args: readonly unknown[]): unknown {\n return (this.fn as (...a: readonly unknown[]) => unknown)(...args);\n }\n}\n\n/** The ops of `FnDomain`. */\nexport type FnOps = OpTable<Fn, \"invoke\">;\n\n/** The domain of function wrappers. */\nexport const FnDomain: Domain<\"Fn\", Fn, FnOps> = defineDomain<\"Fn\", Fn, FnOps>({\n name: \"Fn\",\n is: (u: unknown): u is Fn => u instanceof Fn,\n ops: { invoke: {} },\n});\n\n/**\n * A value that is there (`top`) or not there (`bottom`). It shows a domain whose ops take functions. A Vex\n * program can also hold this state in its own errors, so most programs do not need this domain.\n */\nexport class Maybe<T> {\n readonly #has: boolean;\n readonly #value: T | undefined;\n\n private constructor(has: boolean, value: T | undefined) {\n this.#has = has;\n this.#value = value;\n }\n static top<T>(value: T): Maybe<T> {\n return new Maybe<T>(true, value);\n }\n static bottom<T = never>(): Maybe<T> {\n return new Maybe<T>(false, undefined);\n }\n isTop(): boolean {\n return this.#has;\n }\n isBottom(): boolean {\n return !this.#has;\n }\n map<U>(f: (value: T) => U): Maybe<U> {\n return this.#has ? Maybe.top(f(this.#value as T)) : Maybe.bottom<U>();\n }\n chain<U>(f: (value: T) => Maybe<U>): Maybe<U> {\n return this.#has ? f(this.#value as T) : Maybe.bottom<U>();\n }\n valueOr<U>(fallback: U): T | U {\n return this.#has ? (this.#value as T) : fallback;\n }\n}\n\n/** The ops of `MaybeDomain`. */\nexport type MaybeOps = OpTable<Maybe<unknown>, \"isTop\" | \"isBottom\" | \"map\" | \"chain\" | \"valueOr\">;\n\n/** The domain of `Maybe` values. */\nexport const MaybeDomain: Domain<\"Maybe\", Maybe<unknown>, MaybeOps> = defineDomain<\"Maybe\", Maybe<unknown>, MaybeOps>({\n name: \"Maybe\",\n is: (u: unknown): u is Maybe<unknown> => u instanceof Maybe,\n ops: { isTop: {}, isBottom: {}, map: {}, chain: {}, valueOr: {} },\n});\n"],"mappings":";;;;;;AAMA,IAAa,OAAb,MAAa,KAAK;CAChB;CACA;CAEA,YAAY,GAAW,GAAW;EAChC,KAAK,IAAI;EACT,KAAK,IAAI;CACX;;CAGA,OAAO,GAAG,GAAW,GAAiB;EACpC,OAAO,IAAI,KAAK,GAAG,CAAC;CACtB;;CAEA,OAAO,OAAO,GAAiB;EAC7B,OAAO,IAAI,KAAK,GAAG,CAAC;CACtB;;CAEA,OAAgB,OAAa,IAAI,KAAK,GAAG,CAAC;;CAE1C,OAAgB,MAAY,IAAI,KAAK,GAAG,CAAC;CAEzC,IAAI,GAAe;EACjB,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;CAC5C;CACA,SAAS,GAAe;EACtB,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;CAC5C;;CAEA,SAAS,GAAe;EACtB,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;CAC5C;;CAEA,OAAO,GAAe;EACpB,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;CAC5C;;CAEA,IAAI,G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CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/vex-domains",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Vex domains: 2D vectors, named-component vectors, colors, angles, numbers and booleans.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"vex",
|
|
8
|
+
"vector",
|
|
9
|
+
"vec2",
|
|
10
|
+
"color",
|
|
11
|
+
"angle",
|
|
12
|
+
"domain",
|
|
13
|
+
"typescript"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://mark1russell7.github.io/vex/",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/mark1russell7/vex/issues"
|
|
18
|
+
},
|
|
19
|
+
"author": "Mark Russell (https://github.com/mark1russell7)",
|
|
6
20
|
"license": "MIT",
|
|
7
21
|
"repository": {
|
|
8
22
|
"type": "git",
|
|
@@ -37,7 +51,7 @@
|
|
|
37
51
|
"vitest": "^5.0.3"
|
|
38
52
|
},
|
|
39
53
|
"dependencies": {
|
|
40
|
-
"@mark1russell7/vex": "0.
|
|
54
|
+
"@mark1russell7/vex": "0.3.0"
|
|
41
55
|
},
|
|
42
56
|
"scripts": {
|
|
43
57
|
"build": "tsdown",
|
package/src/ndvector.ts
CHANGED
|
@@ -30,7 +30,7 @@ export class NDVector<K extends string = string> {
|
|
|
30
30
|
}
|
|
31
31
|
/** The value of a component, or 0 if the vector does not have it. */
|
|
32
32
|
get(k: string): number {
|
|
33
|
-
return Object.hasOwn(this.c, k) ? (this.c as Readonly<Record<string, number>>)[k]
|
|
33
|
+
return Object.hasOwn(this.c, k) ? Number((this.c as Readonly<Record<string, number>>)[k]) : 0;
|
|
34
34
|
}
|
|
35
35
|
set<K2 extends string>(k: K2, v: number): NDVector<K | K2> {
|
|
36
36
|
return new NDVector({ ...this.c, [k]: v } as Record<K | K2, number>);
|