Skip to main content

truncate()

Returns a truncated string, with a custom length and delimiter.

Usage

import { truncate } from 'string-factory';

truncate(string, length, delimiter);

Prop types

proptyperequireddefault
stringStringyesnull
lengthNumberno30
delimiterstringno"..."

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