MCPcopy Create free account
hub / github.com/microsoft/tslib / __addDisposableResource

Function __addDisposableResource

tslib.es6.mjs:305–326  ·  view source on GitHub ↗
(env, value, async)

Source from the content-addressed store, hash-verified

303}
304
305export function __addDisposableResource(env, value, async) {
306 if (value !== null && value !== void 0) {
307 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
308 var dispose, inner;
309 if (async) {
310 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
311 dispose = value[Symbol.asyncDispose];
312 }
313 if (dispose === void 0) {
314 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
315 dispose = value[Symbol.dispose];
316 if (async) inner = dispose;
317 }
318 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
319 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
320 env.stack.push({ value: value, dispose: dispose, async: async });
321 }
322 else if (async) {
323 env.stack.push({ async: true });
324 }
325 return value;
326}
327
328var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
329 var e = new Error(message);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…