Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / createCompounder.js
1 var deburr = require('../string/deburr'),
2     words = require('../string/words');
3
4 /**
5  * Creates a function that produces compound words out of the words in a
6  * given string.
7  *
8  * @private
9  * @param {Function} callback The function to combine each word.
10  * @returns {Function} Returns the new compounder function.
11  */
12 function createCompounder(callback) {
13   return function(string) {
14     var index = -1,
15         array = words(deburr(string)),
16         length = array.length,
17         result = '';
18
19     while (++index < length) {
20       result = callback(result, array[index], index);
21     }
22     return result;
23   };
24 }
25
26 module.exports = createCompounder;