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

lib: Convert String#indexOf usages to String#includes #327

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ Interface.prototype.setBreakpoint = function(script, line,
for (var id in scripts) {
if (scripts[id] &&
scripts[id].name &&
scripts[id].name.indexOf(script) !== -1) {
scripts[id].name.includes(script)) {
if (scriptId) {
ambiguous = true;
}
Expand Down Expand Up @@ -1441,7 +1441,7 @@ Interface.prototype.clearBreakpoint = function(script, line) {
this.client.breakpoints.some(function(bp, i) {
if (bp.scriptId === script ||
bp.scriptReq === script ||
(bp.script && bp.script.indexOf(script) !== -1)) {
(bp.script && bp.script.includes(script))) {
if (!util.isUndefined(index)) {
ambiguous = true;
}
Expand All @@ -1459,7 +1459,7 @@ Interface.prototype.clearBreakpoint = function(script, line) {
for (var id in scripts) {
if (scripts[id] &&
scripts[id].name &&
scripts[id].name.indexOf(script) !== -1) {
scripts[id].name.includes(script)) {
if (scriptId) {
ambiguous = true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function onlookup(err, addresses) {
if (this.family) {
this.callback(null, addresses[0], this.family);
} else {
this.callback(null, addresses[0], addresses[0].indexOf(':') >= 0 ? 6 : 4);
this.callback(null, addresses[0], addresses[0].includes(':') ? 6 : 4);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function assertEncoding(encoding) {
}

function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
if (('' + path).includes('\u0000')) {
var er = new Error('Path must be a string without null bytes.');
if (!callback)
throw er;
Expand Down
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Module._resolveLookupPaths = function(request, parent) {

// make sure require('./path') and require('path') get distinct ids, even
// when called from the toplevel js file
if (parentIdPath === '.' && id.indexOf('/') === -1) {
if (parentIdPath === '.' && !id.includes('/')) {
id = './' + id;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
// need to be.
for (var i = 0, l = autoEscape.length; i < l; i++) {
var ae = autoEscape[i];
if (rest.indexOf(ae) === -1)
if (!rest.includes(ae))
continue;
var esc = encodeURIComponent(ae);
if (esc === ae) {
Expand Down Expand Up @@ -375,7 +375,7 @@ Url.prototype.format = function() {
if (this.host) {
host = auth + this.host;
} else if (this.hostname) {
host = auth + (this.hostname.indexOf(':') === -1 ?
host = auth + (!this.hostname.includes(':') ?
this.hostname :
'[' + this.hostname + ']');
if (this.port) {
Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
} else {
str = formatValue(ctx, desc.value, recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (str.includes('\n')) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
Expand Down