Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(): replace indexOf with includes #8784

Merged
merged 1 commit into from Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration/microservices/e2e/orders-grpc.spec.ts
Expand Up @@ -134,7 +134,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
if (!String(err).toLowerCase().includes('cancelled')) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
if (!String(err).toLowerCase().includes('cancelled')) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand Down
4 changes: 2 additions & 2 deletions integration/microservices/e2e/sum-grpc.spec.ts
Expand Up @@ -78,7 +78,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
if (!String(err).toLowerCase().includes('cancelled')) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand All @@ -100,7 +100,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
if (!String(err).toLowerCase().includes('cancelled')) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/common/pipes/parse-enum.pipe.ts
Expand Up @@ -59,6 +59,6 @@ export class ParseEnumPipe<T = any> implements PipeTransform<T> {
const enumValues = Object.keys(this.enumType).map(
item => this.enumType[item],
);
return enumValues.indexOf(value) >= 0;
return enumValues.includes(value);
}
}
3 changes: 1 addition & 2 deletions packages/microservices/server/server-mqtt.ts
Expand Up @@ -191,8 +191,7 @@ export class ServerMqtt extends Server implements CustomTransportStrategy {

for (const [key, value] of this.messageHandlers) {
if (
key.indexOf(MQTT_WILDCARD_SINGLE) === -1 &&
key.indexOf(MQTT_WILDCARD_ALL) === -1
!key.includes(MQTT_WILDCARD_SINGLE) && !key.includes(MQTT_WILDCARD_ALL)
) {
continue;
}
Expand Down