flow fixes that change logic slightly
This commit is contained in:
parent
5acea6d218
commit
51a07fc4ee
|
@ -50,7 +50,7 @@ export default class TransactionHandler extends Base {
|
|||
started: true,
|
||||
};
|
||||
|
||||
FirebaseDatabase.startTransaction(reference.path, id, applyLocally || false);
|
||||
FirebaseDatabase.startTransaction(reference.path, id, applyLocally);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ export default class TransactionHandler extends Base {
|
|||
case 'update':
|
||||
return this._handleUpdate(event);
|
||||
case 'error':
|
||||
return this._handleError(error);
|
||||
return this._handleError(event);
|
||||
case 'complete':
|
||||
return this._handleComplete(event);
|
||||
default:
|
||||
|
|
|
@ -111,9 +111,9 @@ export function isFunction(item?: any): boolean {
|
|||
* @param string
|
||||
* @returns {*}
|
||||
*/
|
||||
export function tryJSONParse(string) {
|
||||
export function tryJSONParse(string: string | null): any {
|
||||
try {
|
||||
return JSON.parse(string);
|
||||
return string && JSON.parse(string);
|
||||
} catch (jsonError) {
|
||||
return string;
|
||||
}
|
||||
|
@ -217,18 +217,25 @@ function _delayChunk(
|
|||
* @param iterator
|
||||
* @param cb
|
||||
*/
|
||||
export function each(array: Array, chunkSize?: number, iterator: Function, cb: Function): void {
|
||||
export function each(
|
||||
array: Array<*>,
|
||||
chunkSize: number | Function,
|
||||
iterator: Function,
|
||||
cb?: Function
|
||||
): void {
|
||||
if (typeof chunkSize === 'function') {
|
||||
cb = iterator;
|
||||
iterator = chunkSize;
|
||||
chunkSize = DEFAULT_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
_delayChunk(array, chunkSize, (slice, start) => {
|
||||
for (let ii = 0, jj = slice.length; ii < jj; ii += 1) {
|
||||
iterator(slice[ii], start + ii);
|
||||
}
|
||||
}, cb);
|
||||
if (cb) {
|
||||
_delayChunk(array, chunkSize, (slice, start) => {
|
||||
for (let ii = 0, jj = slice.length; ii < jj; ii += 1) {
|
||||
iterator(slice[ii], start + ii);
|
||||
}
|
||||
}, cb);
|
||||
}
|
||||
}
|
||||
|
||||
export function typeOf(value: any): string {
|
||||
|
@ -245,7 +252,12 @@ export function typeOf(value: any): string {
|
|||
* @param cb
|
||||
* @returns {*}
|
||||
*/
|
||||
export function map(array: Array, chunkSize?: number, iterator: Function, cb: Function): void {
|
||||
export function map(
|
||||
array: Array<*>,
|
||||
chunkSize: number | Function,
|
||||
iterator: Function,
|
||||
cb?: Function
|
||||
): void {
|
||||
if (typeof chunkSize === 'function') {
|
||||
cb = iterator;
|
||||
iterator = chunkSize;
|
||||
|
@ -258,7 +270,7 @@ export function map(array: Array, chunkSize?: number, iterator: Function, cb: Fu
|
|||
result.push(iterator(slice[ii], start + ii, array));
|
||||
}
|
||||
return result;
|
||||
}, () => cb(result));
|
||||
}, () => cb && cb(result));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue