import omit from 'lodash' ; import pick from 'lodash' ; import cloneDeep from 'lodash' ; export function deepCopy ( src ) { return cloneDeep ( src ) ; } export function pickKeys ( src , keys ) { return pick ( src , keys ) ; } export function omitKeys ( src , keys ) { return omit ( src , keys ) ; } const debounceTimer = { } as any ; export function debounceByKey ( key , func , timeout ) { const str = `${ key }#p6478==` ; if ( ! debounceTimer [ str ] ) { debounceTimer [ str ] = setTimeout ( ( ) => { func ( ) ; clearTimeout ( debounceTimer [ str ] ) ; delete debounceTimer [ str ] ; } , timeout ) ; } } const myWindow = window as any ; export function debounceByLast ( key , func , timeout ) { const str = `${ key }#m6978==` ; myWindow [ str ] && ( clearTimeout ( myWindow [ str ] ) ) ; myWindow [ str ] = setTimeout ( ( ) => { func ( ) ; myWindow [ str ] = null ; } , timeout ) ; } export function merge ( oldObj , newObj ) { for ( const key in newObj ) { if ( newObj [ key ] ) { oldObj [ key ] = newObj [ key ] ; } } return oldObj ; } export function mapToArray ( map ) { let resp = [ ] as any ; for ( const o in map ) { resp = resp . concat ( map [ o ] ) ; } return resp ; } export function keyCount ( map ) { let count = 0 ; for ( const o in map ) { count = count + 1 ; } return count ; }