string.js 553 B

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.kebabCase = exports.camelCase = void 0;
  4. /**
  5. * camelCase('foo-bar');
  6. * // => 'fooBar'
  7. * @param s
  8. */
  9. function camelCase(s) {
  10. return s.replace(/-(\w)/g, function (_, letter) {
  11. return letter.toUpperCase();
  12. });
  13. }
  14. exports.camelCase = camelCase;
  15. /**
  16. * kebabCase('fooBar');
  17. * // => 'foo-bar'
  18. * @param s
  19. */
  20. function kebabCase(s) {
  21. return s.replace(/([A-Z])/g, '-$1').toLowerCase();
  22. }
  23. exports.kebabCase = kebabCase;
  24. //# sourceMappingURL=string.js.map