Skip to content

Commit

Permalink
Merge pull request #8784 from ZanMinKian/refactor/replace_indexOf
Browse files Browse the repository at this point in the history
refactor(): replace `indexOf` with `includes`
  • Loading branch information
kamilmysliwiec authored Dec 16, 2021
2 parents 80aaecb + 4621fad commit be6c741
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions integration/microservices/e2e/orders-grpc.spec.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit be6c741

Please sign in to comment.