Skip to content

Using Array.isArray() instead of instanceof #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.vscode
.DS_Store
npm-debug.log

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions src/auth/token-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,7 @@ export class FirebaseTokenGenerator {
if (typeof developerClaims === 'undefined') {
return true;
}

if (typeof developerClaims === 'object' && developerClaims !== null && !(developerClaims instanceof Array)) {
return true;
}

return false;
return validator.isNonNullObject(developerClaims);
}


Expand Down
4 changes: 2 additions & 2 deletions src/utils/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function isBuffer(value: any): boolean {
* @return {boolean} Whether the value is an array or not.
*/
export function isArray(value: any): boolean {
return value instanceof Array;
return Array.isArray(value);
}

/**
Expand Down Expand Up @@ -98,7 +98,7 @@ export function isNonEmptyString(value: any): boolean {
* @return {boolean} Whether the value is an object or not.
*/
export function isObject(value: any): boolean {
return typeof value === 'object' && !(value instanceof Array);
return typeof value === 'object' && !isArray(value);
}


Expand Down