indisposed 0.0.8 โ†’ 0.2.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/README.md CHANGED
@@ -10,6 +10,8 @@ The missing utilities for JavaScript's [Explicit Resource Management](https://gi
10
10
 
11
11
  - ๐Ÿงน **Resource Management** - Convert any resource into a disposable with `toDisposable` and `toAsyncDisposable`
12
12
  - ๐ŸŽง **Event Handlers** - Transform event emitters into disposable iterators with `on` and promises with `once`
13
+ - โฑ๏ธ **Timing Utilities** - Disposable `timeout` and `interval` for clean timer management
14
+ - ๐Ÿ“ก **Channels** - Build async iterators from push-based sources with `channel`
13
15
  - ๐Ÿ”’ **Scoped Execution** - Execute code with automatic cleanup using `invoke`
14
16
  - ๐Ÿ“ฆ **Zero Dependencies** - Lightweight and focused
15
17
  - ๐Ÿ”ง **TypeScript First** - Full type safety and inference
@@ -133,7 +135,7 @@ import { once } from "indisposed";
133
135
  }
134
136
  ```
135
137
 
136
- ### `on(emitter, event, maxBuffer?)`
138
+ ### `on(emitter, event, options?)`
137
139
 
138
140
  Create a disposable async iterator for multiple events.
139
141
 
@@ -164,6 +166,109 @@ import { on } from "indisposed";
164
166
  console.log(`Position: ${x}, ${y}`);
165
167
  }
166
168
  }
169
+
170
+ // With buffer options
171
+ {
172
+ using events = on(emitter, "data", { maxBuffer: 10, drain: true });
173
+ // ...
174
+ }
175
+ ```
176
+
177
+ ### `timeout(ms)`
178
+
179
+ Create a disposable promise that resolves after a delay.
180
+
181
+ ```typescript
182
+ import { timeout } from "indisposed";
183
+
184
+ // Basic usage
185
+ await timeout(1000);
186
+ console.log("1 second passed");
187
+
188
+ // With using - automatically clears timeout when scope exits
189
+ {
190
+ using timer = timeout(5000);
191
+ await timer;
192
+ } // timeout cleared if scope exits early
193
+
194
+ // Racing with other promises
195
+ {
196
+ using timer = timeout(10000);
197
+ using data = once(socket, "data");
198
+
199
+ await Promise.race([timer, data]);
200
+ } // both cleaned up regardless of which wins
201
+ ```
202
+
203
+ ### `interval(ms, options?)`
204
+
205
+ Create a disposable async iterator that yields incrementing numbers at a fixed interval.
206
+
207
+ ```typescript
208
+ import { interval } from "indisposed";
209
+
210
+ // Basic usage - tick every second
211
+ {
212
+ using ticks = interval(1000);
213
+
214
+ for await (const tick of ticks) {
215
+ console.log(`Tick ${tick}`); // 0, 1, 2, ...
216
+ if (tick >= 5) break;
217
+ }
218
+ } // interval automatically cleared
219
+
220
+ // Polling pattern
221
+ {
222
+ using poll = interval(5000);
223
+
224
+ for await (const _ of poll) {
225
+ const status = await checkStatus();
226
+ if (status === "complete") break;
227
+ }
228
+ }
229
+
230
+ // With options
231
+ const ticks = interval(100, { maxBuffer: 10, drain: true });
232
+ ```
233
+
234
+ ### `channel<T>(options?)`
235
+
236
+ Create a buffered async channel for pushing values and consuming them via async iteration.
237
+
238
+ This is a low-level primitive for building async iterators from push-based sources.
239
+ The channel separates producer (`push`) and consumer (`iterator`) concerns - only expose
240
+ the `iterator` to downstream code.
241
+
242
+ **Options:**
243
+
244
+ - `maxBuffer` - Maximum events to buffer (default: 100). Set to 0 for no buffering.
245
+ - `drain` - Whether to drain buffered events on dispose (default: false)
246
+
247
+ ```typescript
248
+ import { channel } from "indisposed";
249
+
250
+ // Basic usage - producer keeps the channel, consumer gets the iterator
251
+ const ch = channel<string>();
252
+
253
+ // Producer side
254
+ ch.push("hello");
255
+ ch.push("world");
256
+
257
+ // Consumer side - only sees the iterator
258
+ {
259
+ using iter = ch.iterator;
260
+ for await (const value of iter) {
261
+ console.log(value);
262
+ if (shouldStop) break;
263
+ }
264
+ }
265
+
266
+ // Building a custom async source
267
+ function createDataStream() {
268
+ const ch = channel<Data>();
269
+ source.on("data", (d) => ch.push(d));
270
+ return ch.iterator; // Only expose the iterator
271
+ }
167
272
  ```
