@azteam/rabbitmq-async 1.0.230 → 1.0.233

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/lib/Provider.js CHANGED
@@ -23,9 +23,8 @@ var Provider = /*#__PURE__*/function () {
23
23
  this.connections = {};
24
24
  this.configs = {};
25
25
  if (Array.isArray(configs)) {
26
- configs.map(function (config) {
26
+ configs.forEach(function (config) {
27
27
  _this.configs[config.name] = config;
28
- return true;
29
28
  });
30
29
  } else {
31
30
  this.configs.main = configs;
@@ -68,6 +67,51 @@ var Provider = /*#__PURE__*/function () {
68
67
  }
69
68
  return waitAllConnection;
70
69
  }()
70
+ }, {
71
+ key: "closeAll",
72
+ value: function () {
73
+ var _closeAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
74
+ var _this3 = this;
75
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
76
+ while (1) switch (_context3.prev = _context3.next) {
77
+ case 0:
78
+ _context3.next = 2;
79
+ return Promise.all(Object.keys(this.connections).map(/*#__PURE__*/function () {
80
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(keyConfig) {
81
+ var connection;
82
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
83
+ while (1) switch (_context2.prev = _context2.next) {
84
+ case 0:
85
+ connection = _this3.connections[keyConfig];
86
+ if (!connection) {
87
+ _context2.next = 4;
88
+ break;
89
+ }
90
+ _context2.next = 4;
91
+ return connection.close();
92
+ case 4:
93
+ case "end":
94
+ return _context2.stop();
95
+ }
96
+ }, _callee2);
97
+ }));
98
+ return function (_x) {
99
+ return _ref.apply(this, arguments);
100
+ };
101
+ }()));
102
+ case 2:
103
+ this.connections = {};
104
+ case 3:
105
+ case "end":
106
+ return _context3.stop();
107
+ }
108
+ }, _callee3, this);
109
+ }));
110
+ function closeAll() {
111
+ return _closeAll.apply(this, arguments);
112
+ }
113
+ return closeAll;
114
+ }()
71
115
  }]);
72
116
  }();
73
117
  var _default = exports["default"] = Provider;