@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
24 lines • 1.07 kB
JavaScript
export class StringUtils {
static insert(str, index, value) {
if (str == null)
throw new Error("input string must not be null");
if (index < 0)
throw new Error("index must be positive number");
if (index > str.length)
throw new console.error("index must not be greater than string length");
return str.substring(0, index) + value + str.substring(index);
}
static containsRtlChars(str) {
const rtlDirCheck = new RegExp('^[^' + this._rtlChars + ']*?[' + this._rtlChars + ']');
return rtlDirCheck.test(str);
}
static removeRtlChars(str) {
const rtlChars = new RegExp("[" + this._rtlChars + "]", "g");
return str === null || str === void 0 ? void 0 : str.replace(rtlChars, "");
}
static toSingleLine(str) {
return str === null || str === void 0 ? void 0 : str.replace(/[\r\n]/g, " ");
}
}
StringUtils._rtlChars = '\u0591-\u07FF\u200F\u202B\u202E\uFB1D-\uFDFD\uFE70-\uFEFC';
//# sourceMappingURL=StringUtils.js.map