168
273
 
169
274
  ### `invoke<T>(fn)`
@@ -0,0 +1,82 @@
1
+ export type ChannelOptions = {
2
+ /**
3
+ * Maximum amount of events to be buffered.
4
+ * When buffer is full, oldest events are dropped.
5
+ * Set to 0 to disable buffering (only deliver to waiting consumers).
6
+ * @default 100
7
+ */
8
+ maxBuffer?: number;
9
+ /**
10
+ * Whether to drain buffered events before ending iteration on dispose.
11
+ * When true, buffered events will still be yielded after dispose is called.
12
+ * When false, dispose immediately ends iteration and discards buffered events.
13
+ * @default false
14
+ */
15
+ drain?: boolean;
16
+ };
17
+ /**
18
+ * The iterator portion of a channel - this is what consumers see.
19
+ */
20
+ export type ChannelIterator<T> = AsyncIterableIterator<T, undefined, void> & {
21
+ [Symbol.dispose]: () => void;
22
+ };
23
+ /**
24
+ * The full channel handle with push capability - for internal/producer use.
25
+ */
26
+ export type Channel<T> = {
27
+ /**
28
+ * Push a value into the channel.
29
+ * If there are waiting consumers, the value is delivered immediately.
30
+ * Otherwise, it's buffered (subject to maxBuffer).
31
+ */
32
+ push: (value: T) => void;
33
+ /**
34
+ * Whether the channel is closed.
35
+ */
36
+ readonly closed: boolean;
37
+ /**
38
+ * The async iterator for consuming values.
39
+ * This is what should be exposed to downstream consumers.
40
+ */
41
+ iterator: ChannelIterator<T>;
42
+ };
43
+ /**
44
+ * Creates a buffered async channel for pushing values and consuming them via async iteration.
45
+ *
46
+ * This is a low-level primitive for building async iterators from push-based sources
47
+ * like event emitters, intervals, or any producer that pushes values over time.
48
+ *
49
+ * The returned channel has a `push` method for producers and an `iterator` property
50
+ * for consumers. Only expose the `iterator` to downstream code.
51
+ *
52
+ * @param options - Channel configuration
53
+ * @returns A channel with push capability and a disposable async iterator
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * // Basic usage - producer keeps the channel, consumer gets the iterator
58
+ * const ch = channel<string>();
59
+ *
60
+ * // Producer side
61
+ * ch.push("hello");
62
+ * ch.push("world");
63
+ *
64
+ * // Consumer side - only sees the iterator
65
+ * for await (const value of ch.iterator) {
66
+ * console.log(value);
67
+ * if (shouldStop) break;
68
+ * }
69
+ * ```
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * // Building a custom async iterator
74
+ * function myAsyncSource() {
75
+ * const ch = channel<number>();
76
+ * // ... set up producer that calls ch.push()
77
+ * return ch.iterator; // Only expose the iterator
78
+ * }
79
+ * ```
80
+ */
81
+ export declare function channel<T>(options?: ChannelOptions): Channel<T>;
82
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/functions/channel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC5B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAOF;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG;IAC5E,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACxB;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CA6F/D"}
@@ -1,5 +1,6 @@
1
- import { EventHandlerParams, EventNames, Fn } from '../types';
2
- import { UnpackArray } from './fn';
1
+ import { EventHandlerParams, EventNames, Fn } from '#/types';
2
+ import { ChannelOptions } from '#/functions/channel';
3
+ import { UnpackArray } from '#/functions/fn';
3
4
  export type Subscription = (event: any, handler: Fn) => any;
