readline: use native `codePointAt`
authorVladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
Thu, 12 Feb 2015 20:09:34 +0000 (23:09 +0300)
committerChris Dickinson <christopher.s.dickinson@gmail.com>
Mon, 23 Feb 2015 04:07:25 +0000 (20:07 -0800)
Semver: patch
PR-URL: https://github.com/iojs/io.js/pull/825
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
lib/readline.js

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