The string to truncate.
Optional
options: OptionsThe options object.
Returns the truncated string.
5.6.0
[[replace]]
truncate('hi-diddly-ho there, neighborino')
// => 'hi-diddly-ho there, neighbo...'
truncate('hi-diddly-ho there, neighborino', {
'length': 24,
'separator': ' '
})
// => 'hi-diddly-ho there,...'
truncate('hi-diddly-ho there, neighborino', {
'length': 24,
'separator': /,? +/
})
// => 'hi-diddly-ho there...'
truncate('hi-diddly-ho there, neighborino', {
'omission': ' [...]'
})
// => 'hi-diddly-ho there, neig [...]'
Optional
options: Options
Truncates
string
if it's longer than the given maximum string length. The last characters of the truncated string are replaced with the omission string which defaults to "...".