venerate 0.0.0 → 0.0.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/README.md CHANGED
@@ -1,55 +1,29 @@
1
- # treetrunks
1
+ # venerate
2
2
 
3
- <a aria-label="NPM version" href="https://www.npmjs.com/package/treetrunks">
3
+ <a aria-label="NPM version" href="https://www.npmjs.com/package/venerate">
4
4
  <img alt="NPM Version" src="https://img.shields.io/npm/v/treetrunks?style=for-the-badge">
5
5
  </a>
6
6
  <a aria-label="Dependencies 0" href="https://www.npmjs.com/package/treetrunks">
7
7
  <img alt="Dependencies 0" src=" https://img.shields.io/badge/dependencies-0-0?style=for-the-badge">
8
8
  </a>
9
- <a href="https://bundlephobia.com/result?p=treetrunks">
10
- <img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/treetrunks?style=for-the-badge">
11
- </a>
12
- <a aria-label="Coverage" href="https://recoverage.cloud/">
13
- <img alt="Coverage" src="https://img.shields.io/endpoint?url=https%3A%2F%2Frecoverage.cloud%2Fshields%2FS1ikz1yFmk93qbAI7lLnu%2Ftreetrunks">
9
+ <a href="https://bundlephobia.com/result?p=venerate">
10
+ <img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/venerate?style=for-the-badge">
14
11
  </a>
15
12
 
16
13
  ```sh
17
- npm i treetrunks
14
+ npm i venerate
18
15
  ```
19
16
 
20
- treetrunks is a convenient way to define type-safe routers.
21
-
22
- ## overview
17
+ venerate is a small, pure library implementing venn diagram logic for iterables.
23
18
 
24
- a tree structure affords many possible routes through the tree
19
+ ## usage
25
20
 
26
- ```typescript
27
- import type { Tree, TreePath } from "treetrunks";
28
- import { optional, required } from "treetrunks";
21
+ ```ts
22
+ import * as V from 'venerate'
29
23
 
30
- const greetingTree = required({
31
- hello: optional({
32
- world: null,
33
- $name: optional({
34
- good: required({
35
- morning: null,
36
- }),
37
- }),
38
- }),
39
- }) satisfies Tree;
24
+ const a = [1, 2, 3]
25
+ const b = new Set([2, 3, 4])
26
+ const c = (function* () { yield 3; yield 4; yield 5 })()
40
27
 
