Skip to content

Commit

Permalink
Remove array-union
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 17, 2022
1 parent ac50a7a commit 73cc6a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
21 changes: 8 additions & 13 deletions 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';
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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()]);
Expand All @@ -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));
Expand All @@ -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));
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 73cc6a1

Please sign in to comment.