1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Replace instanceof Array with Array.isArray (#2812)

This commit is contained in:
Michael Telatynski
2022-10-26 17:59:16 +01:00
committed by GitHub
parent 6f2390a765
commit b44787192d
4 changed files with 4 additions and 4 deletions

View File

@@ -217,7 +217,7 @@ const MAC_SET = new Set(MAC_LIST);
const SAS_SET = new Set(SAS_LIST); const SAS_SET = new Set(SAS_LIST);
function intersection<T>(anArray: T[], aSet: Set<T>): T[] { 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 { export enum SasEvent {

View File

@@ -82,7 +82,7 @@ class ExtensionE2EE implements Extension {
const unusedFallbackKeys = data["device_unused_fallback_key_types"] || const unusedFallbackKeys = data["device_unused_fallback_key_types"] ||
data["org.matrix.msc2732.device_unused_fallback_key_types"]; data["org.matrix.msc2732.device_unused_fallback_key_types"];
this.crypto.setNeedsNewFallback( this.crypto.setNeedsNewFallback(
unusedFallbackKeys instanceof Array && Array.isArray(unusedFallbackKeys) &&
!unusedFallbackKeys.includes("signed_curve25519"), !unusedFallbackKeys.includes("signed_curve25519"),
); );
} }

View File

@@ -1482,7 +1482,7 @@ export class SyncApi {
const unusedFallbackKeys = data["device_unused_fallback_key_types"] || const unusedFallbackKeys = data["device_unused_fallback_key_types"] ||
data["org.matrix.msc2732.device_unused_fallback_key_types"]; data["org.matrix.msc2732.device_unused_fallback_key_types"];
this.opts.crypto.setNeedsNewFallback( this.opts.crypto.setNeedsNewFallback(
unusedFallbackKeys instanceof Array && Array.isArray(unusedFallbackKeys) &&
!unusedFallbackKeys.includes("signed_curve25519"), !unusedFallbackKeys.includes("signed_curve25519"),
); );
} }

View File

@@ -232,7 +232,7 @@ export function deepCompare(x: any, y: any): boolean {
} }
// the object algorithm works for Array, but it's sub-optimal. // the object algorithm works for Array, but it's sub-optimal.
if (x instanceof Array) { if (Array.isArray(x)) {
if (x.length !== y.length) { if (x.length !== y.length) {
return false; return false;
} }