nci/lib/utils.js

17 lines
341 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
};
2015-05-21 21:09:16 +00:00
exports.logErrorCallback = function(err) {
if (err) console.error(err.stack || err);
};