File tree 3 files changed +8
-0
lines changed
3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
const stripAnsi = require ( 'strip-ansi' ) ;
3
3
const isFullwidthCodePoint = require ( 'is-fullwidth-code-point' ) ;
4
+ const emojiRegex = require ( 'emoji-regex' ) ( ) ;
4
5
5
6
module . exports = str => {
7
+ str = str . replace ( emojiRegex , ' ' ) ;
8
+
6
9
if ( typeof str !== 'string' || str . length === 0 ) {
7
10
return 0 ;
8
11
}
Original file line number Diff line number Diff line change 45
45
" fixed-width"
46
46
],
47
47
"dependencies" : {
48
+ "emoji-regex" : " ^7.0.1" ,
48
49
"is-fullwidth-code-point" : " ^2.0.0" ,
49
50
"strip-ansi" : " ^4.0.0"
50
51
},
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ test('main', t => {
10
10
t . is ( m ( '안녕하세요' ) , 10 ) ;
11
11
t . is ( m ( 'A\uD83C\uDE00BC' ) , 5 , 'surrogate' ) ;
12
12
t . is ( m ( '\u001B[31m\u001B[39m' ) , 0 ) ;
13
+ t . is ( m ( '\u{231A}' ) , 2 , '⌚ default emoji presentation character (Emoji_Presentation)' ) ;
14
+ t . is ( m ( '\u{2194}\u{FE0F}' ) , 2 , '↔️ default text presentation character rendered as emoji' ) ;
15
+ t . is ( m ( '\u{1F469}' ) , 2 , '👩 emoji modifier base (Emoji_Modifier_Base)' ) ;
16
+ t . is ( m ( '\u{1F469}\u{1F3FF}' ) , 2 , '👩🏿 emoji modifier base followed by a modifier' ) ;
13
17
} ) ;
14
18
15
19
test ( 'ignores control characters' , t => {
You can’t perform that action at this time.
0 commit comments