Skip to content

Commit f9d4b09

Browse files
committed
[minor] Use Array.prototype.includes()
Use `Array.prototype.includes()` instead of `Array.prototype.indexOf()`.
1 parent 63adb73 commit f9d4b09

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/websocket.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class WebSocket extends EventEmitter {
8787
}
8888

8989
set binaryType(type) {
90-
if (constants.BINARY_TYPES.indexOf(type) < 0) return;
90+
if (!constants.BINARY_TYPES.includes(type)) return;
9191

9292
this._binaryType = type;
9393

@@ -449,7 +449,7 @@ function initAsClient(address, protocols, options) {
449449
}
450450
);
451451

452-
if (protocolVersions.indexOf(options.protocolVersion) === -1) {
452+
if (!protocolVersions.includes(options.protocolVersion)) {
453453
throw new RangeError(
454454
`Unsupported protocol version: ${options.protocolVersion} ` +
455455
`(supported versions: ${protocolVersions.join(', ')})`
@@ -588,7 +588,7 @@ function initAsClient(address, protocols, options) {
588588
protError = 'Server sent a subprotocol but none was requested';
589589
} else if (protocols && !serverProt) {
590590
protError = 'Server sent no subprotocol';
591-
} else if (serverProt && protList.indexOf(serverProt) === -1) {
591+
} else if (serverProt && !protList.includes(serverProt)) {
592592
protError = 'Server sent an invalid subprotocol';
593593
}
594594

0 commit comments

Comments
 (0)