import { Dimensions , NativeSyntheticEvent , NativeScrollEvent , } from 'react-native' ; export function flat ( arr ) { let arrResult = [ ] ; arr . forEach ( item => { if ( Array . isArray ( item ) ) { arrResult = arrResult . concat ( flat ( item ) ) ; } else { arrResult . push ( item ) ; } } ) ; return arrResult ; } export function isPromise ( e ) { return ! ! e && typeof e . then === 'function' ; } export function sleep ( ms ) { return new Promise ( resolve => setTimeout ( resolve , ms ) ) ; } ; export function checkScrollEnd ( event ) { let y = event . nativeEvent . contentOffset . y ; let height = event . nativeEvent . layoutMeasurement . height ; let contentHeight = event . nativeEvent . contentSize . height ; return y + height >= contentHeight - Dimensions . get ( 'screen' ) . height ; }