Skip to content

Commit 0a586f1

Browse files
committed
Refactor some more
1 parent 7ac7d02 commit 0a586f1

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @typedef {import('./lib/index.js').UrlConfig} UrlConfig
32
* @typedef {import('./lib/index.js').Options} Options
3+
* @typedef {import('./lib/index.js').UrlConfig} UrlConfig
44
*/
55

66
export {default} from './lib/index.js'

lib/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ export default function remarkValidateLinks(options, fileSet) {
217217
root,
218218
urlConfig
219219
}
220-
/** @type {Array<string>} */
221-
const statted = []
222-
/** @type {Array<string>} */
223-
const added = []
220+
/** @type {Set<string>} */
221+
const statted = new Set()
222+
/** @type {Set<string>} */
223+
const added = new Set()
224224
/** @type {Array<Promise<void>>} */
225225
const promises = []
226226

@@ -260,7 +260,7 @@ export default function remarkValidateLinks(options, fileSet) {
260260
addReference(fp, hash, node)
261261
}
262262

263-
if (fileSet && fp && !statted.includes(fp)) {
263+
if (fileSet && fp && !statted.has(fp)) {
264264
promises.push(addFile(fp))
265265
}
266266
}
@@ -351,7 +351,7 @@ export default function remarkValidateLinks(options, fileSet) {
351351
* Nothing.
352352
*/
353353
async function addFile(filePath) {
354-
statted.push(filePath)
354+
statted.add(filePath)
355355

356356
try {
357357
const stats = await fs.stat(filePath)
@@ -384,13 +384,13 @@ export default function remarkValidateLinks(options, fileSet) {
384384
// Else, there’s no readme that we can parse, so add the directory.
385385
if (file) {
386386
filePath = path.join(filePath, file)
387-
statted.push(filePath)
387+
statted.add(filePath)
388388
}
389389
}
390390
} catch {}
391391

392-
if (fileSet && !added.includes(filePath)) {
393-
added.push(filePath)
392+
if (fileSet && !added.has(filePath)) {
393+
added.add(filePath)
394394
fileSet.add(
395395
new VFile({cwd: file.cwd, path: path.relative(file.cwd, filePath)})
396396
)

0 commit comments

Comments
 (0)