| 564 | } |
| 565 | |
| 566 | export class DataSnapshot implements IDataSnapshot { |
| 567 | _native: com.google.firebase.database.DataSnapshot; |
| 568 | static fromNative(snapshot: com.google.firebase.database.DataSnapshot) { |
| 569 | if (snapshot instanceof com.google.firebase.database.DataSnapshot) { |
| 570 | const ss = new DataSnapshot(); |
| 571 | ss._native = snapshot; |
| 572 | return ss; |
| 573 | } |
| 574 | return null; |
| 575 | } |
| 576 | |
| 577 | get native() { |
| 578 | return this._native; |
| 579 | } |
| 580 | get android() { |
| 581 | return this.native; |
| 582 | } |
| 583 | |
| 584 | get key(): string { |
| 585 | return this.native?.getKey(); |
| 586 | } |
| 587 | |
| 588 | get ref(): Reference { |
| 589 | return Reference.fromNative(this.native.getRef()); |
| 590 | } |
| 591 | |
| 592 | child(path: string): DataSnapshot { |
| 593 | return DataSnapshot.fromNative(this.native.child(path)); |
| 594 | } |
| 595 | exists(): boolean { |
| 596 | return this.native?.exists(); |
| 597 | } |
| 598 | exportVal() { |
| 599 | return { |
| 600 | '.priority': this.native.getPriority?.(), |
| 601 | '.value': deserialize(this.native.getValue(true)), |
| 602 | }; |
| 603 | } |
| 604 | forEach(action: (child: DataSnapshot) => true | undefined): boolean { |
| 605 | const iterator = this.native.getChildren().iterator(); |
| 606 | let stopEnumerate = false; |
| 607 | while (!stopEnumerate) { |
| 608 | if (iterator.hasNext()) { |
| 609 | const object = iterator.next(); |
| 610 | stopEnumerate = action(DataSnapshot.fromNative(object)); |
| 611 | } else { |
| 612 | stopEnumerate = true; |
| 613 | } |
| 614 | } |
| 615 | return stopEnumerate; |
| 616 | } |
| 617 | getPriority(): string | number { |
| 618 | return this.native.getPriority(); |
| 619 | } |
| 620 | hasChild(path: string): boolean { |
| 621 | return this.native?.hasChild?.(path); |
| 622 | } |
| 623 | hasChildren(): boolean { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…