diff --git a/index.js b/index.js index 253846c..cc671a4 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,4 @@ import fs from 'node:fs'; -import arrayUnion from 'array-union'; import merge2 from 'merge2'; import fastGlob from 'fast-glob'; import dirGlob from 'dir-glob'; @@ -55,7 +54,7 @@ const unionFastGlobResults = (results, filter) => { }; export const generateGlobTasks = (patterns, taskOptions) => { - patterns = arrayUnion([patterns].flat()); + patterns = [...new Set([patterns].flat())]; assertPatternsInput(patterns); const globTasks = []; @@ -164,7 +163,7 @@ export const globby = async (patterns, options = {}) => { return Promise.all(globs.map(globToTask(task))); })); - return arrayUnion(...tasks); + return tasks.flat(); }; const [filter, tasks] = await Promise.all([getFilter(options), getTasks()]); @@ -176,11 +175,9 @@ export const globby = async (patterns, options = {}) => { export const globbySync = (patterns, options = {}) => { const globTasks = generateGlobTasks(patterns, options); - const tasks = []; - for (const task of globTasks) { - const newTask = getPattern(task, dirGlob.sync).map(globToTaskSync(task)); - tasks.push(...newTask); - } + const tasks = globTasks.flatMap( + task => getPattern(task, dirGlob.sync).map(globToTaskSync(task)), + ); const filter = getFilterSync(options); const results = tasks.map(task => fastGlob.sync(task.pattern, task.options)); @@ -191,11 +188,9 @@ export const globbySync = (patterns, options = {}) => { export const globbyStream = (patterns, options = {}) => { const globTasks = generateGlobTasks(patterns, options); - const tasks = []; - for (const task of globTasks) { - const newTask = getPattern(task, dirGlob.sync).map(globToTaskSync(task)); - tasks.push(...newTask); - } + const tasks = globTasks.flatMap( + task => getPattern(task, dirGlob.sync).map(globToTaskSync(task)), + ); const filter = getFilterSync(options); const filterStream = new FilterStream(fastGlobResult => !filter(fastGlobResult)); diff --git a/package.json b/package.json index 97dc494..f65b998 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "git" ], "dependencies": { - "array-union": "^3.0.1", "dir-glob": "^3.0.1", "fast-glob": "^3.2.7", "ignore": "^5.1.9",