mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-11 07:55:08 +00:00
17 lines
341 B
JavaScript
17 lines
341 B
JavaScript
'use strict';
|
|
|
|
exports.prune = function(str, length) {
|
|
var result = '',
|
|
words = str.split(' ');
|
|
|
|
do {
|
|
result += words.shift() + ' ';
|
|
} while (words.length && result.length < length);
|
|
|
|
return result.replace(/ $/, words.length ? '...' : '');
|
|
};
|
|
|
|
exports.logErrorCallback = function(err) {
|
|
if (err) console.error(err.stack || err);
|
|
};
|