unCamelCase.js 580 B

1234567891011121314151617181920212223
  1. var toString = require('../lang/toString');
  2. var CAMEL_CASE_BORDER = /([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g;
  3. /**
  4. * Add space between camelCase text.
  5. */
  6. function unCamelCase(str, delimiter){
  7. if (delimiter == null) {
  8. delimiter = ' ';
  9. }
  10. function join(str, c1, c2) {
  11. return c1 + delimiter + c2;
  12. }
  13. str = toString(str);
  14. str = str.replace(CAMEL_CASE_BORDER, join);
  15. str = str.toLowerCase(); //add space between camelCase text
  16. return str;
  17. }
  18. module.exports = unCamelCase;