@mark1russell7/vex 0.0.0-stage → 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 ADDED
@@ -0,0 +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.
package/README.md CHANGED
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # @mark1russell7/vex
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@mark1russell7/vex)](https://www.npmjs.com/package/@mark1russell7/vex) [![CI](https://github.com/mark1russell7/vex/actions/workflows/ci.yml/badge.svg)](https://github.com/mark1russell7/vex/actions/workflows/ci.yml) [![license](https://img.shields.io/npm/l/@mark1russell7/vex)](https://github.com/mark1russell7/vex/blob/main/LICENSE)
4
+
5
+ Typed spreadsheet formulas over TypeScript objects. A Vex program evaluates at one record of a collection. It reads fields relative to that record, and combines them with the ops of domains, for example 2D vectors. A failure does not throw: it is an error value with a code like `#REF!` or `#N/A`, and a trace shows where it started.
6
+
7
+ **[Documentation, live examples and the Lab](https://mark1russell7.github.io/vex/)**
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install @mark1russell7/vex @mark1russell7/vex-domains
13
+ ```
14
+
15
+ ## Example
16
+
17
+ The distance from each box to the nearest other box:
18
+
19
+ ```ts doctest
20
+ import { space, vex } from "@mark1russell7/vex";
21
+ import { NumDomain, Vec2, Vec2Domain } from "@mark1russell7/vex-domains";
22
+
23
+ const boxes = space.record({
24
+ A: { position: new Vec2(0, 0) },
25
+ B: { position: new Vec2(3, 4) },
26
+ C: { position: new Vec2(6, 8) },
27
+ });
28
+ const root = vex(Vec2Domain, NumDomain).over(boxes);
29
+ const nearest = root.from("position").others((e) => e._.distance("position")).min();
30
+
31
+ nearest.at("A"); // => { tag: "some", value: 5 }
32
+ nearest.all().values(); // => [5, 5, 5]
33
+ nearest.at("A"); // : Optional<number>
34
+ ```
35
+
36
+ The types know the fields of the records and the ops of each domain. `root.from("mass")` and `._.explode()` do not compile.
37
+
38
+ ## Features
39
+
40
+ - **Axes.** `others`, `each`, `neighbors` in a grid, and `children`, `ancestors`, `descendants` and `siblings` in a tree. A `where` test filters the targets.
41
+ - **Sheets.** Named columns of formulas that read each other, like the columns of a spreadsheet. A cycle of reads gives `#CYCLE!`.
42
+ - **Error values.** Each failure has a code, a kind, a message, the path of its node, the origin and the focus. `ifError` catches an error.
43
+ - **Programs are data.** A program is a JSON tree. `explain` gives a trace, `deps` gives the reads, and `compile` gives a program that evaluates at each record of each space.
44
+ - **No runtime dependencies.** The package is one ES module with its type declarations.
45
+
46
+ ## Related packages
47
+
48
+ - [`@mark1russell7/vex-domains`](https://www.npmjs.com/package/@mark1russell7/vex-domains): 2D vectors, colors, angles, numbers and booleans
49
+ - [`@mark1russell7/vex-testkit`](https://www.npmjs.com/package/@mark1russell7/vex-testkit): property tests for the laws of your domains
50
+
51
+ ## License
52
+
53
+ MIT