41
- const validPaths: TreePath<typeof greetingTree>[] = [
42
- [`hello`],
43
- [`hello`, `world`],
44
- [`hello`, `jeremybanka`],
45
- [`hello`, `treetrunks`, `good`, `morning`],
46
- ];
28
+ const union = [...V.union(a, b, c)] // [1, 2, 3, 4, 5]
47
29
  ```
48
-
49
- the `optional` and `required` functions help determine what routes are valid.
50
-
51
- note that,
52
-
53
- - `"hello"` is required
54
- - `"world"`, or any `$name` is optional
55
- - `"good morning"` is optional
@@ -16,13 +16,13 @@ declare function union<T>(...iterables: Iterable<T>[]): Iterable<T>;
16
16
  /**
17
17
  * Lazily yield A \ (B ∪ C ∪ ...), streaming A and pre-materializing removals.
18
18
  */
19
- declare function difference<T>(a: Iterable<T>, ...rest: Iterable<T>[]): Iterable<T>;
19
+ declare function difference<T>(base: Iterable<T>, ...rest: Iterable<T>[]): Iterable<T>;
20
20
  /**
21
21
  * Lazily yield A ∩ B ∩ C ∩ ...
22
22
  * Streams only the FIRST iterable; others are materialized as Sets for O(1) lookups.
23
23
  * If no others are provided, yields a shallow copy of A.
24
24
  */
25
- declare function intersection<T>(a: Iterable<T>, ...rest: Iterable<T>[]): Iterable<T>;
25
+ declare function intersection<T>(base: Iterable<T>, ...rest: Iterable<T>[]): Iterable<T>;
26
26
  /**
27
27
  * Lazily yield A △ B (pairwise symmetric difference).
28
28
  * Streams A and B once; materializes the opposite side for membership checks.
@@ -35,7 +35,7 @@ declare function symmetricDifference<T>(a: Iterable<T>, b: Iterable<T>): Iterabl
35
35
  * Still lazy in the sense that we only materialize small per-step Sets;
36
36
  * each fold pass consumes its input generator.
37
37
  */
38
- declare function symmetricDifferenceVariadic<T>(first: Iterable<T>, ...rest: Iterable<T>[]): Iterable<T>;
38
+ declare function symmetricDifferenceVariadic<T>(acc: Iterable<T>, ...rest: Iterable<T>[]): Iterable<T>;
39
39
  /**
40
40
  * Predicates (not lazy outputs, but efficient w/ early exits)
41
41
  */
package/dist/venerate.js CHANGED
@@ -30,27 +30,27 @@ function* union(...iterables) {
30
30
  /**
31
31
  * Lazily yield A \ (B ∪ C ∪ ...), streaming A and pre-materializing removals.
32
32
  */
33
- function* difference(a, ...rest) {
33
+ function* difference(base, ...rest) {
34
34
  if (rest.length === 0) {
35
- yield* a;
35
+ yield* base;
36
36
  return;
37
37
  }
38
38
  const remove = /* @__PURE__ */ new Set();
39
39
  for (const it of rest) for (const v of it) remove.add(v);
40
- for (const v of a) if (!remove.has(v)) yield v;
40
+ for (const v of base) if (!remove.has(v)) yield v;
41
41
  }
42
42
  /**
43
43
  * Lazily yield A ∩ B ∩ C ∩ ...
44
44
  * Streams only the FIRST iterable; others are materialized as Sets for O(1) lookups.
45
45
  * If no others are provided, yields a shallow copy of A.
46
46
  */
47
- function* intersection(a, ...rest) {
47
+ function* intersection(base, ...rest) {
48
48
  if (rest.length === 0) {
49
- yield* a;
49
+ yield* base;
50
50
  return;
51
51
  }
52
52
  const sets = rest.map(toSet);
53
- for (const v of a) if (sets.every((s) => s.has(v))) yield v;
53
+ for (const v of base) if (sets.every((s) => s.has(v))) yield v;
54
54
  }
55
55
  /**
56
56
  * Lazily yield A △ B (pairwise symmetric difference).
@@ -69,8 +69,7 @@ function* symmetricDifference(a, b) {
69
69
  * Still lazy in the sense that we only materialize small per-step Sets;
70
70
  * each fold pass consumes its input generator.
71
71
  */
72
- function* symmetricDifferenceVariadic(first, ...rest) {
73
- let acc = first;
72
+ function* symmetricDifferenceVariadic(acc, ...rest) {
74
73
  for (const it of rest) acc = symmetricDifference(acc, it);
75
74
  yield* acc;
76
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"venerate.js","names":["acc: Iterable<T>"],"sources":["../src/venerate.ts"],"sourcesContent":["/**\n * Cross-realm-safe check for anything that extends Set.\n */\nexport function isSet(value: unknown): value is Set<any> {\n\tif (value == null) return false\n\ttry {\n\t\t// brand check: throws TypeError unless `value` has [[SetData]]\n\t\tSet.prototype.has.call(value, Symbol.for(`@@brandCheck`))\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/**\n * Materializes an unknown iterable as a Set, without providing for mutation.\n * Does not copy the input if it is already a Set.\n */\nexport const toSet = <T>(it: Iterable<T>): ReadonlySet<T> =>\n\tisSet(it) ? it : new Set(it)\n\n/**\n * Lazily yield the union of A, B, C, ... preserving first-seen order.\n * Only a small \"seen\" Set is maintained; inputs are streamed.\n */\nexport function* union<T>(...iterables: Iterable<T>[]): Iterable<T> {\n\tconst seen = new Set<T>()\n\tfor (const it of iterables) {\n\t\tfor (const v of it) {\n\t\t\tif (!seen.has(v)) {\n\t\t\t\tseen.add(v)\n\t\t\t\tyield v\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Lazily yield A \\ (B ∪ C ∪ ...), streaming A and pre-materializing removals.\n */\nexport function* difference<T>(\n\ta: Iterable<T>,\n\t...rest: Iterable<T>[]\n): Iterable<T> {\n\tif (rest.length === 0) {\n\t\tyield* a\n\t\treturn\n\t}\n\tconst remove = new Set<T>()\n\tfor (const it of rest) for (const v of it) remove.add(v)\n\tfor (const v of a) if (!remove.has(v)) yield v\n}\n\n/**\n * Lazily yield A ∩ B ∩ C ∩ ...\n * Streams only the FIRST iterable; others are materialized as Sets for O(1) lookups.\n * If no others are provided, yields a shallow copy of A.\n */\nexport function* intersection<T>(\n\ta: Iterable<T>,\n\t...rest: Iterable<T>[]\n): Iterable<T> {\n\tif (rest.length === 0) {\n\t\tyield* a\n\t\treturn\n\t}\n\tconst sets = rest.map(toSet)\n\tfor (const v of a) {\n\t\tif (sets.every((s) => s.has(v))) yield v\n\t}\n}\n\n/**\n * Lazily yield A △ B (pairwise symmetric difference).\n * Streams A and B once; materializes the opposite side for membership checks.\n * - First yields items unique to A (preserving A's order)\n * - Then yields items unique to B (preserving B's order)\n */\nexport function* symmetricDifference<T>(\n\ta: Iterable<T>,\n\tb: Iterable<T>,\n): Iterable<T> {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\n\t// Items unique to A\n\tfor (const v of A) if (!B.has(v)) yield v\n\t// Items unique to B\n\tfor (const v of B) if (!A.has(v)) yield v\n}\n\n/**\n * Variadic symmetric difference via left fold of the pairwise version.\n * Still lazy in the sense that we only materialize small per-step Sets;\n * each fold pass consumes its input generator.\n */\nexport function* symmetricDifferenceVariadic<T>(\n\tfirst: Iterable<T>,\n\t...rest: Iterable<T>[]\n): Iterable<T> {\n\tlet acc: Iterable<T> = first\n\tfor (const it of rest) acc = symmetricDifference(acc, it)\n\tyield* acc\n}\n\n/**\n * Predicates (not lazy outputs, but efficient w/ early exits)\n */\nexport function isSubset<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\tif (A.size > B.size) return false\n\tfor (const v of A) if (!B.has(v)) return false\n\treturn true\n}\n\nexport function isSuperset<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\treturn isSubset(b, a)\n}\n\nexport function isDisjoint<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\tconst aIsSmall = A.size <= B.size\n\tconst small = aIsSmall ? A : B\n\tconst big = aIsSmall ? B : A\n\tfor (const v of small) if (big.has(v)) return false\n\treturn true\n}\n\nexport function equals<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\tif (A.size !== B.size) return false\n\tfor (const v of A) if (!B.has(v)) return false\n\treturn true\n}\n"],"mappings":";;;;AAGA,SAAgB,MAAM,OAAmC;AACxD,KAAI,SAAS,KAAM,QAAO;AAC1B,KAAI;AAEH,MAAI,UAAU,IAAI,KAAK,OAAO,OAAO,IAAI;AACzC,SAAO;CACP,QAAO;AACP,SAAO;CACP;AACD;;;;;AAMD,MAAa,SAAY,OACxB,MAAM,MAAM,KAAK,IAAI,IAAI;;;;;AAM1B,UAAiB,MAAS,GAAG,WAAuC;CACnE,MAAM,uBAAO,IAAI;AACjB,MAAK,MAAM,MAAM,UAChB,MAAK,MAAM,KAAK,GACf,KAAI,CAAC,KAAK,IAAI,IAAI;AACjB,OAAK,IAAI;AACT,QAAM;CACN;AAGH;;;;AAKD,UAAiB,WAChB,GACA,GAAG,MACW;AACd,KAAI,KAAK,WAAW,GAAG;AACtB,SAAO;AACP;CACA;CACD,MAAM,yBAAS,IAAI;AACnB,MAAK,MAAM,MAAM,KAAM,MAAK,MAAM,KAAK,GAAI,QAAO,IAAI;AACtD,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,OAAO,IAAI,GAAI,OAAM;AAC7C;;;;;;AAOD,UAAiB,aAChB,GACA,GAAG,MACW;AACd,KAAI,KAAK,WAAW,GAAG;AACtB,SAAO;AACP;CACA;CACD,MAAM,OAAO,KAAK,IAAI;AACtB,MAAK,MAAM,KAAK,EACf,KAAI,KAAK,OAAO,MAAM,EAAE,IAAI,IAAK,OAAM;AAExC;;;;;;;AAQD,UAAiB,oBAChB,GACA,GACc;CACd,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;AAGhB,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,OAAM;AAExC,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,OAAM;AACxC;;;;;;AAOD,UAAiB,4BAChB,OACA,GAAG,MACW;CACd,IAAIA,MAAmB;AACvB,MAAK,MAAM,MAAM,KAAM,OAAM,oBAAoB,KAAK;AACtD,QAAO;AACP;;;;AAKD,SAAgB,SAAY,GAAgB,GAAyB;CACpE,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;AAChB,KAAI,EAAE,OAAO,EAAE,KAAM,QAAO;AAC5B,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,QAAO;AACzC,QAAO;AACP;AAED,SAAgB,WAAc,GAAgB,GAAyB;AACtE,QAAO,SAAS,GAAG;AACnB;AAED,SAAgB,WAAc,GAAgB,GAAyB;CACtE,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;CAChB,MAAM,WAAW,EAAE,QAAQ,EAAE;CAC7B,MAAM,QAAQ,WAAW,IAAI;CAC7B,MAAM,MAAM,WAAW,IAAI;AAC3B,MAAK,MAAM,KAAK,MAAO,KAAI,IAAI,IAAI,GAAI,QAAO;AAC9C,QAAO;AACP;AAED,SAAgB,OAAU,GAAgB,GAAyB;CAClE,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;AAChB,KAAI,EAAE,SAAS,EAAE,KAAM,QAAO;AAC9B,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,QAAO;AACzC,QAAO;AACP"}
1
+ {"version":3,"file":"venerate.js","names":[],"sources":["../src/venerate.ts"],"sourcesContent":["/**\n * Cross-realm-safe check for anything that extends Set.\n */\nexport function isSet(value: unknown): value is Set<any> {\n\tif (value == null) return false\n\ttry {\n\t\t// brand check: throws TypeError unless `value` has [[SetData]]\n\t\tSet.prototype.has.call(value, Symbol.for(`@@brandCheck`))\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/**\n * Materializes an unknown iterable as a Set, without providing for mutation.\n * Does not copy the input if it is already a Set.\n */\nexport const toSet = <T>(it: Iterable<T>): ReadonlySet<T> =>\n\tisSet(it) ? it : new Set(it)\n\n/**\n * Lazily yield the union of A, B, C, ... preserving first-seen order.\n * Only a small \"seen\" Set is maintained; inputs are streamed.\n */\nexport function* union<T>(...iterables: Iterable<T>[]): Iterable<T> {\n\tconst seen = new Set<T>()\n\tfor (const it of iterables) {\n\t\tfor (const v of it) {\n\t\t\tif (!seen.has(v)) {\n\t\t\t\tseen.add(v)\n\t\t\t\tyield v\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Lazily yield A \\ (B ∪ C ∪ ...), streaming A and pre-materializing removals.\n */\nexport function* difference<T>(\n\tbase: Iterable<T>,\n\t...rest: Iterable<T>[]\n): Iterable<T> {\n\tif (rest.length === 0) {\n\t\tyield* base\n\t\treturn\n\t}\n\tconst remove = new Set<T>()\n\tfor (const it of rest) for (const v of it) remove.add(v)\n\tfor (const v of base) if (!remove.has(v)) yield v\n}\n\n/**\n * Lazily yield A ∩ B ∩ C ∩ ...\n * Streams only the FIRST iterable; others are materialized as Sets for O(1) lookups.\n * If no others are provided, yields a shallow copy of A.\n */\nexport function* intersection<T>(\n\tbase: Iterable<T>,\n\t...rest: Iterable<T>[]\n): Iterable<T> {\n\tif (rest.length === 0) {\n\t\tyield* base\n\t\treturn\n\t}\n\tconst sets = rest.map(toSet)\n\tfor (const v of base) {\n\t\tif (sets.every((s) => s.has(v))) yield v\n\t}\n}\n\n/**\n * Lazily yield A △ B (pairwise symmetric difference).\n * Streams A and B once; materializes the opposite side for membership checks.\n * - First yields items unique to A (preserving A's order)\n * - Then yields items unique to B (preserving B's order)\n */\nexport function* symmetricDifference<T>(\n\ta: Iterable<T>,\n\tb: Iterable<T>,\n): Iterable<T> {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\n\t// Items unique to A\n\tfor (const v of A) if (!B.has(v)) yield v\n\t// Items unique to B\n\tfor (const v of B) if (!A.has(v)) yield v\n}\n\n/**\n * Variadic symmetric difference via left fold of the pairwise version.\n * Still lazy in the sense that we only materialize small per-step Sets;\n * each fold pass consumes its input generator.\n */\nexport function* symmetricDifferenceVariadic<T>(\n\tacc: Iterable<T>,\n\t...rest: Iterable<T>[]\n): Iterable<T> {\n\tfor (const it of rest) acc = symmetricDifference(acc, it)\n\tyield* acc\n}\n\n/**\n * Predicates (not lazy outputs, but efficient w/ early exits)\n */\nexport function isSubset<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\tif (A.size > B.size) return false\n\tfor (const v of A) if (!B.has(v)) return false\n\treturn true\n}\n\nexport function isSuperset<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\treturn isSubset(b, a)\n}\n\nexport function isDisjoint<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\tconst aIsSmall = A.size <= B.size\n\tconst small = aIsSmall ? A : B\n\tconst big = aIsSmall ? B : A\n\tfor (const v of small) if (big.has(v)) return false\n\treturn true\n}\n\nexport function equals<T>(a: Iterable<T>, b: Iterable<T>): boolean {\n\tconst A = toSet(a)\n\tconst B = toSet(b)\n\tif (A.size !== B.size) return false\n\tfor (const v of A) if (!B.has(v)) return false\n\treturn true\n}\n"],"mappings":";;;;AAGA,SAAgB,MAAM,OAAmC;AACxD,KAAI,SAAS,KAAM,QAAO;AAC1B,KAAI;AAEH,MAAI,UAAU,IAAI,KAAK,OAAO,OAAO,IAAI;AACzC,SAAO;CACP,QAAO;AACP,SAAO;CACP;AACD;;;;;AAMD,MAAa,SAAY,OACxB,MAAM,MAAM,KAAK,IAAI,IAAI;;;;;AAM1B,UAAiB,MAAS,GAAG,WAAuC;CACnE,MAAM,uBAAO,IAAI;AACjB,MAAK,MAAM,MAAM,UAChB,MAAK,MAAM,KAAK,GACf,KAAI,CAAC,KAAK,IAAI,IAAI;AACjB,OAAK,IAAI;AACT,QAAM;CACN;AAGH;;;;AAKD,UAAiB,WAChB,MACA,GAAG,MACW;AACd,KAAI,KAAK,WAAW,GAAG;AACtB,SAAO;AACP;CACA;CACD,MAAM,yBAAS,IAAI;AACnB,MAAK,MAAM,MAAM,KAAM,MAAK,MAAM,KAAK,GAAI,QAAO,IAAI;AACtD,MAAK,MAAM,KAAK,KAAM,KAAI,CAAC,OAAO,IAAI,GAAI,OAAM;AAChD;;;;;;AAOD,UAAiB,aAChB,MACA,GAAG,MACW;AACd,KAAI,KAAK,WAAW,GAAG;AACtB,SAAO;AACP;CACA;CACD,MAAM,OAAO,KAAK,IAAI;AACtB,MAAK,MAAM,KAAK,KACf,KAAI,KAAK,OAAO,MAAM,EAAE,IAAI,IAAK,OAAM;AAExC;;;;;;;AAQD,UAAiB,oBAChB,GACA,GACc;CACd,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;AAGhB,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,OAAM;AAExC,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,OAAM;AACxC;;;;;;AAOD,UAAiB,4BAChB,KACA,GAAG,MACW;AACd,MAAK,MAAM,MAAM,KAAM,OAAM,oBAAoB,KAAK;AACtD,QAAO;AACP;;;;AAKD,SAAgB,SAAY,GAAgB,GAAyB;CACpE,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;AAChB,KAAI,EAAE,OAAO,EAAE,KAAM,QAAO;AAC5B,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,QAAO;AACzC,QAAO;AACP;AAED,SAAgB,WAAc,GAAgB,GAAyB;AACtE,QAAO,SAAS,GAAG;AACnB;AAED,SAAgB,WAAc,GAAgB,GAAyB;CACtE,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;CAChB,MAAM,WAAW,EAAE,QAAQ,EAAE;CAC7B,MAAM,QAAQ,WAAW,IAAI;CAC7B,MAAM,MAAM,WAAW,IAAI;AAC3B,MAAK,MAAM,KAAK,MAAO,KAAI,IAAI,IAAI,GAAI,QAAO;AAC9C,QAAO;AACP;AAED,SAAgB,OAAU,GAAgB,GAAyB;CAClE,MAAM,IAAI,MAAM;CAChB,MAAM,IAAI,MAAM;AAChB,KAAI,EAAE,SAAS,EAAE,KAAM,QAAO;AAC9B,MAAK,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,GAAI,QAAO;AACzC,QAAO;AACP"}
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
1
  {
2
- "name": "venerate",
3
- "version": "0.0.0",
4
- "license": "MIT",
5
- "author": {
6
- "name": "Jeremy Banka",
7
- "email": "hello@jeremybanka.com"
8
- },
9
- "publishConfig": {
10
- "access": "public"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/jeremybanka/wayforge.git",
15
- "directory": "packages/venerate"
16
- },
17
- "type": "module",
18
- "files": [
19
- "dist",
20
- "src"
21
- ],
22
- "main": "dist/venerate.js",
23
- "scripts": {
24
- "build": "tsdown",
25
- "lint:biome": "biome check -- .",
26
- "lint:eslint": "eslint -- .",
27
- "lint:types": "tsgo --noEmit",
28
- "watch:types": "tsgo --watch --noEmit",
29
- "lint": "concurrently \"bun:lint:*\"",
30
- "test": "vitest",
31
- "test:coverage": "vitest run --coverage",
32
- "test:once": "vitest run",
33
- "postversion": "biome format --write package.json"
34
- },
35
- "devDependencies": {
36
- "@types/node": "24.3.0",
37
- "@vitest/coverage-v8": "3.2.4",
38
- "concurrently": "9.2.0",
39
- "eslint": "9.33.0",
40
- "recoverage": "0.1.11",
41
- "tsdown": "0.14.1",
42
- "vite": "7.1.3",
43
- "vitest": "3.2.4"
44
- }
45
- }
2
+ "name": "venerate",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "author": {
6
+ "name": "Jeremy Banka",
7
+ "email": "hello@jeremybanka.com"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/jeremybanka/wayforge.git",
15
+ "directory": "packages/venerate"
16
+ },
17
+ "type": "module",
18
+ "files": [
19
+ "dist",
20
+ "src"
21
+ ],
22
+ "main": "dist/venerate.js",
23
+ "devDependencies": {
24
+ "@types/node": "24.3.0",
25
+ "@vitest/coverage-v8": "3.2.4",
26
+ "concurrently": "9.2.0",
27
+ "eslint": "9.33.0",
28
+ "recoverage": "0.1.11",
29
+ "tsdown": "0.14.1",
30
+ "vite": "7.1.3",
31
+ "vitest": "3.2.4"
32
+ },
33
+ "scripts": {
34
+ "build": "tsdown",
35
+ "lint:biome": "biome check -- .",
36
+ "lint:eslint": "eslint -- .",
37
+ "lint:types": "tsgo --noEmit",
38
+ "watch:types": "tsgo --watch --noEmit",
39
+ "lint": "concurrently \"bun:lint:*\"",
40
+ "test": "vitest",
41
+ "test:coverage": "vitest run --coverage",
42
+ "test:once": "vitest run",
43
+ "postversion": "biome format --write package.json"
44
+ }
45
+ }
package/src/venerate.ts CHANGED
@@ -39,16 +39,16 @@ export function* union<T>(...iterables: Iterable<T>[]): Iterable<T> {
39
39
  * Lazily yield A \ (B ∪ C ∪ ...), streaming A and pre-materializing removals.
40
40
  */
41
41
  export function* difference<T>(
42
- a: Iterable<T>,
42
+ base: Iterable<T>,
43
43
  ...rest: Iterable<T>[]
44
44
  ): Iterable<T> {
45
45
  if (rest.length === 0) {
46
- yield* a
46
+ yield* base
47
47
  return
48
48
  }
49
49
  const remove = new Set<T>()
50
50
  for (const it of rest) for (const v of it) remove.add(v)
51
- for (const v of a) if (!remove.has(v)) yield v
51
+ for (const v of base) if (!remove.has(v)) yield v
52
52
  }
53
53
 
54
54
  /**
@@ -57,15 +57,15 @@ export function* difference<T>(
57
57
  * If no others are provided, yields a shallow copy of A.
58
58
  */
59
59
  export function* intersection<T>(
60
- a: Iterable<T>,
60
+ base: Iterable<T>,
61
61
  ...rest: Iterable<T>[]
62
62
  ): Iterable<T> {
63
63
  if (rest.length === 0) {
64
- yield* a
64
+ yield* base
65
65
  return
66
66
  }
67
67
  const sets = rest.map(toSet)
68
- for (const v of a) {
68
+ for (const v of base) {
69
69
  if (sets.every((s) => s.has(v))) yield v
70
70
  }
71
71
  }
@@ -95,10 +95,9 @@ export function* symmetricDifference<T>(
95
95
  * each fold pass consumes its input generator.
96
96
  */
97
97
  export function* symmetricDifferenceVariadic<T>(
98
- first: Iterable<T>,
98
+ acc: Iterable<T>,
99
99
  ...rest: Iterable<T>[]
100
100
  ): Iterable<T> {
101
- let acc: Iterable<T> = first
102
101
  for (const it of rest) acc = symmetricDifference(acc, it)
103
102
  yield* acc
104
103
  }