Skip to content

Commit 8a87b29

Browse files
committed
readline: remove deprecated methods
This commit removes the deprecated exports getStringWidth(), stripVTControlCharacters(), and isFullWidthCodePoint(). It also removes codePointAt() in its entirety, as it was deprecated and not being used by core. Refs: #3862 PR-URL: #6423 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 628ae25 commit 8a87b29

File tree

2 files changed

+25
-65
lines changed

2 files changed

+25
-65
lines changed

lib/readline.js

-36
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const kHistorySize = 30;
1010

1111
const util = require('util');
1212
const debug = util.debuglog('readline');
13-
const internalUtil = require('internal/util');
1413
const inherits = util.inherits;
1514
const Buffer = require('buffer').Buffer;
1615
const EventEmitter = require('events');
@@ -1042,38 +1041,3 @@ function clearScreenDown(stream) {
10421041
stream.write('\x1b[0J');
10431042
}
10441043
exports.clearScreenDown = clearScreenDown;
1045-
1046-
1047-
/**
1048-
* Returns the Unicode code point for the character at the
1049-
* given index in the given string. Similar to String.charCodeAt(),
1050-
* but this function handles surrogates (code point >= 0x10000).
1051-
*/
1052-
1053-
function codePointAt(str, index) {
1054-
var code = str.charCodeAt(index);
1055-
var low;
1056-
if (0xd800 <= code && code <= 0xdbff) { // High surrogate
1057-
low = str.charCodeAt(index + 1);
1058-
if (!isNaN(low)) {
1059-
code = 0x10000 + (code - 0xd800) * 0x400 + (low - 0xdc00);
1060-
}
1061-
}
1062-
return code;
1063-
}
1064-
exports.codePointAt = internalUtil.deprecate(codePointAt,
1065-
'readline.codePointAt is deprecated. ' +
1066-
'Use String.prototype.codePointAt instead.');
1067-
1068-
1069-
exports.getStringWidth = internalUtil.deprecate(getStringWidth,
1070-
'getStringWidth is deprecated and will be removed.');
1071-
1072-
1073-
exports.isFullWidthCodePoint = internalUtil.deprecate(isFullWidthCodePoint,
1074-
'isFullWidthCodePoint is deprecated and will be removed.');
1075-
1076-
1077-
exports.stripVTControlCharacters = internalUtil.deprecate(
1078-
stripVTControlCharacters,
1079-
'stripVTControlCharacters is deprecated and will be removed.');

test/parallel/test-readline-interface.js

+25-29
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
// Flags: --expose_internals
12
'use strict';
23
require('../common');
3-
var assert = require('assert');
4-
var readline = require('readline');
5-
var EventEmitter = require('events').EventEmitter;
6-
var inherits = require('util').inherits;
4+
const assert = require('assert');
5+
const readline = require('readline');
6+
const internalReadline = require('internal/readline');
7+
const EventEmitter = require('events').EventEmitter;
8+
const inherits = require('util').inherits;
79

810
function FakeInput() {
911
EventEmitter.call(this);
@@ -322,37 +324,31 @@ function isWarned(emitter) {
322324
}
323325

324326
// wide characters should be treated as two columns.
325-
assert.equal(readline.isFullWidthCodePoint('a'.charCodeAt(0)), false);
326-
assert.equal(readline.isFullWidthCodePoint('あ'.charCodeAt(0)), true);
327-
assert.equal(readline.isFullWidthCodePoint('谢'.charCodeAt(0)), true);
328-
assert.equal(readline.isFullWidthCodePoint('고'.charCodeAt(0)), true);
329-
assert.equal(readline.isFullWidthCodePoint(0x1f251), true); // surrogate
330-
assert.equal(readline.codePointAt('ABC', 0), 0x41);
331-
assert.equal(readline.codePointAt('あいう', 1), 0x3044);
332-
assert.equal(readline.codePointAt('\ud800\udc00', 0), // surrogate
333-
0x10000);
334-
assert.equal(readline.codePointAt('\ud800\udc00A', 2), // surrogate
335-
0x41);
336-
assert.equal(readline.getStringWidth('abcde'), 5);
337-
assert.equal(readline.getStringWidth('古池や'), 6);
338-
assert.equal(readline.getStringWidth('ノード.js'), 9);
339-
assert.equal(readline.getStringWidth('你好'), 4);
340-
assert.equal(readline.getStringWidth('안녕하세요'), 10);
341-
assert.equal(readline.getStringWidth('A\ud83c\ude00BC'), 5); // surrogate
327+
assert.equal(internalReadline.isFullWidthCodePoint('a'.charCodeAt(0)), false);
328+
assert.equal(internalReadline.isFullWidthCodePoint('あ'.charCodeAt(0)), true);
329+
assert.equal(internalReadline.isFullWidthCodePoint('谢'.charCodeAt(0)), true);
330+
assert.equal(internalReadline.isFullWidthCodePoint('고'.charCodeAt(0)), true);
331+
assert.equal(internalReadline.isFullWidthCodePoint(0x1f251), true);
332+
assert.equal(internalReadline.getStringWidth('abcde'), 5);
333+
assert.equal(internalReadline.getStringWidth('古池や'), 6);
334+
assert.equal(internalReadline.getStringWidth('ノード.js'), 9);
335+
assert.equal(internalReadline.getStringWidth('你好'), 4);
336+
assert.equal(internalReadline.getStringWidth('안녕하세요'), 10);
337+
assert.equal(internalReadline.getStringWidth('A\ud83c\ude00BC'), 5);
342338

343339
// check if vt control chars are stripped
344-
assert.equal(readline
340+
assert.equal(internalReadline
345341
.stripVTControlCharacters('\u001b[31m> \u001b[39m'), '> ');
346-
assert.equal(readline
342+
assert.equal(internalReadline
347343
.stripVTControlCharacters('\u001b[31m> \u001b[39m> '), '> > ');
348-
assert.equal(readline
344+
assert.equal(internalReadline
349345
.stripVTControlCharacters('\u001b[31m\u001b[39m'), '');
350-
assert.equal(readline
346+
assert.equal(internalReadline
351347
.stripVTControlCharacters('> '), '> ');
352-
assert.equal(readline.getStringWidth('\u001b[31m> \u001b[39m'), 2);
353-
assert.equal(readline.getStringWidth('\u001b[31m> \u001b[39m> '), 4);
354-
assert.equal(readline.getStringWidth('\u001b[31m\u001b[39m'), 0);
355-
assert.equal(readline.getStringWidth('> '), 2);
348+
assert.equal(internalReadline.getStringWidth('\u001b[31m> \u001b[39m'), 2);
349+
assert.equal(internalReadline.getStringWidth('\u001b[31m> \u001b[39m> '), 4);
350+
assert.equal(internalReadline.getStringWidth('\u001b[31m\u001b[39m'), 0);
351+
assert.equal(internalReadline.getStringWidth('> '), 2);
356352

357353
assert.deepStrictEqual(fi.listeners(terminal ? 'keypress' : 'data'), []);
358354

0 commit comments

Comments
 (0)