@isograph/disposable-types 0.0.0-main-79e2a3c0 → 0.0.0-main-ae4fea0e

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.
@@ -1,11 +1,11 @@
1
1
  ../.. |  WARN  Unsupported engine: wanted: {"node":"24.12.0"} (current: {"node":"v24.20.0","pnpm":"10.15.0"})
2
2
 
3
- > @isograph/disposable-types@0.0.0-main-79e2a3c0 compile-libs /home/runner/work/isograph/isograph/libs/isograph-disposable-types
3
+ > @isograph/disposable-types@0.0.0-main-ae4fea0e compile-libs /home/runner/work/isograph/isograph/libs/isograph-disposable-types
4
4
  > tsdown
5
5
 
6
6
  ℹ tsdown v0.20.1 powered by rolldown v1.0.0-rc.1
7
7
  ℹ config file: /home/runner/work/isograph/isograph/tsdown.config.ts
8
- (node:2441) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/isograph/isograph/tsdown.config.ts?no-cache=30ac702b-12ce-449f-91ed-e242cb2824a1 is not specified and it doesn't parse as CommonJS.
8
+ (node:2653) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/isograph/isograph/tsdown.config.ts?no-cache=dea0ee5b-991e-42cf-93dd-ff44b8fc144d is not specified and it doesn't parse as CommonJS.
9
9
  Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
10
10
  To eliminate this warning, add "type": "module" to /home/runner/work/isograph/isograph/package.json.
11
11
  (Use `node --trace-warnings ...` to show where the warning was created)
@@ -1,5 +1,5 @@
1
1
  ../.. |  WARN  Unsupported engine: wanted: {"node":"24.12.0"} (current: {"node":"v24.20.0","pnpm":"10.15.0"})
2
2
 
3
- > @isograph/disposable-types@0.0.0-main-79e2a3c0 tsc /home/runner/work/isograph/isograph/libs/isograph-disposable-types
3
+ > @isograph/disposable-types@0.0.0-main-ae4fea0e tsc /home/runner/work/isograph/isograph/libs/isograph-disposable-types
4
4
  > tsc
5
5
 
package/dist/index.cjs CHANGED
@@ -0,0 +1,20 @@
1
+
2
+ //#region src/index.ts
3
+ function joinCleanups(...pairs) {
4
+ const items = pairs.map(([item]) => item);
5
+ const dispose = () => {
6
+ let error;
7
+ pairs.reduceRight((_, [, cleanup]) => {
8
+ try {
9
+ cleanup();
10
+ } catch (e) {
11
+ error ??= e;
12
+ }
13
+ }, void 0);
14
+ if (error !== void 0) throw error;
15
+ };
16
+ return [items, dispose];
17
+ }
18
+
19
+ //#endregion
20
+ exports.joinCleanups = joinCleanups;
package/dist/index.d.cts CHANGED
@@ -2,6 +2,8 @@
2
2
  type CleanupFn = () => void;
3
3
  type ItemCleanupPair<T> = [T, CleanupFn];
4
4
  type Factory<T> = () => ItemCleanupPair<T>;
5
+ type ItemsOf<T extends readonly ItemCleanupPair<unknown>[]> = { [I in keyof T]: T[I] extends ItemCleanupPair<infer V> ? V : never };
6
+ declare function joinCleanups<const T extends readonly ItemCleanupPair<unknown>[]>(...pairs: T): ItemCleanupPair<ItemsOf<T>>;
5
7
  //#endregion
6
- export { CleanupFn, Factory, ItemCleanupPair };
8
+ export { CleanupFn, Factory, ItemCleanupPair, joinCleanups };
7
9
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";KAAY,SAAA;AAAA,KACA,eAAA,OAAsB,CAAA,EAAG,SAAA;AAAA,KACzB,OAAA,YAAmB,eAAA,CAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";KAAY,SAAA;AAAA,KACA,eAAA,OAAsB,CAAA,EAAG,SAAA;AAAA,KACzB,OAAA,YAAmB,eAAA,CAAgB,CAAA;AAAA,KAE1C,OAAA,oBAA2B,eAAA,6BAClB,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,eAAA,YAA2B,CAAA;AAAA,iBAG1C,YAAA,0BACW,eAAA,YAAA,CAAA,GACtB,KAAA,EAAO,CAAA,GAAI,eAAA,CAAgB,OAAA,CAAQ,CAAA"}
package/dist/index.d.mts CHANGED
@@ -2,6 +2,8 @@
2
2
  type CleanupFn = () => void;
3
3
  type ItemCleanupPair<T> = [T, CleanupFn];
4
4
  type Factory<T> = () => ItemCleanupPair<T>;
5
+ type ItemsOf<T extends readonly ItemCleanupPair<unknown>[]> = { [I in keyof T]: T[I] extends ItemCleanupPair<infer V> ? V : never };
6
+ declare function joinCleanups<const T extends readonly ItemCleanupPair<unknown>[]>(...pairs: T): ItemCleanupPair<ItemsOf<T>>;
5
7
  //#endregion
