Skip to content

Commit

Permalink
Replace instanceof Array with Array.isArray (#2812)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Oct 26, 2022
1 parent 6f2390a commit b447871
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/crypto/verification/SAS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const MAC_SET = new Set(MAC_LIST);
const SAS_SET = new Set(SAS_LIST);

function intersection<T>(anArray: T[], aSet: Set<T>): T[] {
return anArray instanceof Array ? anArray.filter(x => aSet.has(x)) : [];
return Array.isArray(anArray) ? anArray.filter(x => aSet.has(x)) : [];
}

export enum SasEvent {
Expand Down
2 changes: 1 addition & 1 deletion src/sliding-sync-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ExtensionE2EE implements Extension {
const unusedFallbackKeys = data["device_unused_fallback_key_types"] ||
data["org.matrix.msc2732.device_unused_fallback_key_types"];
this.crypto.setNeedsNewFallback(
unusedFallbackKeys instanceof Array &&
Array.isArray(unusedFallbackKeys) &&
!unusedFallbackKeys.includes("signed_curve25519"),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ export class SyncApi {
const unusedFallbackKeys = data["device_unused_fallback_key_types"] ||
data["org.matrix.msc2732.device_unused_fallback_key_types"];
this.opts.crypto.setNeedsNewFallback(
unusedFallbackKeys instanceof Array &&
Array.isArray(unusedFallbackKeys) &&
!unusedFallbackKeys.includes("signed_curve25519"),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export function deepCompare(x: any, y: any): boolean {
}

// the object algorithm works for Array, but it's sub-optimal.
if (x instanceof Array) {
if (Array.isArray(x)) {
if (x.length !== y.length) {
return false;
}
Expand Down

0 comments on commit b447871

Please sign in to comment.