import { isObject } from 'lodash' ; export * from './ip.util' ; export const isDev = process . env . NODE_ENV == 'development' ; export const isTest = ! ! process . env . TEST ; export const md5 = ( text ) => require ( 'crypto' ) . createHash ( 'md5' ) . update ( text ) . digest ( 'hex' ) ; export function getAvatar ( mail ) { if ( ! mail ) { return '' ; } return `https://sdn.geekzu.org/avatar/${ md5 ( mail ) }?d=retro` ; } export function sleep ( ms ) { return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ; } export function hasChinese ( str ) { return escape ( str ) . indexOf ( '%u' ) < 0 ? false : true ; } export function deleteKeys < T extends KV > ( target , keys ) ; export function deleteKeys < T extends KV > ( target , keys ) ; export function deleteKeys < T extends KV > ( target , ... keys ) ; export function deleteKeys < T extends KV > ( target , ... keys ) { if ( ! isObject ( target ) ) { throw new TypeError ( 'target must be Object, got ' + target ) ; } if ( Array . isArray ( keys [ 0 ] ) ) { for ( const key of keys [ 0 ] ) { Reflect . deleteProperty ( target , key ) ; } } else { for ( const key of keys ) { Reflect . deleteProperty ( target , key ) ; } } return target ; }