[firestore] .settings() - use hasOwnProperty instead of truthy value existence checks
This commit is contained in:
parent
016c07fa35
commit
f4832410bb
|
@ -15,7 +15,7 @@ import Path from './Path';
|
|||
import WriteBatch from './WriteBatch';
|
||||
import TransactionHandler from './TransactionHandler';
|
||||
import Transaction from './Transaction';
|
||||
import { isBoolean, isObject, isString } from '../../utils';
|
||||
import { isBoolean, isObject, isString, hop } from '../../utils';
|
||||
import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type DocumentSnapshot from './DocumentSnapshot';
|
||||
|
@ -164,22 +164,25 @@ export default class Firestore extends ModuleBase {
|
|||
return Promise.reject(
|
||||
new Error('Firestore.settings failed: settings must be an object.')
|
||||
);
|
||||
} else if (settings.host && !isString(settings.host)) {
|
||||
} else if (hop(settings, 'host') && !isString(settings.host)) {
|
||||
return Promise.reject(
|
||||
new Error('Firestore.settings failed: settings.host must be a string.')
|
||||
);
|
||||
} else if (settings.persistence && !isBoolean(settings.persistence)) {
|
||||
} else if (
|
||||
hop(settings, 'persistence') &&
|
||||
!isBoolean(settings.persistence)
|
||||
) {
|
||||
return Promise.reject(
|
||||
new Error(
|
||||
'Firestore.settings failed: settings.persistence must be boolean.'
|
||||
)
|
||||
);
|
||||
} else if (settings.ssl && !isBoolean(settings.ssl)) {
|
||||
} else if (hop(settings, 'ssl') && !isBoolean(settings.ssl)) {
|
||||
return Promise.reject(
|
||||
new Error('Firestore.settings failed: settings.ssl must be boolean.')
|
||||
);
|
||||
} else if (
|
||||
settings.timestampsInSnapshots &&
|
||||
hop(settings, 'timestampsInSnapshots') &&
|
||||
!isBoolean(settings.timestampsInSnapshots)
|
||||
) {
|
||||
return Promise.reject(
|
||||
|
|
|
@ -11,6 +11,15 @@ const AUTO_ID_CHARS =
|
|||
const { hasOwnProperty } = Object;
|
||||
|
||||
// const DEFAULT_CHUNK_SIZE = 50;
|
||||
/**
|
||||
* Checks for property existence by name on the specified object
|
||||
* @param object
|
||||
* @param property
|
||||
* @returns {*}
|
||||
*/
|
||||
export function hop(object: Object, property: string): boolean {
|
||||
return hasOwnProperty.call(object, property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deep get a value from an object.
|
||||
|
|
Loading…
Reference in New Issue