truncate()
Returns a truncated string, with a custom length and delimiter.
Usage
import { truncate } from 'string-factory';
truncate(string, length, delimiter);
Prop types
prop | type | required | default |
---|---|---|---|
string | String | yes | null |
length | Number | no | 30 |
delimiter | string | no | "..." |
Examples
truncate("This is a test", 7) // "This is..."
truncate("This is a test") // "This is a test"
truncate("This is a test", 7, "?") // "This is?"