import Range from "range-utils" ; function walk ( base , iter ) { let offset = 0 ; const tokens = base . getTokens ( ) ; if ( tokens . size === 0 ) { iter ( base , Range ( 0 , base . getText ( ) . length ) ) ; return base . getText ( ) ; } return tokens . reduce ( ( output , token ) => { if ( token . isBlock ( ) ) { return output ; } const innerText = walk ( token , ( tok , range ) => { const realRange = Range . moveBy ( range , offset ) ; iter ( tok , realRange ) ; } ) ; iter ( token , Range ( offset , innerText . length ) ) ; offset += innerText . length ; return output + innerText ; } , "" ) ; } export default walk ;