const currencyFormatter = new Intl . NumberFormat ( 'en-US' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 2 } ) ; export const formatAsUsd = currencyFormatter . format ; param str export const truncate = ( str , max = 90 ) : string => { const trimmed = str . trim ( ) ; return trimmed . length > max ? trimmed . slice ( 0 , max ) . concat ( ' ...' ) : trimmed ; } ; export const removeCurrencyFormatting = ( input ) => input . replace ( /[^\d.]/g , '' ) ; export const pluralize = ( nonPluralForm , pluralForm = nonPluralForm + 's' ) => ( groupSize = 2 ) => ( groupSize === 1 ? nonPluralForm : pluralForm ) ; param userInput export const escapeUserInputForRegex = ( userInput ) => userInput . replace ( /[.*+?^${}()|[\]\\]/g , '\\$&' ) ; export const pluralizeHits = pluralize ( 'HIT' ) ;