|
1 | 1 | "use strict";
|
2 |
| -var __assign = (this && this.__assign) || function () { |
3 |
| - __assign = Object.assign || function(t) { |
4 |
| - for (var s, i = 1, n = arguments.length; i < n; i++) { |
5 |
| - s = arguments[i]; |
6 |
| - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) |
7 |
| - t[p] = s[p]; |
8 |
| - } |
9 |
| - return t; |
10 |
| - }; |
11 |
| - return __assign.apply(this, arguments); |
12 |
| -}; |
13 | 2 | var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
14 | 3 | if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
15 | 4 | if (ar || !(i in from)) {
|
@@ -118,8 +107,9 @@ var Sarus = /** @class */ (function () {
|
118 | 107 | */
|
119 | 108 | this.state = "connecting";
|
120 | 109 | // Extract the properties that are passed to the class
|
121 |
| - var url = props.url, binaryType = props.binaryType, protocols = props.protocols, _b = props.eventListeners, eventListeners = _b === void 0 ? constants_1.DEFAULT_EVENT_LISTENERS_OBJECT : _b, reconnectAutomatically = props.reconnectAutomatically, retryProcessTimePeriod = props.retryProcessTimePeriod, // TODO - write a test case to check this |
122 |
| - retryConnectionDelay = props.retryConnectionDelay, _c = props.storageType, storageType = _c === void 0 ? "memory" : _c, _d = props.storageKey, storageKey = _d === void 0 ? "sarus" : _d; |
| 110 | + var url = props.url, binaryType = props.binaryType, protocols = props.protocols, eventListeners = props.eventListeners, // = DEFAULT_EVENT_LISTENERS_OBJECT, |
| 111 | + reconnectAutomatically = props.reconnectAutomatically, retryProcessTimePeriod = props.retryProcessTimePeriod, // TODO - write a test case to check this |
| 112 | + retryConnectionDelay = props.retryConnectionDelay, _b = props.storageType, storageType = _b === void 0 ? "memory" : _b, _c = props.storageKey, storageKey = _c === void 0 ? "sarus" : _c; |
123 | 113 | this.eventListeners = this.auditEventListeners(eventListeners);
|
124 | 114 | // Sets the WebSocket server url for the client to connect to.
|
125 | 115 | this.url = validateWebSocketUrl(url);
|
@@ -260,14 +250,12 @@ var Sarus = /** @class */ (function () {
|
260 | 250 | * @returns {object} The eventListeners object parameter, with any missing events prefilled in
|
261 | 251 | */
|
262 | 252 | Sarus.prototype.auditEventListeners = function (eventListeners) {
|
263 |
| - var defaultEventListeners = { |
264 |
| - open: [], |
265 |
| - message: [], |
266 |
| - error: [], |
267 |
| - close: [], |
| 253 | + return { |
| 254 | + open: (eventListeners === null || eventListeners === void 0 ? void 0 : eventListeners.open) || [], |
| 255 | + message: (eventListeners === null || eventListeners === void 0 ? void 0 : eventListeners.message) || [], |
| 256 | + error: (eventListeners === null || eventListeners === void 0 ? void 0 : eventListeners.error) || [], |
| 257 | + close: (eventListeners === null || eventListeners === void 0 ? void 0 : eventListeners.close) || [], |
268 | 258 | };
|
269 |
| - var mergedEventListeners = __assign(__assign({}, defaultEventListeners), eventListeners); // Type assertion added here |
270 |
| - return mergedEventListeners; |
271 | 259 | };
|
272 | 260 | /**
|
273 | 261 | * Connects the WebSocket client, and attaches event listeners
|
|
0 commit comments