7
7
const ansi =
8
8
/ [ \u001b \u009b ] [ [ ( ) # ; ? ] * (?: [ 0 - 9 ] { 1 , 4 } (?: ; [ 0 - 9 ] { 0 , 4 } ) * ) ? [ 0 - 9 A - O R Z c f - n q r y = > < ] / g;
9
9
10
-
11
- module . exports = {
12
- emitKeys,
13
- stripVTControlCharacters
14
- } ;
10
+ var getStringWidth ;
11
+ var isFullWidthCodePoint ;
15
12
16
13
if ( process . binding ( 'config' ) . hasIntl ) {
17
14
const icu = process . binding ( 'icu' ) ;
18
- module . exports . getStringWidth = function getStringWidth ( str , options ) {
15
+ getStringWidth = function getStringWidth ( str , options ) {
19
16
options = options || { } ;
20
17
if ( ! Number . isInteger ( str ) )
21
18
str = stripVTControlCharacters ( String ( str ) ) ;
22
19
return icu . getStringWidth ( str ,
23
20
Boolean ( options . ambiguousAsFullWidth ) ,
24
21
Boolean ( options . expandEmojiSequence ) ) ;
25
22
} ;
26
- module . exports . isFullWidthCodePoint =
23
+ isFullWidthCodePoint =
27
24
function isFullWidthCodePoint ( code , options ) {
28
25
if ( typeof code !== 'number' )
29
26
return false ;
@@ -33,9 +30,9 @@ if (process.binding('config').hasIntl) {
33
30
/**
34
31
* Returns the number of columns required to display the given string.
35
32
*/
36
- module . exports . getStringWidth = function getStringWidth ( str ) {
33
+ getStringWidth = function getStringWidth ( str ) {
37
34
if ( Number . isInteger ( str ) )
38
- return module . exports . isFullWidthCodePoint ( str ) ? 2 : 1 ;
35
+ return isFullWidthCodePoint ( str ) ? 2 : 1 ;
39
36
40
37
let width = 0 ;
41
38
@@ -48,7 +45,7 @@ if (process.binding('config').hasIntl) {
48
45
i ++ ;
49
46
}
50
47
51
- if ( module . exports . isFullWidthCodePoint ( code ) ) {
48
+ if ( isFullWidthCodePoint ( code ) ) {
52
49
width += 2 ;
53
50
} else {
54
51
width ++ ;
@@ -62,7 +59,7 @@ if (process.binding('config').hasIntl) {
62
59
* Returns true if the character represented by a given
63
60
* Unicode code point is full-width. Otherwise returns false.
64
61
*/
65
- module . exports . isFullWidthCodePoint = function isFullWidthCodePoint ( code ) {
62
+ isFullWidthCodePoint = function isFullWidthCodePoint ( code ) {
66
63
if ( ! Number . isInteger ( code ) ) {
67
64
return false ;
68
65
}
@@ -407,3 +404,10 @@ function* emitKeys(stream) {
407
404
/* Unrecognized or broken escape sequence, don't emit anything */
408
405
}
409
406
}
407
+
408
+ module . exports = {
409
+ emitKeys,
410
+ getStringWidth,
411
+ isFullWidthCodePoint,
412
+ stripVTControlCharacters
413
+ } ;
0 commit comments