use Set instead of object

This commit is contained in:
Brian Gough 2020-12-18 14:56:53 +00:00
parent b03812bf06
commit 11ef3c27ed

View file

@ -26,10 +26,9 @@ module.exports = OutputFileFinder = {
if (callback == null) { if (callback == null) {
callback = function (error, outputFiles, allFiles) {} callback = function (error, outputFiles, allFiles) {}
} }
const incomingResources = {} const incomingResources = new Set(
for (const resource of Array.from(resources)) { resources.map((resource) => resource.path)
incomingResources[resource.path] = true )
}
return OutputFileFinder._getAllFiles(directory, function (error, allFiles) { return OutputFileFinder._getAllFiles(directory, function (error, allFiles) {
if (allFiles == null) { if (allFiles == null) {
@ -41,10 +40,10 @@ module.exports = OutputFileFinder = {
} }
const outputFiles = [] const outputFiles = []
for (const file of Array.from(allFiles)) { for (const file of Array.from(allFiles)) {
if (!incomingResources[file]) { if (!incomingResources.has(file)) {
outputFiles.push({ outputFiles.push({
path: file, path: file,
type: __guard__(file.match(/\.([^\.]+)$/), (x) => x[1]) type: __guard__(file.match(/\.([^\.]+)$/), (x) => x[1]),
}) })
} }
} }
@ -70,7 +69,7 @@ module.exports = OutputFileFinder = {
'.archive', '.archive',
'-o', '-o',
'-name', '-name',
'.project-*' '.project-*',
] ]
const args = [ const args = [
directory, directory,
@ -81,7 +80,7 @@ module.exports = OutputFileFinder = {
'-o', '-o',
'-type', '-type',
'f', 'f',
'-print' '-print',
] ]
logger.log({ args }, 'running find command') logger.log({ args }, 'running find command')
@ -105,7 +104,7 @@ module.exports = OutputFileFinder = {
}) })
return callback(null, fileList) return callback(null, fileList)
}) })
} },
} }
function __guard__(value, transform) { function __guard__(value, transform) {