您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.js 586B

123456789101112131415161718192021
  1. /*!
  2. * pascalcase <https://github.com/jonschlinkert/pascalcase>
  3. *
  4. * Copyright (c) 2015, Jon Schlinkert.
  5. * Licensed under the MIT License.
  6. */
  7. function pascalcase(str) {
  8. if (typeof str !== 'string') {
  9. throw new TypeError('expected a string.');
  10. }
  11. str = str.replace(/([A-Z])/g, ' $1');
  12. if (str.length === 1) { return str.toUpperCase(); }
  13. str = str.replace(/^[\W_]+|[\W_]+$/g, '').toLowerCase();
  14. str = str.charAt(0).toUpperCase() + str.slice(1);
  15. return str.replace(/[\W_]+(\w|$)/g, function (_, ch) {
  16. return ch.toUpperCase();
  17. });
  18. }
  19. module.exports = pascalcase;