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