import { IPathResultItem } from '../../typings' ; import { DEFAULT_ACCURATE_DIGIT , DEFAULT_SIZE_DIGIT } from '../const' ; import { shortenNumberList } from '../utils/shorten-number-list' ; import { stringifyFuncVal } from '../utils/stringify-funcval' ; import { shortenDigit } from './shorten-digit' ; import { stringifyArc } from './stringify-arc' ; export const stringifyPath = ( pathResult , digit1 = DEFAULT_SIZE_DIGIT , digit2 = DEFAULT_ACCURATE_DIGIT ) => { let d = '' ; let lastType = '' ; for ( const subPath of pathResult ) { for ( const pathItem of subPath ) { const stringifyFunc = pathItem . type === 'a' || pathItem . type === 'A' ? stringifyArc : stringifyFuncVal ; if ( ( pathItem . type === lastType && lastType . toLowerCase ( ) !== 'm' ) || ( pathItem . type === 'l' && lastType === 'm' ) || ( pathItem . type === 'L' && lastType === 'M' ) ) { d = shortenNumberList ( `${ d },${ stringifyFunc ( shortenDigit ( pathItem , digit1 , digit2 ) ) }` ) ; } else { lastType = pathItem . type ; d += `${ pathItem . type }${ stringifyFunc ( shortenDigit ( pathItem , digit1 , digit2 ) ) }` ; } } } return d ; } ;