You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
412 B

4 years ago
  1. 'use strict';
  2. var KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
  3. var REVERSE_REGEX = /-[a-z\u00E0-\u00F6\u00F8-\u00FE]/g;
  4. module.exports = exports = function kebabCase(str) {
  5. return str.replace(KEBAB_REGEX, function (match) {
  6. return '-' + match.toLowerCase();
  7. });
  8. };
  9. exports.reverse = function (str) {
  10. return str.replace(REVERSE_REGEX, function (match) {
  11. return match.slice(1).toUpperCase();
  12. });
  13. };