const MAX_MIX_LEVEL = 5 ; const toString = { } . toString ; const isType = ( value , type ) : boolean => toString . call ( value ) === '[object ' + type + ']' ; const isObjectLike = ( value ) : value is object => { /**
     * isObjectLike({}) => true
     * isObjectLike([1, 2, 3]) => true
     * isObjectLike(Function) => false
     */ return typeof value === 'object' && value !== null ; } ; const isPlainObject = ( value ) : value is object => { /**
     * isObjectLike(new Foo) => false
     * isObjectLike([1, 2, 3]) => false
     * isObjectLike({ x: 0, y: 0 }) => true
     */ if ( ! isObjectLike ( value ) || ! isType ( value , 'Object' ) ) { return false ; } let proto = value ; while ( Object . getPrototypeOf ( proto ) !== null ) { proto = Object . getPrototypeOf ( proto ) ; } return Object . getPrototypeOf ( value ) === proto ; } ; param { any } dist param { any } src param { number } level param { number } maxLevel const deep = ( dist , src , level ? , maxLevel ? ) => { level = level || 0 ; maxLevel = maxLevel || MAX_MIX_LEVEL ; for ( const key in src ) { if ( Object . prototype . hasOwnProperty . call ( src , key ) ) { const value = src [ key ] ; if ( ! value ) { dist [ key ] = value ; } else { if ( isPlainObject ( value ) ) { if ( ! isPlainObject ( dist [ key ] ) ) { dist [ key ] = { } ; } if ( level < maxLevel ) { deep ( dist [ key ] , value , level + 1 , maxLevel ) ; } else { dist [ key ] = src [ key ] ; } } else { dist [ key ] = value ; } } } } } ; /**
 * customAssign 功能类似 merge
 */ export const customAssign = ( rst , ... args ) => { for ( let i = 0 ; i < args . length ; i += 1 ) { deep ( rst , args [ i ] ) ; } return rst ; } ;