6
- export { CleanupFn, Factory, ItemCleanupPair };
8
+ export { CleanupFn, Factory, ItemCleanupPair, joinCleanups };
7
9
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAAY,SAAA;AAAA,KACA,eAAA,OAAsB,CAAA,EAAG,SAAA;AAAA,KACzB,OAAA,YAAmB,eAAA,CAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAAY,SAAA;AAAA,KACA,eAAA,OAAsB,CAAA,EAAG,SAAA;AAAA,KACzB,OAAA,YAAmB,eAAA,CAAgB,CAAA;AAAA,KAE1C,OAAA,oBAA2B,eAAA,6BAClB,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,eAAA,YAA2B,CAAA;AAAA,iBAG1C,YAAA,0BACW,eAAA,YAAA,CAAA,GACtB,KAAA,EAAO,CAAA,GAAI,eAAA,CAAgB,OAAA,CAAQ,CAAA"}
package/dist/index.mjs CHANGED
@@ -1 +1,20 @@
1
- export { };
1
+ //#region src/index.ts
2
+ function joinCleanups(...pairs) {
3
+ const items = pairs.map(([item]) => item);
4
+ const dispose = () => {
5
+ let error;
6
+ pairs.reduceRight((_, [, cleanup]) => {
7
+ try {
8
+ cleanup();
9
+ } catch (e) {
10
+ error ??= e;
11
+ }
12
+ }, void 0);
13
+ if (error !== void 0) throw error;
14
+ };
15
+ return [items, dispose];
16
+ }
17
+
18
+ //#endregion
19
+ export { joinCleanups };
20
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export type CleanupFn = () => void;\nexport type ItemCleanupPair<T> = [T, CleanupFn];\nexport type Factory<T> = () => ItemCleanupPair<T>;\n\ntype ItemsOf<T extends readonly ItemCleanupPair<unknown>[]> = {\n [I in keyof T]: T[I] extends ItemCleanupPair<infer V> ? V : never;\n};\n\nexport function joinCleanups<\n const T extends readonly ItemCleanupPair<unknown>[],\n>(...pairs: T): ItemCleanupPair<ItemsOf<T>> {\n const items = pairs.map(([item]) => item) as ItemsOf<T>;\n const dispose: CleanupFn = () => {\n let error: unknown;\n pairs.reduceRight((_, [, cleanup]) => {\n try {\n cleanup();\n } catch (e) {\n error ??= e;\n }\n return undefined;\n }, undefined);\n if (error !== undefined) {\n throw error;\n }\n };\n return [items, dispose];\n}\n"],"mappings":";AAQA,SAAgB,aAEd,GAAG,OAAuC;CAC1C,MAAM,QAAQ,MAAM,KAAK,CAAC,UAAU,KAAK;CACzC,MAAM,gBAA2B;EAC/B,IAAI;AACJ,QAAM,aAAa,GAAG,GAAG,aAAa;AACpC,OAAI;AACF,aAAS;YACF,GAAG;AACV,cAAU;;KAGX,OAAU;AACb,MAAI,UAAU,OACZ,OAAM;;AAGV,QAAO,CAAC,OAAO,QAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isograph/disposable-types",
3
- "version": "0.0.0-main-79e2a3c0",
3
+ "version": "0.0.0-main-ae4fea0e",
4
4
  "description": "Common types for disposable items",
5
5
  "homepage": "https://isograph.dev",
6
6
  "main": "./dist/index.cjs",
package/src/index.ts CHANGED
@@ -1,3 +1,28 @@
1
1
  export type CleanupFn = () => void;
2
2
  export type ItemCleanupPair<T> = [T, CleanupFn];
3
3
  export type Factory<T> = () => ItemCleanupPair<T>;
4
+
5
+ type ItemsOf<T extends readonly ItemCleanupPair<unknown>[]> = {
6
+ [I in keyof T]: T[I] extends ItemCleanupPair<infer V> ? V : never;
7
+ };
8
+
9
+ export function joinCleanups<
10
+ const T extends readonly ItemCleanupPair<unknown>[],
11
+ >(...pairs: T): ItemCleanupPair<ItemsOf<T>> {
12
+ const items = pairs.map(([item]) => item) as ItemsOf<T>;
13
+ const dispose: CleanupFn = () => {
14
+ let error: unknown;
15
+ pairs.reduceRight((_, [, cleanup]) => {
16
+ try {
17
+ cleanup();
18
+ } catch (e) {
19
+ error ??= e;
20
+ }
21
+ return undefined;
22
+ }, undefined);
23
+ if (error !== undefined) {
24
+ throw error;
25
+ }
26
+ };
27
+ return [items, dispose];
28
+ }