const tagReg = /<\/?([^<|^>]*)>/g ; export param { any } value param { any } limit returns export function cutStr ( value , limit ) { if ( ! value ) { return '' ; } let result = `${ value }` ; result = result . replace ( tagReg , '' ) ; let strLength = 0 ; const strLen = result . length ; let strCut = '' ; for ( let i = 0 ; i < strLen ; i += 1 ) { const a = result . charAt ( i ) ; strLength += 1 ; if ( encodeURI ( a ) . length > 4 ) { strLength += 1 ; } strCut = strCut . concat ( a ) ; if ( strLength > limit ) { strCut = strCut . concat ( '...' ) ; return strCut ; } if ( strLength === limit ) { return strCut ; } } if ( strLength < limit ) { return result ; } return '' ; } param { Object } obj export function deepClone ( obj ) { return JSON . parse ( JSON . stringify ( obj ) ) ; } export function jsonProp ( obj ) { if ( ! obj || typeof obj !== 'object' ) { return obj ; } const res = Object . assign ( obj ) ; Object . keys ( res ) . forEach ( ( key ) => { if ( typeof obj [ key ] === 'object' ) { res [ key ] = JSON . stringify ( obj [ key ] ) ; } } ) ; return res ; }