From 7e8dbcbb35882076d04ac9fd1790d0bea7a87a69 Mon Sep 17 00:00:00 2001 From: Salakar Date: Thu, 2 Mar 2017 13:09:41 +0000 Subject: [PATCH] dump of current js files --- lib/modules/analytics/index.js | 2 +- lib/modules/auth/index.js | 5 +---- lib/modules/auth/user.js | 13 +++++++++++++ lib/modules/database/disconnect.js | 2 +- lib/modules/database/index.js | 2 +- lib/modules/database/reference.js | 2 +- lib/modules/storage/index.js | 2 +- lib/modules/storage/reference.js | 4 ++-- lib/utils/index.js | 7 ++++--- 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/modules/analytics/index.js b/lib/modules/analytics/index.js index f1870907..ec9e4086 100644 --- a/lib/modules/analytics/index.js +++ b/lib/modules/analytics/index.js @@ -2,7 +2,7 @@ import { NativeModules } from 'react-native'; import { Base } from './../base'; -const FirebaseAnalytics = NativeModules.FirebaseAnalytics; +const FirebaseAnalytics = NativeModules.RNFirebaseAnalytics; const AlphaNumericUnderscore = /^[a-zA-Z0-9_]+$/; const ReservedEventNames = [ diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index 4f20f537..b8cbb141 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -6,12 +6,9 @@ import { Base } from './../base'; import EmailAuthProvider from './Email'; import { promisify } from './../../utils'; -const FirebaseAuth = NativeModules.FirebaseAuth; +const FirebaseAuth = NativeModules.RNFirebaseAuth; const FirebaseAuthEvt = new NativeEventEmitter(FirebaseAuth); -type AuthResultType = { authenticated: boolean, user: Object|null }; -type CredentialType = { provider: string, token: string, secret: string }; - // TODO move user methods to user class export default class Auth extends Base { _user: User|null; diff --git a/lib/modules/auth/user.js b/lib/modules/auth/user.js index 8e50bb9c..363159e4 100644 --- a/lib/modules/auth/user.js +++ b/lib/modules/auth/user.js @@ -1,6 +1,19 @@ +import { NativeModules, NativeEventEmitter } from 'react-native'; + +const FirebaseAuth = NativeModules.RNFirebaseAuth; + // TODO refreshToken property // TODO reload() method + +/** + * @url https://firebase.google.com/docs/reference/js/firebase.User + */ export default class User { + /** + * + * @param authClass Instance of Authentication class + * @param authObj authentication result object from native + */ constructor(authClass, authObj) { this._auth = authClass; this._user = null; diff --git a/lib/modules/database/disconnect.js b/lib/modules/database/disconnect.js index b103cb23..f79795eb 100644 --- a/lib/modules/database/disconnect.js +++ b/lib/modules/database/disconnect.js @@ -4,7 +4,7 @@ import { NativeModules } from 'react-native'; import { promisify, typeOf } from './../../utils'; import Reference from './reference'; -const FirebaseDatabase = NativeModules.FirebaseDatabase; +const FirebaseDatabase = NativeModules.RNFirebaseDatabase; /** * @url https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect diff --git a/lib/modules/database/index.js b/lib/modules/database/index.js index 1b3e77c9..2aeb1653 100644 --- a/lib/modules/database/index.js +++ b/lib/modules/database/index.js @@ -9,7 +9,7 @@ import Snapshot from './snapshot.js'; import Reference from './reference.js'; import { promisify } from './../../utils'; -const FirebaseDatabase = NativeModules.FirebaseDatabase; +const FirebaseDatabase = NativeModules.RNFirebaseDatabase; const FirebaseDatabaseEvt = new NativeEventEmitter(FirebaseDatabase); /** diff --git a/lib/modules/database/reference.js b/lib/modules/database/reference.js index 806dc82b..de143585 100644 --- a/lib/modules/database/reference.js +++ b/lib/modules/database/reference.js @@ -9,7 +9,7 @@ import Disconnect from './disconnect'; import { ReferenceBase } from './../base'; import { promisify, isFunction, isObject, tryJSONParse, tryJSONStringify, generatePushID } from './../../utils'; -const FirebaseDatabase = NativeModules.FirebaseDatabase; +const FirebaseDatabase = NativeModules.RNFirebaseDatabase; // https://firebase.google.com/docs/reference/js/firebase.database.Reference diff --git a/lib/modules/storage/index.js b/lib/modules/storage/index.js index 78c2e3f3..c1d84357 100644 --- a/lib/modules/storage/index.js +++ b/lib/modules/storage/index.js @@ -4,7 +4,7 @@ import { NativeModules, NativeEventEmitter } from 'react-native'; import { Base } from './../base'; import StorageRef from './reference'; -const FirebaseStorage = NativeModules.FirebaseStorage; +const FirebaseStorage = NativeModules.RNFirebaseStorage; const FirebaseStorageEvt = new NativeEventEmitter(FirebaseStorage); type StorageOptionsType = { diff --git a/lib/modules/storage/reference.js b/lib/modules/storage/reference.js index 2a7fbdfc..4e96e209 100644 --- a/lib/modules/storage/reference.js +++ b/lib/modules/storage/reference.js @@ -6,7 +6,7 @@ import { ReferenceBase } from './../base'; import StorageTask, { UPLOAD_TASK, DOWNLOAD_TASK } from './task'; import Storage from './'; -const FirebaseStorage = NativeModules.FirebaseStorage; +const FirebaseStorage = NativeModules.RNFirebaseStorage; /** * @url https://firebase.google.com/docs/reference/js/firebase.storage.Reference @@ -49,7 +49,7 @@ export default class StorageReference extends ReferenceBase { * @url https://firebase.google.com/docs/reference/js/firebase.storage.Reference#delete * @returns {Promise.|*} */ - delete(): Promise { + delete(): Promise<*> { return promisify('delete', FirebaseStorage)(this.path) .catch((error) => { this.log.error('Error deleting reference ', this.path, '. Error: ', error); diff --git a/lib/utils/index.js b/lib/utils/index.js index 208c9950..5e408ade 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -38,7 +38,7 @@ export function deepGet(object, path, joiner = '/') { const len = keys.length; while (i < len) { - const key = keys[i += 1]; + const key = keys[i++]; if (!tmp || !hasOwnProperty.call(tmp, key)) return null; tmp = tmp[key]; } @@ -62,7 +62,7 @@ export function deepExists(object, path, joiner = '/') { const len = keys.length; while (i < len) { - const key = keys[i += 1]; + const key = keys[i++]; if (!tmp || !hasOwnProperty.call(tmp, key)) return false; tmp = tmp[key]; } @@ -205,8 +205,9 @@ export function each(array: Array, chunkSize?: number, iterator: Function, cb: F } export function typeOf(value) { + if (value === null) return 'null'; if (Array.isArray(value)) return 'array'; - return value === null ? 'null' : typeof value; + return typeof value; } /**