Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit a3b62d2

Browse files
committed
Move from .indexOf() !== -1 to .includes()
1 parent ae7d049 commit a3b62d2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const resolveGlobbedPath = function (entries, cwd) {
3535
// Globby yields unix-style paths.
3636
const normalized = path.resolve(entry)
3737

38-
if (paths.indexOf(normalized) === -1) {
38+
if (!paths.includes(normalized)) {
3939
paths.push(normalized)
4040
}
4141
})
@@ -96,7 +96,7 @@ module.exports.missing = function (pkg, deps, options) {
9696
const config = configure(pkg, options)
9797

9898
deps.map(used => {
99-
if (config.allDeps.indexOf(used) === -1 && !micromatch.isMatch(used, config.ignore)) {
99+
if (!config.allDeps.includes(used) && !micromatch.isMatch(used, config.ignore)) {
100100
missing.push(used)
101101
}
102102
})
@@ -109,7 +109,7 @@ module.exports.extra = function (pkg, deps, options) {
109109
const config = configure(pkg, options)
110110

111111
config.allDeps.map(dep => {
112-
if (deps.indexOf(dep) === -1 && !micromatch.isMatch(dep, config.ignore)) {
112+
if (!deps.includes(dep) && !micromatch.isMatch(dep, config.ignore)) {
113113
missing.push(dep)
114114
}
115115
})
@@ -269,23 +269,23 @@ function parse (opts) {
269269
const requires = detective(contents)
270270
const relatives = []
271271
requires.map(req => {
272-
const isCore = builtins.indexOf(req) > -1
272+
const isCore = builtins.includes(req)
273273
if (isNotRelative(req) && !isCore) {
274274
// require('foo/bar') -> require('foo')
275-
if (req[0] !== '@' && req.indexOf('/') > -1) req = req.split('/')[0]
275+
if (req[0] !== '@' && req.includes('/')) req = req.split('/')[0]
276276
else if (req[0] === '@') req = req.split('/').slice(0, 2).join('/')
277277
debug('require("' + req + '")' + ' is a dependency')
278278
deps[req] = true
279279
} else {
280280
if (isCore) {
281281
debug('require("' + req + '")' + ' is core')
282-
if (core.indexOf(req) === -1) {
282+
if (!core.includes(req)) {
283283
core.push(req)
284284
}
285285
} else {
286286
debug('require("' + req + '")' + ' is relative')
287287
req = path.resolve(path.dirname(file), req)
288-
if (seen.indexOf(req) === -1) {
288+
if (!seen.includes(req)) {
289289
seen.push(req)
290290
relatives.push(req)
291291
}

0 commit comments

Comments
 (0)