Skip to content

Commit b447871

Browse files
authored
Replace instanceof Array with Array.isArray (#2812)
1 parent 6f2390a commit b447871

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/crypto/verification/SAS.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const MAC_SET = new Set(MAC_LIST);
217217
const SAS_SET = new Set(SAS_LIST);
218218

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

223223
export enum SasEvent {

src/sliding-sync-sdk.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ExtensionE2EE implements Extension {
8282
const unusedFallbackKeys = data["device_unused_fallback_key_types"] ||
8383
data["org.matrix.msc2732.device_unused_fallback_key_types"];
8484
this.crypto.setNeedsNewFallback(
85-
unusedFallbackKeys instanceof Array &&
85+
Array.isArray(unusedFallbackKeys) &&
8686
!unusedFallbackKeys.includes("signed_curve25519"),
8787
);
8888
}

src/sync.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ export class SyncApi {
14821482
const unusedFallbackKeys = data["device_unused_fallback_key_types"] ||
14831483
data["org.matrix.msc2732.device_unused_fallback_key_types"];
14841484
this.opts.crypto.setNeedsNewFallback(
1485-
unusedFallbackKeys instanceof Array &&
1485+
Array.isArray(unusedFallbackKeys) &&
14861486
!unusedFallbackKeys.includes("signed_curve25519"),
14871487
);
14881488
}

src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export function deepCompare(x: any, y: any): boolean {
232232
}
233233

234234
// the object algorithm works for Array, but it's sub-optimal.
235-
if (x instanceof Array) {
235+
if (Array.isArray(x)) {
236236
if (x.length !== y.length) {
237237
return false;
238238
}

0 commit comments

Comments
 (0)