Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove array-union #211

Merged
merged 1 commit into from Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tasks are all objects, arrayUnion not doing anything here.

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