export const isNode = ( ) : boolean => { return typeof IS_NODE !== 'undefined' ? IS_NODE : typeof process !== 'undefined' && process . versions !== null && process . versions . node !== null ; } ; export const isBrowser = ( ) : boolean => { return typeof IS_BROWSER !== 'undefined' ? IS_BROWSER : typeof window !== 'undefined' && typeof window . document !== 'undefined' && ! window . process ; } ; export function getWebpackEnvVar ( webpackEnvVar , name , defaultValue ) { return ( webpackEnvVar || ( typeof process !== 'undefined' && process . env [ name ] ) || defaultValue ) ; } export const isMobile = ( mobileBreakpoint = 460 ) : boolean => { if ( isBrowser ( ) ) { const w = Math . max ( document . documentElement . clientWidth , window . innerWidth || 0 ) ; if ( w < mobileBreakpoint ) { return true ; } } return false ; } ; export function isFunction ( o ) { return typeof o === 'function' ; } export function cloneObject ( object ) { if ( ! object ) return { } ; return { ... object } ; } export const params2queryString = ( params ) : string => Object . entries ( params ) . map ( ( [ k , v ] ) => `${ encodeURIComponent ( k ) }=${ encodeURIComponent ( v ) }` ) . join ( '&' ) ; export const join = ( ... segments ) : string => { let parts = [ ] ; for ( let i = 0 , l = segments . length ; i < l ; i ++ ) { parts = parts . concat ( segments [ i ] . split ( '/' ) ) ; } const newParts = [ ] ; for ( let i = 0 , l = parts . length ; i < l ; i ++ ) { const part = parts [ i ] ; if ( ! part || part === '.' ) continue ; if ( part === '..' ) newParts . pop ( ) ; else newParts . push ( part ) ; } if ( parts [ 0 ] === '' ) newParts . unshift ( '' ) ; return newParts . join ( '/' ) || ( newParts . length ? '/' : '.' ) ; } ; export const dirname = ( path ) : string => join ( path , '..' ) ;