UNPKG

@rws-air/utils

Version:
16 lines 588 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.splitText = void 0; /** * Split a string 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. * @param char The character to split with */ function splitText(str, length, char = ' ') { const x = str.substring(0, length).lastIndexOf(char); const pos = x === -1 ? length : x; return str.substring(0, pos); } exports.splitText = splitText; //# sourceMappingURL=SplitText.js.map