mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
40
.internal/unicodeToArray.js
Normal file
40
.internal/unicodeToArray.js
Normal file
@@ -0,0 +1,40 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
const rsAstralRange = '\\ud800-\\udfff';
|
||||
const rsComboMarksRange = '\\u0300-\\u036f';
|
||||
const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
|
||||
const rsComboSymbolsRange = '\\u20d0-\\u20ff';
|
||||
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
||||
const rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
const rsAstral = `[${ rsAstralRange }]`;
|
||||
const rsCombo = `[${ rsComboRange }]`;
|
||||
const rsFitz = '\\ud83c[\\udffb-\\udfff]';
|
||||
const rsModifier = `(?:${ rsCombo }|${ rsFitz })`;
|
||||
const rsNonAstral = `[^${ rsAstralRange }]`;
|
||||
const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
|
||||
const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
|
||||
const rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
const reOptMod = `${ rsModifier }?`;
|
||||
const rsOptVar = `[${ rsVarRange }]?`;
|
||||
const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`;
|
||||
const rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
||||
const rsSymbol = `(?:${ [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') })`;
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
const reUnicode = RegExp(`${ rsFitz }(?=${ rsFitz })|${ rsSymbol + rsSeq }`, 'g');
|
||||
|
||||
/**
|
||||
* Converts a Unicode `string` to an array.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the converted array.
|
||||
*/
|
||||
function unicodeToArray(string) {
|
||||
return string.match(reUnicode) || [];
|
||||
}
|
||||
|
||||
export default unicodeToArray;
|
||||
Reference in New Issue
Block a user