function arg text arg str arg caseSensitive export function getIndicesOf ( text , str , caseSensitive = true ) { if ( ! str . length ) { return [ ] ; } let startIndex = 0 ; let index ; const indices = new Array < number > ( ) ; if ( ! caseSensitive ) { text = text . toLowerCase ( ) ; str = str . toLowerCase ( ) ; } while ( ( index = text . indexOf ( str , startIndex ) ) > - 1 ) { indices . push ( index ) ; startIndex = index + str . length ; } return indices ; } function arg arg export function immutableSort ( array , compareFunction ? ) { return [ ... array ] . sort ( compareFunction ) ; } function arg arg arg export function cut ( s1 , s2 , delimiter = '' ) { if ( s1 . indexOf ( s2 ) === - 1 ) { return s1 ; } const trimmedSplitArray = new Array < string > ( ) ; for ( const part of s1 . split ( s2 ) ) { if ( part !== '' && part . trim ( ) !== '' ) { trimmedSplitArray . push ( part . trim ( ) ) ; } } return trimmedSplitArray . join ( delimiter ) ; }