@sapphire/utilities
Version:
Common JavaScript utilities for the Sapphire Community
21 lines (19 loc) • 668 B
JavaScript
import { __name } from '../chunk-PAWJFY3S.mjs';
// 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
*/
export { splitText };
//# sourceMappingURL=splitText.mjs.map
//# sourceMappingURL=splitText.mjs.map