@raona/sp
Version:
Raona utilities to work with Sharepoint using pnp/sp
14 lines (13 loc) • 566 B
JavaScript
;
// Source: https://stackoverflow.com/questions/1199352/smart-way-to-truncate-long-strings
Object.defineProperty(exports, "__esModule", { value: true });
function truncate(str, limit, useHtmlEntityForEllipsis, useWordBoundary) {
if (str.length <= limit)
return str;
var ellipsis = useHtmlEntityForEllipsis ? '…' : '...';
var subString = str.substr(0, limit - 1);
return (useWordBoundary
? subString.substr(0, subString.lastIndexOf(' '))
: subString) + ellipsis;
}
exports.truncate = truncate;