import { IPathResultItem } from '../../typings' ; import { numberLength } from '../utils/number-length' ; import { computeH } from './compute-h' ; import { computeV } from './compute-v' ; export const computeL = ( absolute , relative , pathResult , pos ) : number [ ] => { if ( relative [ 1 ] === 0 ) { return computeH ( absolute [ 0 ] , relative [ 0 ] , pathResult , pos ) ; } else if ( relative [ 0 ] === 0 ) { return computeV ( absolute [ 1 ] , relative [ 1 ] , pathResult , pos ) ; } const relLen = numberLength ( relative ) ; const absLen = numberLength ( absolute ) ; if ( relLen === absLen ) { if ( pathResult [ pathResult . length - 1 ] . type === 'L' ) { pathResult . push ( { type : 'L' , from : pos . slice ( ) , val : absolute . slice ( ) , } ) ; } else { pathResult . push ( { type : 'l' , from : pos . slice ( ) , val : relative . slice ( ) , } ) ; } } else if ( relLen < absLen ) { pathResult . push ( { type : 'l' , from : pos . slice ( ) , val : relative . slice ( ) , } ) ; } else { pathResult . push ( { type : 'L' , from : pos . slice ( ) , val : absolute . slice ( ) , } ) ; } return absolute . slice ( ) ; } ;