mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-02-22 04:30:33 +09:00
8 lines
199 B
JavaScript
8 lines
199 B
JavaScript
export function truncateString(string, length, omission = "…") {
|
|
if (string.length <= length) {
|
|
return string
|
|
} else {
|
|
return string.slice(0, length - omission.length) + omission
|
|
}
|
|
}
|