Skip to main content
Module

x/lodash_es/mod.ts>truncate

lodash for deno use
Latest
function truncate
import { truncate } from "https://deno.land/x/lodash_es@v0.0.2/mod.ts";

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 "...".

Examples

_.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 [...]'

Parameters

string
options