Skip to content

Commit

Permalink
fix: add hasOwnProperty (#259)
Browse files Browse the repository at this point in the history
Co-authored-by: Денис Котелев <d.kotelev@carprice.ru>
  • Loading branch information
hardsmile98 and Денис Котелев authored Oct 4, 2023
1 parent cabda81 commit acf1db5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/centrifuge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,15 @@ export class Centrifuge extends (EventEmitter as new () => TypedEventEmitter<Cli
this._transports = this._endpoint;
this._emulation = true;
for (const i in this._transports) {
const transportConfig = this._transports[i];
if (!transportConfig.endpoint || !transportConfig.transport) {
throw new Error('malformed transport configuration');
}
const transportName = transportConfig.transport;
if (['websocket', 'http_stream', 'sse', 'sockjs', 'webtransport'].indexOf(transportName) < 0) {
throw new Error('unsupported transport name: ' + transportName);
if (this._transports.hasOwnProperty(i)) {
const transportConfig = this._transports[i];
if (!transportConfig.endpoint || !transportConfig.transport) {
throw new Error('malformed transport configuration');
}
const transportName = transportConfig.transport;
if (['websocket', 'http_stream', 'sse', 'sockjs', 'webtransport'].indexOf(transportName) < 0) {
throw new Error('unsupported transport name: ' + transportName);
}
}
}
} else {
Expand Down Expand Up @@ -777,7 +779,9 @@ export class Centrifuge extends (EventEmitter as new () => TypedEventEmitter<Cli
if (optimistic) {
const subscribeCommands: any[] = self._sendSubscribeCommands(true, true);
for (const i in subscribeCommands) {
initialCommands.push(subscribeCommands[i]);
if (subscribeCommands.hasOwnProperty(i)) {
initialCommands.push(subscribeCommands[i]);
}
}
}
}
Expand Down

0 comments on commit acf1db5

Please sign in to comment.