944735a87cddf787da017379030f2dceeb6ab9bd
[yaffs-website] / node_modules / uncss / node_modules / lodash / deburr.js
1 var deburrLetter = require('./internal/deburrLetter'),
2     toString = require('./toString');
3
4 /** Used to match latin-1 supplementary letters (excluding mathematical operators). */
5 var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/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 [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
22  * to basic latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
23  *
24  * @static
25  * @memberOf _
26  * @category String
27  * @param {string} [string=''] The string to deburr.
28  * @returns {string} Returns the deburred string.
29  * @example
30  *
31  * _.deburr('déjà vu');
32  * // => 'deja vu'
33  */
34 function deburr(string) {
35   string = toString(string);
36   return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, '');
37 }
38
39 module.exports = deburr;