string.js 875 B

1234567891011121314151617
  1. export function toUppercaseFirstLetter(string) {
  2. return string.toString().charAt(0).toUpperCase() + string.toString().slice(1);
  3. }
  4. export function toLowercaseFirstLetter(string) {
  5. return string.toString().charAt(0).toLowerCase() + string.toString().slice(1);
  6. }
  7. export function addPrefix(string, prefix) {
  8. return "".concat(prefix).concat(toUppercaseFirstLetter(string));
  9. }
  10. export function removePrefix(string, prefix, lowercaseFirstLetter) {
  11. var _a;
  12. if (lowercaseFirstLetter === void 0) { lowercaseFirstLetter = true; }
  13. var inferPrefix = prefix || ((_a = string.match(/^([a-z][a-z0-9]+)/)) === null || _a === void 0 ? void 0 : _a[0]) || '';
  14. var withoutPrefix = string.replace(new RegExp("^(".concat(inferPrefix, ")")), '');
  15. return lowercaseFirstLetter ? toLowercaseFirstLetter(withoutPrefix) : withoutPrefix;
  16. }
  17. //# sourceMappingURL=string.js.map