UNPKG

@sapphire/utilities

Version:
24 lines (21 loc) 773 B
'use strict'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/lib/splitText.ts function splitText(str, length, char = " ") { const x = str.substring(0, length).lastIndexOf(char); const pos = x === -1 ? length : x; return str.substring(0, pos); } __name(splitText, "splitText"); /** * 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 * @copyright 2019 Aura Román * @license Apache-2.0 */ exports.splitText = splitText; //# sourceMappingURL=splitText.cjs.map //# sourceMappingURL=splitText.cjs.map