Skip to content

Commit b41dbc2

Browse files
vkurchatkinchrisdickinson
authored andcommitted
readline: use native codePointAt
Semver: patch PR-URL: #825 Reviewed-By: Chris Dickinson <[email protected]>
1 parent cb22bc9 commit b41dbc2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/readline.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ Interface.prototype._getDisplayPos = function(str) {
570570
var code;
571571
str = stripVTControlCharacters(str);
572572
for (var i = 0, len = str.length; i < len; i++) {
573-
code = codePointAt(str, i);
573+
code = str.codePointAt(i);
574574
if (code >= 0x10000) { // surrogates
575575
i++;
576576
}
@@ -605,7 +605,7 @@ Interface.prototype._getCursorPos = function() {
605605
// move the cursor to the beginning of the next line.
606606
if (cols + 1 === columns &&
607607
this.cursor < this.line.length &&
608-
isFullWidthCodePoint(codePointAt(this.line, this.cursor))) {
608+
isFullWidthCodePoint(this.line.codePointAt(this.cursor))) {
609609
rows++;
610610
cols = 0;
611611
}
@@ -1251,7 +1251,7 @@ function getStringWidth(str) {
12511251
var width = 0;
12521252
str = stripVTControlCharacters(str);
12531253
for (var i = 0, len = str.length; i < len; i++) {
1254-
var code = codePointAt(str, i);
1254+
var code = str.codePointAt(i);
12551255
if (code >= 0x10000) { // surrogates
12561256
i++;
12571257
}
@@ -1331,7 +1331,8 @@ function codePointAt(str, index) {
13311331
}
13321332
return code;
13331333
}
1334-
exports.codePointAt = codePointAt;
1334+
exports.codePointAt = util.deprecate(codePointAt,
1335+
'codePointAt() is deprecated. Use String.prototype.codePointAt');
13351336

13361337

13371338
/**

0 commit comments

Comments
 (0)