Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / globule / node_modules / lodash / deburr.js
1 var deburrLetter = require('./_deburrLetter'),
2     toString = require('./toString');
3
4 /** Used to match Latin Unicode letters (excluding mathematical operators). */
5 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
6
7 /** Used to compose unicode character classes. */
8 var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
9     rsComboSymbolsRange = '\\u20d0-\\u20f0';
10
11 /** Used to compose unicode capture groups. */
12 var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']';
13
14 /**
15  * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
16  * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
17  */
18 var reComboMark = RegExp(rsCombo, 'g');
19
20 /**
21  * Deburrs `string` by converting
22  * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
23  * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
24  * letters to basic Latin letters and removing
25  * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
26  *
27  * @static
28  * @memberOf _
29  * @since 3.0.0
30  * @category String
31  * @param {string} [string=''] The string to deburr.
32  * @returns {string} Returns the deburred string.
33  * @example
34  *
35  * _.deburr('déjà vu');
36  * // => 'deja vu'
37  */
38 function deburr(string) {
39   string = toString(string);
40   return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
41 }
42
43 module.exports = deburr;