nci/lib/utils.js

13 lines
262 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);
return result.replace(/ $/, result.length <= length ? '' : '...');
};