import normalizeStrings from 'normalize-strings' ; export const textTruncator = ( text , numOfCharsAllowed , replaceLineBreaks = true ) : string => { const ellipsis = '...' ; const cleanText = replaceLineBreaks ? text . replace ( /\n/g , ' ' ) : text ; if ( cleanText . length < numOfCharsAllowed ) { return cleanText ; } return `${ cleanText . substring ( 0 , cleanText . lastIndexOf ( ' ' , numOfCharsAllowed ) ) }${ ellipsis }` ; } ; export const normalizeSearchString = ( str ) : string => normalizeStrings ( str ) . toLowerCase ( ) ; param path returns { string } export const urlFromPath = ( path ) : string => `${ window . location . origin }${ path }` ;