4
5
  /**
5
6
  * Represents an event emitter with an `off` method for removing listeners.
@@ -67,7 +68,7 @@ export type OnResult<EventEmitter extends HasOn, Event extends EventNames<EventE
67
68
  *
68
69
  * @param emitter - Event emitter with `on` and `off` methods
69
70
  * @param event - Event name (must match one of the emitter's overloads)
70
- * @param maxBuffer - Maximum number of events to buffer (default: 100)
71
+ * @param options - Channel options (maxBuffer, etc.)
71
72
  * @returns Disposable async iterator that yields handler arguments
72
73
  *
73
74
  * @example
@@ -93,7 +94,9 @@ export type OnResult<EventEmitter extends HasOn, Event extends EventNames<EventE
93
94
  * }
94
95
  * ```
95
96
  */
96
- export declare function on<EventEmitter extends HasOn, const Event extends EventNames<EventEmitter["on"]>>(emitter: EventEmitter, event: Event, maxBuffer?: number): AsyncIterableIterator<UnpackArray<Parameters<import('../types').OverLoadFunctions<EventEmitter["on"]>> extends infer T ? T extends Parameters<import('../types').OverLoadFunctions<EventEmitter["on"]>> ? T extends unknown ? T extends [Event, infer Handler] ? import('../types').ExtractParams<Handler> extends infer P ? P extends any[] ? any[] extends P ? never : P : never : never : never : never : never : never>, undefined, void> & {
97
+ export declare function on<EventEmitter extends HasOn, const Event extends EventNames<EventEmitter["on"]>>(emitter: EventEmitter, event: Event, options?: ChannelOptions): AsyncIterableIterator<UnpackArray<Parameters<import('#/types').OverLoadFunctions<EventEmitter["on"]>> extends infer T ? T extends Parameters<import('#/types').OverLoadFunctions<EventEmitter["on"]>> ? T extends unknown ? T extends [Event, infer Handler] ? import('#/types').ExtractParams<Handler> extends infer P ? P extends any[] ? any[] extends P ? never : P : never : never : never : never : never : never>, undefined, void> & {
98
+ [Symbol.dispose]: () => void;
99
+ } & {
97
100
  [Symbol.dispose]: () => void;
98
101
  };
99
102
  //# sourceMappingURL=handlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/functions/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAA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O,EAC5B,KAAK,CAAC,KAAK,SAAS,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EACpD,KAAK,CAAC,OAAO,SAAS,OAAO,GAAG,KAAK,EACpC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO;;EAavD;AAED,MAAM,MAAM,QAAQ,CACnB,YAAY,SAAS,KAAK,EAC1B,KAAK,SAAS,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IACzC,WAAW,CAAC,kBAAkB,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,EAAE,CACjB,YAAY,SAAS,KAAK,EAC1B,KAAK,CAAC,KAAK,SAAS,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EACjD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc;;;;EAc9D"}
@@ -0,0 +1,91 @@
1
+ import { ChannelOptions } from '#/functions/channel';
2
+ /**
3
+ * Creates a disposable promise that resolves after a specified delay.
4
+ *
5
+ * The timeout is automatically cleared when disposed, preventing
6
+ * memory leaks and unnecessary timer execution.
7
+ *
8
+ * @param ms - Delay in milliseconds before the promise resolves
9
+ * @returns A disposable promise that resolves to `void` after the delay
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // Basic usage - wait for 1 second
14
+ * await timeout(1000);
15
+ * console.log("1 second passed");
16
+ * ```
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // With using - automatically clears timeout when scope exits
21
+ * {
22
+ * using timer = timeout(5000);
23
+ * await timer;
24
+ * } // timeout cleared if scope exits early
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // Racing with other promises - losing timeout is cleaned up
30
+ * {
31
+ * using timer = timeout(10000);
32
+ * using data = once(socket, "data");
33
+ *
34
+ * await Promise.race([timer, data]);
35
+ * } // both cleaned up regardless of which wins
36
+ * ```
37
+ */
38
+ export declare function timeout(ms: number): Promise<void> & {
39
+ [Symbol.dispose]: () => void;
40
+ };
41
+ export type IntervalOptions = ChannelOptions;
42
+ /**
43
+ * Creates a disposable async iterator that yields incrementing numbers at a fixed interval.
44
+ *
45
+ * Values start at 0 and increment by 1 for each interval tick. The interval
46
+ * is automatically cleared when the iterator is disposed or iteration ends.
47
+ *
48
+ * @param ms - Interval duration in milliseconds between each tick
49
+ * @param options - Channel options for buffering behavior
50
+ * @param options.maxBuffer - Maximum events to buffer (default: 100). Set to 0 for no buffering.
51
+ * @param options.drain - Whether to drain buffer on close (default: false)
52
+ * @returns A disposable async iterator yielding incrementing numbers
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * // Basic usage - tick every second
57
+ * {
58
+ * using ticks = interval(1000);
59
+ *
60
+ * for await (const tick of ticks) {
61
+ * console.log(`Tick ${tick}`); // 0, 1, 2, ...
62
+ * if (tick >= 5) break;
63
+ * }
64
+ * } // interval automatically cleared
65
+ * ```
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * // Polling pattern
70
+ * {
71
+ * using poll = interval(5000);
72
+ *
73
+ * for await (const _ of poll) {
74
+ * const status = await checkStatus();
75
+ * if (status === "complete") break;
76
+ * }
77
+ * }
78
+ * ```
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * // With no buffering - only deliver to waiting consumers
83
+ * const ticks = interval(100, { maxBuffer: 0 });
84
+ * ```
85
+ */
86
+ export declare function interval(ms: number, options?: IntervalOptions): AsyncIterableIterator<number, undefined, void> & {
87
+ [Symbol.dispose]: () => void;
88
+ } & {
89
+ [Symbol.dispose]: () => void;
90
+ };
91
+ //# sourceMappingURL=timing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../src/functions/timing.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM;;EAKjC;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe;;;;EAY7D"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './no-polyfill';
1
+ export * from '#/no-polyfill';
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,31 +1,18 @@
1
- import { invoke, on, once, toAsyncDisposable, toDisposable } from "./no-polyfill.js";
2
- const hasNativeDispose = typeof Symbol.dispose === "symbol" && typeof Symbol.asyncDispose === "symbol";
3
- if (!hasNativeDispose) {
4
- try {
5
- await import("./explicit-resource-management-BSyjFgS-.js").then((n) => n.e);
6
- } catch {
7
- console.warn(
8
- `Symbol.dispose and Symbol.asyncDispose are not available in this environment.
9
- To enable polyfill support, install core-js as a dependency.`
10
- );
11
- }
1
+ import { a as invoke, c as toDisposable, i as once, n as timeout, o as channel, r as on, s as toAsyncDisposable, t as interval } from "./no-polyfill-D3v5MBct.js";
2
+ //#region src/polyfill.ts
3
+ if (!(typeof Symbol.dispose === "symbol" && typeof Symbol.asyncDispose === "symbol")) try {
4
+ await import("core-js/proposals/explicit-resource-management");
5
+ } catch {
6
+ console.warn(`Symbol.dispose and Symbol.asyncDispose are not available in this environment.
7
+ To enable polyfill support, install core-js as a dependency.`);
12
8
  }
13
- const hasNativeWithResolvers = typeof Promise.withResolvers === "function";
14
- if (!hasNativeWithResolvers) {
15
- try {
16
- await import("./with-resolvers-0tPpPN4C.js").then((n) => n.w);
17
- } catch {
18
- console.warn(
19
- `Promise.withResolvers is not available in this environment.
20
- To enable polyfill support, install core-js as a dependency.`
21
- );
22
- }
9
+ if (!(typeof Promise.withResolvers === "function")) try {
10
+ await import("core-js/actual/promise/with-resolvers");
11
+ } catch {
12
+ console.warn(`Promise.withResolvers is not available in this environment.
13
+ To enable polyfill support, install core-js as a dependency.`);
23
14
  }
24
- export {
25
- invoke,
26
- on,
27
- once,
28
- toAsyncDisposable,
29
- toDisposable
30
- };
31
- //# sourceMappingURL=index.js.map
15
+ //#endregion
16
+ export { channel, interval, invoke, on, once, timeout, toAsyncDisposable, toDisposable };
17
+
18
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/polyfill.ts"],"sourcesContent":["const hasNativeDispose =\n\ttypeof Symbol.dispose === \"symbol\" && typeof Symbol.asyncDispose === \"symbol\";\n\nif (!hasNativeDispose) {\n\ttry {\n\t\t//@ts-expect-error It exists\n\t\tawait import(\"core-js/proposals/explicit-resource-management\");\n\t} catch {\n\t\tconsole.warn(\n\t\t\t`Symbol.dispose and Symbol.asyncDispose are not available in this environment.\n\t\t\tTo enable polyfill support, install core-js as a dependency.`,\n\t\t);\n\t}\n}\n\nconst hasNativeWithResolvers = typeof Promise.withResolvers === \"function\";\n\nif (!hasNativeWithResolvers) {\n\ttry {\n\t\t//@ts-expect-error It exists\n\t\tawait import(\"core-js/actual/promise/with-resolvers\");\n\t} catch {\n\t\tconsole.warn(\n\t\t\t`Promise.withResolvers is not available in this environment.\n\t\t\tTo enable polyfill support, install core-js as a dependency.`,\n\t\t);\n\t}\n}\n"],"names":[],"mappings":";AAAA,MAAM,mBACL,OAAO,OAAO,YAAY,YAAY,OAAO,OAAO,iBAAiB;AAEtE,IAAI,CAAC,kBAAkB;AACtB,MAAI;AAEH,UAAM,OAAO,4CAAgD,EAAA,KAAA,OAAA,EAAA,CAAA;AAAA,EAC9D,QAAQ;AACP,YAAQ;AAAA,MACP;AAAA;AAAA,IAAA;AAAA,EAGF;AACD;AAEA,MAAM,yBAAyB,OAAO,QAAQ,kBAAkB;AAEhE,IAAI,CAAC,wBAAwB;AAC5B,MAAI;AAEH,UAAM,OAAO,8BAAuC,EAAA,KAAA,OAAA,EAAA,CAAA;AAAA,EACrD,QAAQ;AACP,YAAQ;AAAA,MACP;AAAA;AAAA,IAAA;AAAA,EAGF;AACD;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/polyfill.ts"],"sourcesContent":["const hasNativeDispose =\n\ttypeof Symbol.dispose === \"symbol\" && typeof Symbol.asyncDispose === \"symbol\";\n\nif (!hasNativeDispose) {\n\ttry {\n\t\t//@ts-expect-error It exists\n\t\tawait import(\"core-js/proposals/explicit-resource-management\");\n\t} catch {\n\t\tconsole.warn(\n\t\t\t`Symbol.dispose and Symbol.asyncDispose are not available in this environment.\n\t\t\tTo enable polyfill support, install core-js as a dependency.`,\n\t\t);\n\t}\n}\n\nconst hasNativeWithResolvers = typeof Promise.withResolvers === \"function\";\n\nif (!hasNativeWithResolvers) {\n\ttry {\n\t\t//@ts-expect-error It exists\n\t\tawait import(\"core-js/actual/promise/with-resolvers\");\n\t} catch {\n\t\tconsole.warn(\n\t\t\t`Promise.withResolvers is not available in this environment.\n\t\t\tTo enable polyfill support, install core-js as a dependency.`,\n\t\t);\n\t}\n}\n"],"mappings":";;AAGA,IAAI,EAFH,OAAO,OAAO,YAAY,YAAY,OAAO,OAAO,iBAAiB,WAGrE,IAAI;CAEH,MAAM,OAAO;AACd,QAAQ;CACP,QAAQ,KACP;gEAED;AACD;AAKD,IAAI,EAF2B,OAAO,QAAQ,kBAAkB,aAG/D,IAAI;CAEH,MAAM,OAAO;AACd,QAAQ;CACP,QAAQ,KACP;gEAED;AACD"}