import { AsyncRouteableComponent , AsyncRouteComponentType , AsyncRouteProps , TransitionBehavior , } from './types' ; import NotFoundComponent from './NotFoundComponent' ; private export const isFunction = ( obj ) => 'function' === typeof obj ; private export const isObject = ( obj ) => obj !== null && typeof obj === 'object' ; private export const isPromise = ( value ) : boolean => isObject ( value ) && isFunction ( value . then ) ; private export const isDOM = ( ) : boolean => typeof window === 'object' && typeof window . document === 'object' ; private export const isServer = ( ) : boolean => ! isDOM ( ) ; private export function isAsyncComponent ( Component ) { return ( ( Component as AsyncRouteComponentType < any > ) . getInitialProps !== undefined ) ; } private export function isLoadableComponent ( Component ) { return ( Component as AsyncRouteComponentType < any > ) . load !== undefined ; } private export function is404ComponentAvailable ( routes ) { return ( routes . find ( route => [ '**' , '*' , '' , undefined ] . includes ( route . path ) ) || false ) ; } private export function get404Component ( routes ) { const match = is404ComponentAvailable ( routes ) ; return match ? match . component : NotFoundComponent ; } private export function getAllRoutes ( routes ) { return is404ComponentAvailable ( routes ) ? routes : [ ... routes , { component : NotFoundComponent } ] ; } private export function isJS ( str ) { return str . endsWith ( '.js' ) ; } private export function isInstantTransition ( transition ) { return transition === "instant" ; }