venerate 0.0.1 → 0.0.3
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 +10 -6
- package/dist/venerate.d.ts.map +1 -0
- package/dist/venerate.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
<img alt="Dependencies 0" src="
|
|
7
|
+
<img alt="Dependencies 0" src="https://img.shields.io/badge/dependencies-0-0?style=for-the-badge">
|
|
8
8
|
</a>
|
|
9
9
|
<a href="https://bundlephobia.com/result?p=venerate">
|
|
10
10
|
<img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/venerate?style=for-the-badge">
|
|
@@ -19,11 +19,15 @@ venerate is a small, pure library implementing venn diagram logic for iterables.
|
|
|
19
19
|
## usage
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import * as V from
|
|
22
|
+
import * as V from "venerate";
|
|
23
23
|
|
|
24
|
-
const a = [1, 2, 3]
|
|
25
|
-
const b = new Set([2, 3, 4])
|
|
26
|
-
const c = (function* () {
|
|
24
|
+
const a = [1, 2, 3];
|
|
25
|
+
const b = new Set([2, 3, 4]);
|
|
26
|
+
const c = (function* () {
|
|
27
|
+
yield 3;
|
|
28
|
+
yield 4;
|
|
29
|
+
yield 5;
|
|
30
|
+
})();
|
|
27
31
|
|
|
28
|
-
const union = [...V.union(a, b, c)] // [1, 2, 3, 4, 5]
|
|
32
|
+
const union = [...V.union(a, b, c)]; // [1, 2, 3, 4, 5]
|
|
29
33
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"venerate.d.ts","names":[],"sources":["../src/venerate.ts"],"sourcesContent":[],"mappings":";;AAGA;AAeA;A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,QA1BnC,CA0B4C,CA1B5C,CAAA,CAAA,EAAA,OAAA;AAAT,iBAkCa,UAlCb,CAAA,CAAA,CAAA,CAAA,CAAA,EAkC8B,QAlC9B,CAkCuC,CAlCvC,CAAA,EAAA,CAAA,EAkC8C,QAlC9C,CAkCuD,CAlCvD,CAAA,CAAA,EAAA,OAAA;AAAA,iBAsCa,UAtCb,CAAA,CAAA,CAAA,CAAA,CAAA,EAsC8B,QAtC9B,CAsCuC,CAtCvC,CAAA,EAAA,CAAA,EAsC8C,QAtC9C,CAsCuD,CAtCvD,CAAA,CAAA,EAAA,OAAA;AAec,iBAiCD,MAjCC,CAAA,CAAA,CAAA,CAAA,CAAA,EAiCY,QAjCZ,CAiCqB,CAjCrB,CAAA,EAAA,CAAA,EAiC4B,QAjC5B,CAiCqC,CAjCrC,CAAA,CAAA,EAAA,OAAA"}
|
package/dist/venerate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,eAAe,CAAC;AACzD,SAAO;SACA;AACP,SAAO;;;;;;;AAQT,MAAa,SAAY,OACxB,MAAM,GAAG,GAAG,KAAK,IAAI,IAAI,GAAG;;;;;AAM7B,UAAiB,MAAS,GAAG,WAAuC;CACnE,MAAM,uBAAO,IAAI,KAAQ;AACzB,MAAK,MAAM,MAAM,UAChB,MAAK,MAAM,KAAK,GACf,KAAI,CAAC,KAAK,IAAI,EAAE,EAAE;AACjB,OAAK,IAAI,EAAE;AACX,QAAM;;;;;;AASV,UAAiB,WAChB,MACA,GAAG,MACW;AACd,KAAI,KAAK,WAAW,GAAG;AACtB,SAAO;AACP;;CAED,MAAM,yBAAS,IAAI,KAAQ;AAC3B,MAAK,MAAM,MAAM,KAAM,MAAK,MAAM,KAAK,GAAI,QAAO,IAAI,EAAE;AACxD,MAAK,MAAM,KAAK,KAAM,KAAI,CAAC,OAAO,IAAI,EAAE,CAAE,OAAM;;;;;;;AAQjD,UAAiB,aAChB,MACA,GAAG,MACW;AACd,KAAI,KA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K,MAAM,KAAK,EAAG,KAAI,CAAC,EAAE,IAAI,EAAE,CAAE,QAAO;AACzC,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "venerate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jeremy Banka",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
],
|
|
22
22
|
"main": "dist/venerate.js",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/node": "24.3.
|
|
24
|
+
"@types/node": "24.3.1",
|
|
25
25
|
"@vitest/coverage-v8": "3.2.4",
|
|
26
|
-
"concurrently": "9.2.
|
|
27
|
-
"eslint": "9.
|
|
26
|
+
"concurrently": "9.2.1",
|
|
27
|
+
"eslint": "9.35.0",
|
|
28
28
|
"recoverage": "0.1.11",
|
|
29
|
-
"tsdown": "0.14.
|
|
30
|
-
"vite": "7.1.
|
|
29
|
+
"tsdown": "0.14.2",
|
|
30
|
+
"vite": "7.1.5",
|
|
31
31
|
"vitest": "3.2.4"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|