usingCtx.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. function _usingCtx() {
  2. var r = "function" == typeof SuppressedError ? SuppressedError : function (r, n) {
  3. var e = Error();
  4. return e.name = "SuppressedError", e.suppressed = n, e.error = r, e;
  5. },
  6. n = {},
  7. e = [];
  8. function using(r, n) {
  9. if (null != n) {
  10. if (Object(n) !== n) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
  11. if (r) var o = n[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
  12. if (null == o && (o = n[Symbol.dispose || Symbol["for"]("Symbol.dispose")]), "function" != typeof o) throw new TypeError("Property [Symbol.dispose] is not a function.");
  13. e.push({
  14. v: n,
  15. d: o,
  16. a: r
  17. });
  18. }
  19. return n;
  20. }
  21. return {
  22. e: n,
  23. u: using.bind(null, !1),
  24. a: using.bind(null, !0),
  25. d: function d() {
  26. var o = this.e;
  27. function next() {
  28. for (; r = e.pop();) try {
  29. var r,
  30. t = r.d.call(r.v);
  31. if (r.a) return Promise.resolve(t).then(next, err);
  32. } catch (r) {
  33. return err(r);
  34. }
  35. if (o !== n) throw o;
  36. }
  37. function err(e) {
  38. return o = o !== n ? new r(o, e) : e, next();
  39. }
  40. return next();
  41. }
  42. };
  43. }
  44. module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;