1
0
mirror of https://github.com/flarum/core.git synced 2025-07-21 16:51:34 +02:00

Extract into truncate helper

This commit is contained in:
Toby Zerner
2015-06-17 18:22:14 +09:30
parent b8fe298b04
commit ccd5fedd25
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
export default function truncate(string, length, start) {
start = start || 0;
return (start > 0 ? '...' : '')+string.substring(start, start + length)+(string.length > start + length ? '...' : '');
}