Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace deprecated String.prototype.substr() #5384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function DEFNODE(type, props, methods, base) {
ctor.SUBCLASSES = [];
for (var name in methods) if (HOP(methods, name)) {
if (/^\$/.test(name)) {
ctor[name.substr(1)] = methods[name];
ctor[name.slice(1)] = methods[name];
} else {
ctor.DEFMETHOD(name, methods[name]);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function OutputStream(options) {
if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
var regex_pos = options.comments.lastIndexOf("/");
comments = new RegExp(
options.comments.substr(1, regex_pos - 1),
options.comments.substr(regex_pos + 1)
options.comments.slice(1, regex_pos),
options.comments.slice(regex_pos + 1)
);
}
if (comments instanceof RegExp) {
Expand Down
8 changes: 4 additions & 4 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
}

function looking_at(str) {
return S.text.substr(S.pos, str.length) == str;
return S.text.slice(S.pos, S.pos + str.length) == str;
}

function find_eol() {
Expand Down Expand Up @@ -449,7 +449,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
var regex_allowed = S.regex_allowed;
var i = find_eol(), ret;
if (i == -1) {
ret = S.text.substr(S.pos);
ret = S.text.slice(S.pos);
S.pos = S.text.length;
} else {
ret = S.text.substring(S.pos, i);
Expand Down Expand Up @@ -489,7 +489,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
}
if (KEYWORDS[name] && escaped) {
var hex = name.charCodeAt(0).toString(16).toUpperCase();
name = "\\u" + "0000".substr(hex.length) + hex + name.slice(1);
name = "\\u" + "0000".slice(hex.length) + hex + name.slice(1);
}
return name;
}
Expand Down Expand Up @@ -816,7 +816,7 @@ function parse($TEXT, options) {
function handle_regexp() {
if (is("operator", "/") || is("operator", "/=")) {
S.peeked = null;
S.token = S.input(S.token.value.substr(1)); // force regexp
S.token = S.input(S.token.value.slice(1)); // force regexp
}
}

Expand Down