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.

24 lines
635 B

4 years ago
  1. var arrayReduce = require('./_arrayReduce'),
  2. deburr = require('./deburr'),
  3. words = require('./words');
  4. /** Used to compose unicode capture groups. */
  5. var rsApos = "['\u2019]";
  6. /** Used to match apostrophes. */
  7. var reApos = RegExp(rsApos, 'g');
  8. /**
  9. * Creates a function like `_.camelCase`.
  10. *
  11. * @private
  12. * @param {Function} callback The function to combine each word.
  13. * @returns {Function} Returns the new compounder function.
  14. */
  15. function createCompounder(callback) {
  16. return function(string) {
  17. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  18. };
  19. }
  20. module.exports = createCompounder;