readline: use native codePointAt

Semver: patch
PR-URL: https://github.com/iojs/io.js/pull/825
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
This commit is contained in:
Vladimir Kurchatkin 2015-02-12 23:09:34 +03:00 committed by Chris Dickinson
parent cb22bc9b8a
commit b41dbc2737

View File

@ -570,7 +570,7 @@ Interface.prototype._getDisplayPos = function(str) {
var code; var code;
str = stripVTControlCharacters(str); str = stripVTControlCharacters(str);
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
code = codePointAt(str, i); code = str.codePointAt(i);
if (code >= 0x10000) { // surrogates if (code >= 0x10000) { // surrogates
i++; i++;
} }
@ -605,7 +605,7 @@ Interface.prototype._getCursorPos = function() {
// move the cursor to the beginning of the next line. // move the cursor to the beginning of the next line.
if (cols + 1 === columns && if (cols + 1 === columns &&
this.cursor < this.line.length && this.cursor < this.line.length &&
isFullWidthCodePoint(codePointAt(this.line, this.cursor))) { isFullWidthCodePoint(this.line.codePointAt(this.cursor))) {
rows++; rows++;
cols = 0; cols = 0;
} }
@ -1251,7 +1251,7 @@ function getStringWidth(str) {
var width = 0; var width = 0;
str = stripVTControlCharacters(str); str = stripVTControlCharacters(str);
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
var code = codePointAt(str, i); var code = str.codePointAt(i);
if (code >= 0x10000) { // surrogates if (code >= 0x10000) { // surrogates
i++; i++;
} }
@ -1331,7 +1331,8 @@ function codePointAt(str, index) {
} }
return code; return code;
} }
exports.codePointAt = codePointAt; exports.codePointAt = util.deprecate(codePointAt,
'codePointAt() is deprecated. Use String.prototype.codePointAt');
/** /**