Total Complexity | 4 |
Complexity/F | 4 |
Lines of Code | 16 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | import Handlebars from 'handlebars' |
||
2 | |||
3 | export default function truncate(str, len) { |
||
4 | if (typeof str !== 'undefined' && str.length > len) { |
||
5 | new_str = new Handlebars.SafeString (str) |
||
|
|||
6 | var new_str = str + ' ' |
||
7 | new_str = str.substr (0, len) |
||
8 | new_str = str.substr (0, new_str.lastIndexOf(' ')) |
||
9 | new_str = (new_str.length > 0) ? new_str : str.substr (0, len) |
||
10 | |||
11 | return new_str +'...' |
||
12 | } else { |
||
13 | |||
14 | return '' |
||
15 | } |
||
16 | } |
||
17 |