Skip to content

Commit 6804c1d

Browse files
authored
Using Array.isArray() instead of instanceof (#237)
1 parent de2063f commit 6804c1d

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
.vscode
23
.DS_Store
34
npm-debug.log
45

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/auth/token-generator.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,7 @@ export class FirebaseTokenGenerator {
250250
if (typeof developerClaims === 'undefined') {
251251
return true;
252252
}
253-
254-
if (typeof developerClaims === 'object' && developerClaims !== null && !(developerClaims instanceof Array)) {
255-
return true;
256-
}
257-
258-
return false;
253+
return validator.isNonNullObject(developerClaims);
259254
}
260255

261256

src/utils/validator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function isBuffer(value: any): boolean {
3333
* @return {boolean} Whether the value is an array or not.
3434
*/
3535
export function isArray(value: any): boolean {
36-
return value instanceof Array;
36+
return Array.isArray(value);
3737
}
3838

3939
/**
@@ -98,7 +98,7 @@ export function isNonEmptyString(value: any): boolean {
9898
* @return {boolean} Whether the value is an object or not.
9999
*/
100100
export function isObject(value: any): boolean {
101-
return typeof value === 'object' && !(value instanceof Array);
101+
return typeof value === 'object' && !isArray(value);
102102
}
103103

104104

0 commit comments

Comments
 (0)