@n3okill/utils
Version:
Many javascript helpers
16 lines • 710 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.trimRight = trimRight;
const escapeRegExp_1 = require("./escapeRegExp");
const toString_1 = require("./toString");
/**
* Remove given characters from right side of the string
* @param s String to remove the characters from
* @param chars Characters to remove, if not defined removes empty spaces
* @returns Trimmed string
*/
function trimRight(s, chars = []) {
// eslint-disable-next-line security/detect-non-literal-regexp
return (0, toString_1.toString)(s).replace(chars.length ? new RegExp(`[${(0, escapeRegExp_1.escapeRegExp)(chars.join(""))}]+$`, "g") : /\s+$/g, "");
}
//# sourceMappingURL=trimRight.js.map
;