param item returns { boolean } export function isFunction ( item ) { return ( item && typeof item === 'function' && ! Array . isArray ( item ) ) ; } param item returns { boolean } export function isObject ( item ) { return ( item && typeof item === 'object' && ! Array . isArray ( item ) ) ; } param item returns { boolean } export function isObjectOrFunction ( item ) { return isFunction ( item ) || isObject ( item ) ; } param item returns { boolean } export function isClassInstance ( item ) { return isObject ( item ) && item . constructor . name !== 'Object' ; } param item returns { boolean } export function isNotEmpty ( item ) { return ! isEmpty ( item ) ; } param item returns { boolean } export function isEmpty ( item ) { if ( item instanceof Array ) { item = item . filter ( ( val ) => ! isEmpty ( val ) ) ; return item . length === 0 ; } else if ( item && typeof item === 'object' ) { for ( var key in item ) { if ( item [ key ] === null || item [ key ] === undefined || item [ key ] === '' ) { delete item [ key ] ; } } return Object . keys ( item ) . length === 0 ; } else { return ( ! item || ( item + '' ) . toLocaleLowerCase ( ) === 'null' || ( item + '' ) . toLocaleLowerCase ( ) === 'undefined' ) ; } } export function isJsObject ( object ) { return ( object !== null && object !== undefined && typeof object === 'object' ) ; } export function average ( items , column ) { let sum = 0 ; if ( items . length > 0 ) { items . forEach ( ( item ) => { sum += parseFloat ( item [ column ] ) ; } ) ; } return sum / items . length ; } export const ArraySum = function ( t , n ) { return parseFloat ( t ) + parseFloat ( n ) ; } ; export function retrieveNameFromEmail ( email ) { if ( email ) { return ucFirst ( email . substring ( 0 , email . lastIndexOf ( '@' ) ) , true ) ; } return ; } export function ucFirst ( str , force ) { str = force ? str . toLowerCase ( ) : str ; return str . replace ( /(\b)([a-zA-Z])/ , function ( firstLetter ) { return firstLetter . toUpperCase ( ) ; } ) ; } param data returns export function removeDuplicates ( data ) { return [ ... new Set ( data ) ] ; }