Skip to content

Commit 392a898

Browse files
jasnelladdaleax
authored andcommitted
readline: use module.exports = {} on internal/readline
PR-URL: #12755 Reviewed-By: Anna Henningsen <[email protected]>
1 parent 9318f82 commit 392a898

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lib/internal/readline.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,20 @@
77
const ansi =
88
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
99

10-
11-
module.exports = {
12-
emitKeys,
13-
stripVTControlCharacters
14-
};
10+
var getStringWidth;
11+
var isFullWidthCodePoint;
1512

1613
if (process.binding('config').hasIntl) {
1714
const icu = process.binding('icu');
18-
module.exports.getStringWidth = function getStringWidth(str, options) {
15+
getStringWidth = function getStringWidth(str, options) {
1916
options = options || {};
2017
if (!Number.isInteger(str))
2118
str = stripVTControlCharacters(String(str));
2219
return icu.getStringWidth(str,
2320
Boolean(options.ambiguousAsFullWidth),
2421
Boolean(options.expandEmojiSequence));
2522
};
26-
module.exports.isFullWidthCodePoint =
23+
isFullWidthCodePoint =
2724
function isFullWidthCodePoint(code, options) {
2825
if (typeof code !== 'number')
2926
return false;
@@ -33,9 +30,9 @@ if (process.binding('config').hasIntl) {
3330
/**
3431
* Returns the number of columns required to display the given string.
3532
*/
36-
module.exports.getStringWidth = function getStringWidth(str) {
33+
getStringWidth = function getStringWidth(str) {
3734
if (Number.isInteger(str))
38-
return module.exports.isFullWidthCodePoint(str) ? 2 : 1;
35+
return isFullWidthCodePoint(str) ? 2 : 1;
3936

4037
let width = 0;
4138

@@ -48,7 +45,7 @@ if (process.binding('config').hasIntl) {
4845
i++;
4946
}
5047

51-
if (module.exports.isFullWidthCodePoint(code)) {
48+
if (isFullWidthCodePoint(code)) {
5249
width += 2;
5350
} else {
5451
width++;
@@ -62,7 +59,7 @@ if (process.binding('config').hasIntl) {
6259
* Returns true if the character represented by a given
6360
* Unicode code point is full-width. Otherwise returns false.
6461
*/
65-
module.exports.isFullWidthCodePoint = function isFullWidthCodePoint(code) {
62+
isFullWidthCodePoint = function isFullWidthCodePoint(code) {
6663
if (!Number.isInteger(code)) {
6764
return false;
6865
}
@@ -407,3 +404,10 @@ function* emitKeys(stream) {
407404
/* Unrecognized or broken escape sequence, don't emit anything */
408405
}
409406
}
407+
408+
module.exports = {
409+
emitKeys,
410+
getStringWidth,
411+
isFullWidthCodePoint,
412+
stripVTControlCharacters
413+
};

0 commit comments

Comments
 (0)