import GraphemeSplitter = require ( "grapheme-splitter" ) ; namespace LibraryTextBreaking { const splitter = new GraphemeSplitter ( ) ; function lineBreak ( text , lineLength ) { let graphemes = splitter . splitGraphemes ( text ) ; let lines = [ ] ; for ( let i = 0 ; i < graphemes . length ; i += lineLength ) { lines . push ( graphemes . slice ( i , i + lineLength ) . join ( "" ) ) ; } return lines ; } console . log ( lineBreak ( "Testing, testing" , 5 ) ) ; console . log ( lineBreak ( "...👮‍♀️" , 5 ) ) ; console . log ( lineBreak ( "....👮‍♀️" , 5 ) ) ; console . log ( lineBreak ( ".....👮‍♀️" , 5 ) ) ; }