readline: use module.exports = {} on internal/readline
PR-URL: https://github.com/nodejs/node/pull/12755 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
9318f82937
commit
392a8987c6
@ -7,15 +7,12 @@
|
||||
const ansi =
|
||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
||||
|
||||
|
||||
module.exports = {
|
||||
emitKeys,
|
||||
stripVTControlCharacters
|
||||
};
|
||||
var getStringWidth;
|
||||
var isFullWidthCodePoint;
|
||||
|
||||
if (process.binding('config').hasIntl) {
|
||||
const icu = process.binding('icu');
|
||||
module.exports.getStringWidth = function getStringWidth(str, options) {
|
||||
getStringWidth = function getStringWidth(str, options) {
|
||||
options = options || {};
|
||||
if (!Number.isInteger(str))
|
||||
str = stripVTControlCharacters(String(str));
|
||||
@ -23,7 +20,7 @@ if (process.binding('config').hasIntl) {
|
||||
Boolean(options.ambiguousAsFullWidth),
|
||||
Boolean(options.expandEmojiSequence));
|
||||
};
|
||||
module.exports.isFullWidthCodePoint =
|
||||
isFullWidthCodePoint =
|
||||
function isFullWidthCodePoint(code, options) {
|
||||
if (typeof code !== 'number')
|
||||
return false;
|
||||
@ -33,9 +30,9 @@ if (process.binding('config').hasIntl) {
|
||||
/**
|
||||
* Returns the number of columns required to display the given string.
|
||||
*/
|
||||
module.exports.getStringWidth = function getStringWidth(str) {
|
||||
getStringWidth = function getStringWidth(str) {
|
||||
if (Number.isInteger(str))
|
||||
return module.exports.isFullWidthCodePoint(str) ? 2 : 1;
|
||||
return isFullWidthCodePoint(str) ? 2 : 1;
|
||||
|
||||
let width = 0;
|
||||
|
||||
@ -48,7 +45,7 @@ if (process.binding('config').hasIntl) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (module.exports.isFullWidthCodePoint(code)) {
|
||||
if (isFullWidthCodePoint(code)) {
|
||||
width += 2;
|
||||
} else {
|
||||
width++;
|
||||
@ -62,7 +59,7 @@ if (process.binding('config').hasIntl) {
|
||||
* Returns true if the character represented by a given
|
||||
* Unicode code point is full-width. Otherwise returns false.
|
||||
*/
|
||||
module.exports.isFullWidthCodePoint = function isFullWidthCodePoint(code) {
|
||||
isFullWidthCodePoint = function isFullWidthCodePoint(code) {
|
||||
if (!Number.isInteger(code)) {
|
||||
return false;
|
||||
}
|
||||
@ -407,3 +404,10 @@ function* emitKeys(stream) {
|
||||
/* Unrecognized or broken escape sequence, don't emit anything */
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
emitKeys,
|
||||
getStringWidth,
|
||||
isFullWidthCodePoint,
|
||||
stripVTControlCharacters
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user