@@ -2,11 +2,19 @@ import * as firebase from 'firebase/app';
22import { Subscription } from 'rxjs/Subscription' ;
33import { Scheduler } from 'rxjs/Scheduler' ;
44import { queue } from 'rxjs/scheduler/queue' ;
5- import { PathReference , DatabaseReference } from './interfaces' ;
5+ import { PathReference , DatabaseReference , FirebaseOperation , FirebaseOperationCases } from './interfaces' ;
66import { FirebaseApp } from 'angularfire2' ;
77
88const REGEX_ABSOLUTE_URL = / ^ [ a - z ] + : \/ \/ .* / ;
99
10+ export function isString ( value : any ) : boolean {
11+ return typeof value === 'string' ;
12+ }
13+
14+ export function isFirebaseDataSnapshot ( value : any ) : boolean {
15+ return typeof value . exportVal === 'function' ;
16+ }
17+
1018export function isNil ( obj : any ) : boolean {
1119 return obj === undefined || obj === null ;
1220}
@@ -56,15 +64,13 @@ export function getRef(app: FirebaseApp, pathRef: PathReference): DatabaseRefere
5664 return app . database ( ) . ref ( path ) ;
5765}
5866
59- export function checkOperationCases ( item : FirebaseOperation , cases : FirebaseOperationCases ) : firebase . Promise < void > {
60- if ( utils . isString ( item ) ) {
67+ export function checkOperationCases ( item : FirebaseOperation , cases : FirebaseOperationCases ) : Promise < void | any > {
68+ if ( isString ( item ) ) {
6169 return cases . stringCase ( ) ;
62- } else if ( utils . isFirebaseRef ( item ) ) {
70+ } else if ( isFirebaseRef ( item ) ) {
6371 return cases . firebaseCase ! ( ) ;
64- } else if ( utils . isFirebaseDataSnapshot ( item ) ) {
72+ } else if ( isFirebaseDataSnapshot ( item ) ) {
6573 return cases . snapshotCase ! ( ) ;
66- } else if ( utils . isAFUnwrappedSnapshot ( item ) ) {
67- return cases . unwrappedSnapshotCase ! ( )
6874 }
69- throw new Error ( `Method requires a key, snapshot, reference, or unwrapped snapshot . Got: ${ typeof item } ` ) ;
70- }
75+ throw new Error ( `Method requires a key, snapshot, reference. Got: ${ typeof item } ` ) ;
76+ }
0 commit comments