@nydelic/toolbox
Version:
A collection of hooks, components, and other helpful tools.
13 lines • 432 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function truncate(str, n, useWordBoundary = true) {
if (str.length <= n) {
return str;
}
const subString = str.substr(0, n - 1); // the original check
return ((useWordBoundary
? subString.substr(0, subString.lastIndexOf(" "))
: subString) + "…");
}
exports.default = truncate;
//# sourceMappingURL=truncate.js.map