Skip to content
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

Align DataSnapshot methods to @firebase/database DataSnapshot #926

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Removed unneeded use of _.isArray with _.isObjectLike
  • Loading branch information
rhodgkins committed Aug 12, 2021
commit f08be255737451af28e80cdcda1fe33aed7000e5
8 changes: 4 additions & 4 deletions src/v1/providers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ export class DataSnapshot {
// Null value
return false;
}
if ((_.isObjectLike(val) || _.isArray(val)) && _.isEmpty(val)) {
if (_.isObjectLike(val) && _.isEmpty(val)) {
// Empty object/array
return false;
}
Expand Down Expand Up @@ -521,7 +521,7 @@ export class DataSnapshot {
*/
forEach(action: (a: DataSnapshot) => boolean | void): boolean {
const val = this.val();
if (_.isObjectLike(val) || _.isArray(val)) {
if (_.isObjectLike(val)) {
return _.some(
val,
(value, key: string) => action(this.child(key)) === true
Expand Down Expand Up @@ -555,7 +555,7 @@ export class DataSnapshot {
*/
hasChildren(): boolean {
const val = this.val();
return (_.isObjectLike(val) || _.isArray(val)) && !_.isEmpty(val);
return _.isObjectLike(val) && !_.isEmpty(val);
}

/**
Expand All @@ -565,7 +565,7 @@ export class DataSnapshot {
*/
numChildren(): number {
const val = this.val();
return _.isObjectLike(val) || _.isArray(val) ? _.keys(val).length : 0;
return _.isObjectLike(val) ? _.keys(val).length : 0;
}

/**
Expand Down