nci/lib/utils.js

13 lines
251 B
JavaScript
Raw Normal View History

2014-12-02 21:21:07 +00:00
'use strict';
2015-05-07 19:03:57 +00:00
exports.prune = function(str, length) {
var result = '',
words = str.split(' ');
do {
result += words.shift() + ' ';
} while (words.length && result.length < length);
2015-05-20 20:20:51 +00:00
return result.replace(/ $/, words.length ? '...' : '');
2015-05-07 19:03:57 +00:00
};