diff --git a/lib/_debugger.js b/lib/_debugger.js index 99b55a8b50e07d..be1b0f62daf151 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -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; } @@ -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; } @@ -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; } diff --git a/lib/dns.js b/lib/dns.js index 0a6e84a435da02..84255119b72035 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -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); } } diff --git a/lib/fs.js b/lib/fs.js index 2d7a038e156a66..211add74d8101c 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -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; diff --git a/lib/module.js b/lib/module.js index 0a4195cf7b7504..2ba04b2fb48092 100644 --- a/lib/module.js +++ b/lib/module.js @@ -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; } diff --git a/lib/url.js b/lib/url.js index abe66acfca983b..7ba812b82f2553 100644 --- a/lib/url.js +++ b/lib/url.js @@ -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) { @@ -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) { diff --git a/lib/util.js b/lib/util.js index 891a376c2d955c..7bbff7f3b2bf26 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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;