@rws-air/utils
Version:
Utilities for rws-air libraries and applications
19 lines • 650 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cutText = void 0;
const SplitText_1 = require("./SplitText");
/**
* Split a text by its latest space character in a range from the character 0 to the selected one.
* @param str The text to split.
* @param length The length of the desired string.
*/
function cutText(str, length) {
if (str.length < length)
return str;
const cut = (0, SplitText_1.splitText)(str, length - 3);
if (cut.length < length - 3)
return `${cut}...`;
return `${cut.slice(0, length - 3)}...`;
}
exports.cutText = cutText;
//# sourceMappingURL=CutText.js.map