indisposed 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Andrew Ross
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 ADDED
@@ -0,0 +1,225 @@
1
+ # indisposed
2
+
3
+ [![CI](https://github.com/andrew-w-ross/indisposed/actions/workflows/ci.yml/badge.svg)](https://github.com/andrew-w-ross/indisposed/actions/workflows/ci.yml)
4
+ [![npm version](https://badge.fury.io/js/indisposed.svg)](https://www.npmjs.com/package/indisposed)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ The missing utilities for JavaScript's [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management) (`using` and `await using` declarations).
8
+
9
+ ## Features
10
+
11
+ - ๐Ÿงน **Resource Management** - Convert any resource into a disposable with `toDisposable` and `toAsyncDisposable`
12
+ - ๐ŸŽง **Event Handlers** - Transform event emitters into disposable iterators with `on` and promises with `once`
13
+ - ๐Ÿ”’ **Scoped Execution** - Execute code with automatic cleanup using `invoke`
14
+ - ๐Ÿ“ฆ **Zero Dependencies** - Lightweight and focused
15
+ - ๐Ÿ”ง **TypeScript First** - Full type safety and inference
16
+ - ๐ŸŒณ **Tree Shakeable** - Import only what you need
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install indisposed
22
+ # or
23
+ yarn add indisposed
24
+ # or
25
+ pnpm add indisposed
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```typescript
31
+ import { toAsyncDisposable, once, invoke } from "indisposed";
32
+ import { WebSocketServer } from "ws";
33
+
34
+ // Automatic cleanup with await using
35
+ {
36
+ await using wss = await invoke(async () => {
37
+ const wss = toAsyncDisposable(
38
+ new WebSocketServer({ host: "127.0.0.1", port: 0 }),
39
+ (wss) =>
40
+ new Promise((resolve, reject) => {
41
+ wss.close((err) => {
42
+ if (err) return reject(err);
43
+ resolve(undefined);
44
+ });
45
+ }),
46
+ );
47
+
48
+ using listening = once(wss, "listening");
49
+ using error = once(wss, "error", true);
50
+
51
+ await Promise.race([listening, error]);
52
+
53
+ return wss;
54
+ });
55
+
56
+ console.log("Server ready at", wss.address());
57
+ // ... handle connections ...
58
+ }
59
+ // wss is automatically closed once the scope ends
60
+ ```
61
+
62
+ ## API Reference
63
+
64
+ ### `toDisposable<T>(value, disposeFn)`
65
+
66
+ Make any object disposable by adding a `Symbol.dispose` method.
67
+
68
+ ```typescript
69
+ import { toDisposable } from "indisposed";
70
+
71
+ const resource = toDisposable({ handle: 123 }, (r) =>
72
+ console.log(`Closing handle ${r.handle}`),
73
+ );
74
+
75
+ {
76
+ using r = resource;
77
+ // use resource
78
+ } // automatically disposed here
79
+ ```
80
+
81
+ ### `toAsyncDisposable<T>(value, disposeFn)`
82
+
83
+ Make any object async disposable by adding a `Symbol.asyncDispose` method.
84
+
85
+ ```typescript
86
+ import { toAsyncDisposable } from "indisposed";
87
+
88
+ const resource = toAsyncDisposable(
89
+ { connection: db },
90
+ async (r) => await r.connection.close(),
91
+ );
92
+
93
+ {
94
+ await using r = resource;
95
+ // use resource
96
+ } // automatically disposed here
97
+ ```
98
+
99
+ ### `once(emitter, event, rejects?)`
100
+
101
+ Create a disposable promise that resolves/rejects when an event fires once.
102
+
103
+ The promise result is automatically unpacked based on the handler signature:
104
+
105
+ - 0 parameters โ†’ `undefined`
106
+ - 1 parameter โ†’ the single value
107
+ - 2+ parameters โ†’ array of values
108
+
109
+ ```typescript
110
+ import { once } from "indisposed";
111
+
112
+ {
113
+ using promise = once(server, "listening");
114
+ await promise; // waits for 'listening' event
115
+ } // removes listener if not yet fired
116
+
117
+ // Single parameter events return the value directly
118
+ {
119
+ using data = once(socket, "message");
120
+ const message = await data; // string (not [string])
121
+ }
122
+
123
+ // Multiple parameters return as array
124
+ {
125
+ using result = once(emitter, "result");
126
+ const [status, data] = await result; // [number, object]
127
+ }
128
+
129
+ // Handle errors
130
+ {
131
+ using error = once(server, "error", true);
132
+ await error; // rejects if 'error' event fires
133
+ }
134
+ ```
135
+
136
+ ### `on(emitter, event, maxBuffer?)`
137
+
138
+ Create a disposable async iterator for multiple events.
139
+
140
+ Yielded values are automatically unpacked based on the handler signature:
141
+
142
+ - 0 parameters โ†’ `undefined`
143
+ - 1 parameter โ†’ the single value
144
+ - 2+ parameters โ†’ array of values
145
+
146
+ ```typescript
147
+ import { on } from "indisposed";
148
+
149
+ // Single parameter events yield values directly
150
+ {
151
+ using events = on(emitter, "data");
152
+
153
+ for await (const data of events) {
154
+ console.log(data); // string (not [string])
155
+ if (shouldStop) break;
156
+ }
157
+ } // automatically removes listener
158
+
159
+ // Multiple parameters yield as array
160
+ {
161
+ using positions = on(emitter, "move");
162
+
163
+ for await (const [x, y] of positions) {
164
+ console.log(`Position: ${x}, ${y}`);
165
+ }
166
+ }
167
+ ```
168
+
169
+ ### `invoke<T>(fn)`
170
+
171
+ Immediately invoke a function - useful for scoping resources.
172
+
173
+ ```typescript
174
+ import { invoke } from "indisposed";
175
+
176
+ const result = invoke(() => {
177
+ using resource1 = getResource1();
178
+ using resource2 = getResource2();
179
+
180
+ return processResources(resource1, resource2);
181
+ }); // resources disposed in reverse order
182
+ ```
183
+
184
+ ## Polyfills
185
+
186
+ By default, `indisposed` automatically polyfills `Symbol.dispose` and `Symbol.asyncDispose` when:
187
+
188
+ 1. The environment doesn't natively support these symbols
189
+ 2. `core-js` is installed as a peer dependency
190
+
191
+ The polyfill is smart and only applies when needed. If your environment already supports explicit resource management or you don't have `core-js` installed, no polyfill is loaded.
192
+
193
+ For environments that already support these symbols, you can skip the polyfill check entirely using the no-polyfill entry point:
194
+
195
+ ```typescript
196
+ import { toDisposable } from "indisposed/no-polyfill";
197
+ ```
198
+
199
+ Or configure your bundler to alias the main export:
200
+
201
+ ```json
202
+ {
203
+ "alias": {
204
+ "indisposed": "indisposed/no-polyfill"
205
+ }
206
+ }
207
+ ```
208
+
209
+ ## Requirements
210
+
211
+ - Node.js >= 22.20.0
212
+ - TypeScript >= 5.2.0 (for `using` declarations support)
213
+
214
+ ## License
215
+
216
+ MIT ยฉ [andrew-w-ross](https://github.com/andrew-w-ross)
217
+
218
+ ## Contributing
219
+
220
+ Contributions are welcome! Please feel free to submit a Pull Request.
221
+
222
+ ## Resources
223
+
224
+ - [TC39 Explicit Resource Management Proposal](https://github.com/tc39/proposal-explicit-resource-management)
225
+ - [TypeScript 5.2 Release Notes](https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#using-declarations-and-explicit-resource-management)
@@ -0,0 +1,448 @@
1
+ import { r as N, a as x, b as le, c as Pe, d as ir, e as qe, f as ve, g as ur, h as Re, i as B, j as cr, k as me, l as ge, m as Te, n as De, o as fe, p as pe, q as de, s as we, t as lr, u as G, v as Ae, w as ke, x as Ce, y as D, z as vr, A, B as U, C as fr, D as je, E as Ke, F as pr, G as dr, H as ye, I as Se, J as be, K as Ne, L as xe, M as Be, N as Ge, O as _e } from "./path-CtSS7upm.js";
2
+ var _r = {}, Er = {}, Ir = {}, Y, Or;
3
+ function Ue() {
4
+ if (Or) return Y;
5
+ Or = 1;
6
+ var t = N();
7
+ return Y = !t(function() {
8
+ function r() {
9
+ }
10
+ return r.prototype.constructor = null, Object.getPrototypeOf(new r()) !== r.prototype;
11
+ }), Y;
12
+ }
13
+ var H, hr;
14
+ function yr() {
15
+ if (hr) return H;
16
+ hr = 1;
17
+ var t = x(), r = ir(), a = Pe(), s = le(), e = Ue(), n = s("IE_PROTO"), i = Object, u = i.prototype;
18
+ return H = e ? i.getPrototypeOf : function(l) {
19
+ var v = a(l);
20
+ if (t(v, n)) return v[n];
21
+ var o = v.constructor;
22
+ return r(o) && v instanceof o ? o.prototype : v instanceof i ? u : null;
23
+ }, H;
24
+ }
25
+ var L = {}, z, Pr;
26
+ function Fe() {
27
+ if (Pr) return z;
28
+ Pr = 1;
29
+ var t = qe(), r = ve();
30
+ return z = Object.keys || function(s) {
31
+ return t(s, r);
32
+ }, z;
33
+ }
34
+ var qr;
35
+ function We() {
36
+ if (qr) return L;
37
+ qr = 1;
38
+ var t = ur(), r = Re(), a = B(), s = cr(), e = me(), n = Fe();
39
+ return L.f = t && !r ? Object.defineProperties : function(u, l) {
40
+ s(u);
41
+ for (var v = e(l), o = n(l), _ = o.length, c = 0, h; _ > c; ) a.f(u, h = o[c++], v[h]);
42
+ return u;
43
+ }, L;
44
+ }
45
+ var V, Rr;
46
+ function Sr() {
47
+ if (Rr) return V;
48
+ Rr = 1;
49
+ var t = cr(), r = We(), a = ve(), s = De(), e = ge(), n = Te(), i = le(), u = ">", l = "<", v = "prototype", o = "script", _ = i("IE_PROTO"), c = function() {
50
+ }, h = function(p) {
51
+ return l + o + u + p + l + "/" + o + u;
52
+ }, y = function(p) {
53
+ p.write(h("")), p.close();
54
+ var S = p.parentWindow.Object;
55
+ return p = null, S;
56
+ }, q = function() {
57
+ var p = n("iframe"), S = "java" + o + ":", E;
58
+ return p.style.display = "none", e.appendChild(p), p.src = String(S), E = p.contentWindow.document, E.open(), E.write(h("document.F=Object")), E.close(), E.F;
59
+ }, d, P = function() {
60
+ try {
61
+ d = new ActiveXObject("htmlfile");
62
+ } catch {
63
+ }
64
+ P = typeof document < "u" ? document.domain && d ? y(d) : q() : y(d);
65
+ for (var p = a.length; p--; ) delete P[v][a[p]];
66
+ return P();
67
+ };
68
+ return s[_] = !0, V = Object.create || function(S, E) {
69
+ var I;
70
+ return S !== null ? (c[v] = t(S), I = new c(), c[v] = null, I[_] = S) : I = P(), E === void 0 ? I : r.f(I, E);
71
+ }, V;
72
+ }
73
+ var J, mr;
74
+ function Me() {
75
+ if (mr) return J;
76
+ mr = 1;
77
+ var t = fe(), r = Error, a = t("".replace), s = (function(i) {
78
+ return String(new r(i).stack);
79
+ })("zxcasd"), e = /\n\s*at [^:]*:[^\n]*/, n = e.test(s);
80
+ return J = function(i, u) {
81
+ if (n && typeof i == "string" && !r.prepareStackTrace)
82
+ for (; u--; ) i = a(i, e, "");
83
+ return i;
84
+ }, J;
85
+ }
86
+ var X, gr;
87
+ function $e() {
88
+ if (gr) return X;
89
+ gr = 1;
90
+ var t = N(), r = pe();
91
+ return X = !t(function() {
92
+ var a = new Error("a");
93
+ return "stack" in a ? (Object.defineProperty(a, "stack", r(1, 7)), a.stack !== 7) : !0;
94
+ }), X;
95
+ }
96
+ var Q, Tr;
97
+ function Ye() {
98
+ if (Tr) return Q;
99
+ Tr = 1;
100
+ var t = de(), r = Me(), a = $e(), s = Error.captureStackTrace;
101
+ return Q = function(e, n, i, u) {
102
+ a && (s ? s(e, n) : t(e, "stack", r(i, u)));
103
+ }, Q;
104
+ }
105
+ var Z, Dr;
106
+ function He() {
107
+ if (Dr) return Z;
108
+ Dr = 1;
109
+ var t = we(), r = String;
110
+ return Z = function(a) {
111
+ if (t(a) === "Symbol") throw new TypeError("Cannot convert a Symbol value to a string");
112
+ return r(a);
113
+ }, Z;
114
+ }
115
+ var rr, wr;
116
+ function Le() {
117
+ if (wr) return rr;
118
+ wr = 1;
119
+ var t = He();
120
+ return rr = function(r, a) {
121
+ return r === void 0 ? arguments.length < 2 ? "" : a : t(r);
122
+ }, rr;
123
+ }
124
+ var Ar;
125
+ function ze() {
126
+ if (Ar) return Ir;
127
+ Ar = 1;
128
+ var t = lr(), r = G(), a = Ae(), s = yr(), e = ke(), n = Ce(), i = Sr(), u = de(), l = pe(), v = Ye(), o = Le(), _ = D(), c = N(), h = vr(), y = r.SuppressedError, q = _("toStringTag"), d = Error, P = !!y && y.length !== 3, p = !!y && c(function() {
129
+ return new y(1, 2, 3, { cause: 4 }).cause === 4;
130
+ }), S = P || p, E = function(T, g, f) {
131
+ var R = a(I, this), b;
132
+ return e ? b = S && (!R || s(this) === I) ? new y() : e(new d(), R ? s(this) : I) : (b = R ? this : i(I), u(b, q, "Error")), f !== void 0 && u(b, "message", o(f)), v(b, E, b.stack, 1), u(b, "error", T), u(b, "suppressed", g), b;
133
+ };
134
+ e ? e(E, d) : n(E, d, { name: !0 });
135
+ var I = E.prototype = S ? y.prototype : i(d.prototype, {
136
+ constructor: l(1, E),
137
+ message: l(1, ""),
138
+ name: l(1, "SuppressedError")
139
+ });
140
+ return S && !h && (I.constructor = E), t({ global: !0, constructor: !0, arity: 3, forced: S }, {
141
+ SuppressedError: E
142
+ }), Ir;
143
+ }
144
+ var kr;
145
+ function Ve() {
146
+ return kr || (kr = 1, ze()), Er;
147
+ }
148
+ var Cr = {}, jr = {}, er, Kr;
149
+ function Ee() {
150
+ if (Kr) return er;
151
+ Kr = 1;
152
+ var t = A();
153
+ return er = function(r, a, s) {
154
+ for (var e in a) t(r, e, a[e], s);
155
+ return r;
156
+ }, er;
157
+ }
158
+ var tr, Nr;
159
+ function Ie() {
160
+ if (Nr) return tr;
161
+ Nr = 1;
162
+ var t = U(), r = fr(), a = fe(), s = je(), e = cr(), n = pr(), i = Ke(), u = dr(), l = D(), v = l("asyncDispose"), o = l("dispose"), _ = a([].push), c = function(y, q) {
163
+ if (q === "async-dispose") {
164
+ var d = u(y, v);
165
+ return d !== void 0 || (d = u(y, o), d === void 0) ? d : function() {
166
+ var P = this, p = t("Promise");
167
+ return new p(function(S) {
168
+ r(d, P), S(void 0);
169
+ });
170
+ };
171
+ }
172
+ return u(y, o);
173
+ }, h = function(y, q, d) {
174
+ return arguments.length < 3 && !i(y) && (d = n(c(e(y), q))), d === void 0 ? function() {
175
+ } : s(d, y);
176
+ };
177
+ return tr = function(y, q, d, P) {
178
+ var p;
179
+ if (arguments.length < 4) {
180
+ if (i(q) && d === "sync-dispose") return;
181
+ p = h(q, d);
182
+ } else
183
+ p = h(void 0, d, P);
184
+ _(y.stack, p);
185
+ }, tr;
186
+ }
187
+ var xr;
188
+ function Je() {
189
+ if (xr) return jr;
190
+ xr = 1;
191
+ var t = lr(), r = ur(), a = U(), s = pr(), e = ye(), n = A(), i = Ee(), u = Se(), l = D(), v = be(), o = Ie(), _ = Ne(), c = a("Promise"), h = a("SuppressedError"), y = ReferenceError, q = l("asyncDispose"), d = l("toStringTag"), P = "AsyncDisposableStack", p = v.set, S = v.getterFor(P), E = "async-dispose", I = "disposed", k = "pending", T = function(b) {
192
+ var O = S(b);
193
+ if (O.state === I) throw new y(P + " already disposed");
194
+ return O;
195
+ }, g = function() {
196
+ p(e(this, f), {
197
+ type: P,
198
+ state: k,
199
+ stack: []
200
+ }), r || (this.disposed = !1);
201
+ }, f = g.prototype;
202
+ i(f, {
203
+ disposeAsync: function() {
204
+ var O = this;
205
+ return new c(function(m, C) {
206
+ var w = S(O);
207
+ if (w.state === I) return m(void 0);
208
+ w.state = I, r || (O.disposed = !0);
209
+ var F = w.stack, W = F.length, M = !1, j, br = function(K) {
210
+ M ? j = new h(K, j) : (M = !0, j = K), $();
211
+ }, $ = function() {
212
+ if (W) {
213
+ var K = F[--W];
214
+ F[W] = null;
215
+ try {
216
+ c.resolve(K()).then($, br);
217
+ } catch (he) {
218
+ br(he);
219
+ }
220
+ } else
221
+ w.stack = null, M ? C(j) : m(void 0);
222
+ };
223
+ $();
224
+ });
225
+ },
226
+ use: function(O) {
227
+ return o(T(this), O, E), O;
228
+ },
229
+ adopt: function(O, m) {
230
+ var C = T(this);
231
+ return s(m), o(C, void 0, E, function() {
232
+ return m(O);
233
+ }), O;
234
+ },
235
+ defer: function(O) {
236
+ var m = T(this);
237
+ s(O), o(m, void 0, E, O);
238
+ },
239
+ move: function() {
240
+ var O = T(this), m = new g();
241
+ return S(m).stack = O.stack, O.stack = [], O.state = I, r || (this.disposed = !0), m;
242
+ }
243
+ }), r && u(f, "disposed", {
244
+ configurable: !0,
245
+ get: function() {
246
+ return S(this).state === I;
247
+ }
248
+ }), n(f, q, f.disposeAsync, { name: "disposeAsync" }), n(f, d, P, { nonWritable: !0 });
249
+ var R = _ && _ < 136;
250
+ return t({ global: !0, constructor: !0, forced: R }, {
251
+ AsyncDisposableStack: g
252
+ }), jr;
253
+ }
254
+ var Br;
255
+ function Xe() {
256
+ return Br || (Br = 1, Je()), Cr;
257
+ }
258
+ var Gr = {}, Ur = {}, ar, Fr;
259
+ function Qe() {
260
+ if (Fr) return ar;
261
+ Fr = 1;
262
+ var t = G(), r = xe(), a = ir(), s = Sr(), e = yr(), n = A(), i = D(), u = vr(), l = "USE_FUNCTION_CONSTRUCTOR", v = i("asyncIterator"), o = t.AsyncIterator, _ = r.AsyncIteratorPrototype, c, h;
263
+ if (_)
264
+ c = _;
265
+ else if (a(o))
266
+ c = o.prototype;
267
+ else if (r[l] || t[l])
268
+ try {
269
+ h = e(e(e(Function("return async function*(){}()")()))), e(h) === Object.prototype && (c = h);
270
+ } catch {
271
+ }
272
+ return c ? u && (c = s(c)) : c = {}, a(c[v]) || n(c, v, function() {
273
+ return this;
274
+ }), ar = c, ar;
275
+ }
276
+ var Wr;
277
+ function Ze() {
278
+ if (Wr) return Ur;
279
+ Wr = 1;
280
+ var t = fr(), r = A(), a = U(), s = dr(), e = x(), n = D(), i = Qe(), u = n("asyncDispose"), l = a("Promise");
281
+ return e(i, u) || r(i, u, function() {
282
+ var v = this;
283
+ return new l(function(o, _) {
284
+ var c = s(v, "return");
285
+ c ? l.resolve(t(c, v)).then(function() {
286
+ o(void 0);
287
+ }, _) : o(void 0);
288
+ });
289
+ }), Ur;
290
+ }
291
+ var Mr;
292
+ function rt() {
293
+ return Mr || (Mr = 1, Ze()), Gr;
294
+ }
295
+ var $r = {}, Yr = {}, Hr;
296
+ function et() {
297
+ if (Hr) return Yr;
298
+ Hr = 1;
299
+ var t = lr(), r = ur(), a = U(), s = pr(), e = ye(), n = A(), i = Ee(), u = Se(), l = D(), v = be(), o = Ie(), _ = a("SuppressedError"), c = ReferenceError, h = l("dispose"), y = l("toStringTag"), q = "DisposableStack", d = v.set, P = v.getterFor(q), p = "sync-dispose", S = "disposed", E = "pending", I = function(g) {
300
+ var f = P(g);
301
+ if (f.state === S) throw new c(q + " already disposed");
302
+ return f;
303
+ }, k = function() {
304
+ d(e(this, T), {
305
+ type: q,
306
+ state: E,
307
+ stack: []
308
+ }), r || (this.disposed = !1);
309
+ }, T = k.prototype;
310
+ return i(T, {
311
+ dispose: function() {
312
+ var f = P(this);
313
+ if (f.state !== S) {
314
+ f.state = S, r || (this.disposed = !0);
315
+ for (var R = f.stack, b = R.length, O = !1, m; b; ) {
316
+ var C = R[--b];
317
+ R[b] = null;
318
+ try {
319
+ C();
320
+ } catch (w) {
321
+ O ? m = new _(w, m) : (O = !0, m = w);
322
+ }
323
+ }
324
+ if (f.stack = null, O) throw m;
325
+ }
326
+ },
327
+ use: function(f) {
328
+ return o(I(this), f, p), f;
329
+ },
330
+ adopt: function(f, R) {
331
+ var b = I(this);
332
+ return s(R), o(b, void 0, p, function() {
333
+ R(f);
334
+ }), f;
335
+ },
336
+ defer: function(f) {
337
+ var R = I(this);
338
+ s(f), o(R, void 0, p, f);
339
+ },
340
+ move: function() {
341
+ var f = I(this), R = new k();
342
+ return P(R).stack = f.stack, f.stack = [], f.state = S, r || (this.disposed = !0), R;
343
+ }
344
+ }), r && u(T, "disposed", {
345
+ configurable: !0,
346
+ get: function() {
347
+ return P(this).state === S;
348
+ }
349
+ }), n(T, h, T.dispose, { name: "dispose" }), n(T, y, q, { nonWritable: !0 }), t({ global: !0, constructor: !0 }, {
350
+ DisposableStack: k
351
+ }), Yr;
352
+ }
353
+ var Lr;
354
+ function tt() {
355
+ return Lr || (Lr = 1, et()), $r;
356
+ }
357
+ var zr = {}, Vr = {}, nr, Jr;
358
+ function at() {
359
+ if (Jr) return nr;
360
+ Jr = 1;
361
+ var t = N(), r = ir(), a = Be(), s = Sr(), e = yr(), n = A(), i = D(), u = vr(), l = i("iterator"), v = !1, o, _, c;
362
+ [].keys && (c = [].keys(), "next" in c ? (_ = e(e(c)), _ !== Object.prototype && (o = _)) : v = !0);
363
+ var h = !a(o) || t(function() {
364
+ var y = {};
365
+ return o[l].call(y) !== y;
366
+ });
367
+ return h ? o = {} : u && (o = s(o)), r(o[l]) || n(o, l, function() {
368
+ return this;
369
+ }), nr = {
370
+ IteratorPrototype: o,
371
+ BUGGY_SAFARI_ITERATORS: v
372
+ }, nr;
373
+ }
374
+ var Xr;
375
+ function nt() {
376
+ if (Xr) return Vr;
377
+ Xr = 1;
378
+ var t = fr(), r = A(), a = dr(), s = x(), e = D(), n = at().IteratorPrototype, i = e("dispose");
379
+ return s(n, i) || r(n, i, function() {
380
+ var u = a(this, "return");
381
+ u && t(u, this);
382
+ }), Vr;
383
+ }
384
+ var Qr;
385
+ function st() {
386
+ return Qr || (Qr = 1, nt()), zr;
387
+ }
388
+ var Zr = {}, re = {}, sr = {}, ee;
389
+ function ot() {
390
+ if (ee) return sr;
391
+ ee = 1;
392
+ var t = D();
393
+ return sr.f = t, sr;
394
+ }
395
+ var or, te;
396
+ function Oe() {
397
+ if (te) return or;
398
+ te = 1;
399
+ var t = Ge(), r = x(), a = ot(), s = B().f;
400
+ return or = function(e) {
401
+ var n = t.Symbol || (t.Symbol = {});
402
+ r(n, e) || s(n, e, {
403
+ value: a.f(e)
404
+ });
405
+ }, or;
406
+ }
407
+ var ae;
408
+ function it() {
409
+ if (ae) return re;
410
+ ae = 1;
411
+ var t = G(), r = Oe(), a = B().f, s = _e().f, e = t.Symbol;
412
+ if (r("asyncDispose"), e) {
413
+ var n = s(e, "asyncDispose");
414
+ n.enumerable && n.configurable && n.writable && a(e, "asyncDispose", { value: n.value, enumerable: !1, configurable: !1, writable: !1 });
415
+ }
416
+ return re;
417
+ }
418
+ var ne;
419
+ function ut() {
420
+ return ne || (ne = 1, it()), Zr;
421
+ }
422
+ var se = {}, oe = {}, ie;
423
+ function ct() {
424
+ if (ie) return oe;
425
+ ie = 1;
426
+ var t = G(), r = Oe(), a = B().f, s = _e().f, e = t.Symbol;
427
+ if (r("dispose"), e) {
428
+ var n = s(e, "dispose");
429
+ n.enumerable && n.configurable && n.writable && a(e, "dispose", { value: n.value, enumerable: !1, configurable: !1, writable: !1 });
430
+ }
431
+ return oe;
432
+ }
433
+ var ue;
434
+ function lt() {
435
+ return ue || (ue = 1, ct()), se;
436
+ }
437
+ var ce;
438
+ function vt() {
439
+ return ce || (ce = 1, Ve(), Xe(), rt(), tt(), st(), ut(), lt()), _r;
440
+ }
441
+ vt();
442
+ const pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
443
+ __proto__: null
444
+ }, Symbol.toStringTag, { value: "Module" }));
445
+ export {
446
+ pt as e
447
+ };
448
+ //# sourceMappingURL=explicit-resource-management-C54qWHAr.js.map