FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

readline: use native `codePointAt` by vkurchatkin · Pull Request #825 · nodejs/node · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 5 additions & 4 deletions lib/readline.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Instead of deprecating it, could we just alias it to Function.prototype.call.bind(String.prototype.codePointAt) and note that it's there for legacy reasons in the docs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

it is actually undocumented and is not supposed to be used anyway. Unfortunately we have a lot of private not underscored stuff

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If it's undocumented, isn't is subject to disappearing at any time? (I realize someone could be using it)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

FWIW, I agree with @vkurchatkin. I believe the reason it was exported was so it could be unit-tested in the test suite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess that would a bit irresponsible. People use repl to discover stuff. We need a roadmap to avoid these in the future

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes people use the repl and other reads the code to find and use undocumented apis. I've done it myself, but I do not expect that code to work between versions.



/**
Expand Down

Back | FazBrowse Home | New Git URL