@@ -35,10 +35,11 @@ const _applyCorrectReplace = (child, options) =>
3535export function replaceEmojis ( string , options ) {
3636 if ( ! string ) return ;
3737 let array = [ string ]
38-
38+ if ( ! options )
39+ options = { }
3940 options = {
40- size : typeof options ? .size === 'string' ? options . size : undefined ,
41- outline : typeof options ? .outline === 'boolean' ? options . outline : undefined
41+ size : typeof options . size === 'string' ? options . size : undefined ,
42+ outline : typeof options . outline === 'boolean' ? options . outline : undefined
4243 } ;
4344
4445 /*
@@ -48,7 +49,7 @@ export function replaceEmojis(string, options) {
4849 * matches all joined (ZWJ) emojis with all attached components matches attached gender
4950 */
5051
51- const regex = / \p{ Extended_Pictographic} [ \u{1f3fb} - \u{1f3ff} \u{1f9b0} - \u{1f9b3} ] ? ( \u200d \p{ Extended_Pictographic} [ \u{1f3fb} - \u{1f3ff} \u{1f9b0} - \u{1f9b3} ] ? ) * [ \u2640 \u2642 ] ? \ufe0f ? (? ! \ufe0e ) / gu;
52+ const regex = / \p{ Extended_Pictographic} [ \u{1f3fb} - \u{1f3ff} \u{1f9b0} - \u{1f9b3} ] ? \ufe0f ? ( \u200d \p{ Extended_Pictographic} [ \u{1f3fb} - \u{1f3ff} \u{1f9b0} - \u{1f9b3} ] ? \ufe0f ? ) * [ \u2640 \u2642 ] ? \ufe0f ? (? ! \ufe0e ) / gu;
5253 let m , j = 0 ;
5354
5455 while ( ( m = regex . exec ( string ) ) !== null ) {
@@ -63,10 +64,11 @@ export function replaceEmojis(string, options) {
6364 let subUnicode = m [ 0 ] . codePointAt ( i )
6465 // dismiss low surrogates characters (56320-57343)
6566 if ( ( subUnicode >= 56320 && subUnicode <= 57343 ) ) continue
66- emojiName += '_' + subUnicode ?. toString ( 16 ) . toUpperCase ( )
67+ if ( subUnicode )
68+ emojiName += '_' + subUnicode . toString ( 16 ) . toUpperCase ( )
6769
6870 // check if is done: if this hexcode is longer than 4, check the next but one codepoint
69- done = m [ 0 ] . codePointAt ( i ) ? .toString ( 16 ) . length > 4
71+ done = m [ 0 ] . codePointAt ( i ) . toString ( 16 ) . length > 4
7072 ? ! m [ 0 ] . codePointAt ( i + 2 )
7173 : ! m [ 0 ] . codePointAt ( i + 1 )
7274 }
0 commit comments