Skip to content

Commit

Permalink
refactor: dedups uniq
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Mar 20, 2024
1 parent e366da8 commit d1859f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/enrich/derive/folders/aggregate-to-folders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
object2Array,
} from "./utl.mjs";
import IndexedModuleGraph from "#graph-utl/indexed-module-graph.mjs";
import { uniq } from "#utl/array-util.mjs";

function upsertCouplings(pAllDependents, pNewDependents) {
pNewDependents.forEach((pNewDependent) => {
Expand Down Expand Up @@ -95,9 +96,7 @@ function deNormalizeInstability(pFolder, _, pAllFolders) {
}),
};
}
function uniq(pArray) {
return [...new Set(pArray)];
}

function getSinks(pFolders) {
const lKnownFolders = new Set(pFolders.map(({ name }) => name));
const lAllFolders = uniq(
Expand Down
5 changes: 1 addition & 4 deletions src/main/options/normalize.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/* eslint-disable security/detect-object-injection */
import { normalizeREProperties } from "../helpers.mjs";
import defaults from "./defaults.mjs";
import { uniq } from "#utl/array-util.mjs";

const DEFAULT_CACHE_FOLDER = "node_modules/.cache/dependency-cruiser";
const DEFAULT_CACHE_STRATEGY = "metadata";

function uniq(pArray) {
return [...new Set(pArray)];
}

function normalizeFilterOption(pFilterOption) {
let lReturnValue = pFilterOption || {};

Expand Down
4 changes: 4 additions & 0 deletions src/utl/array-util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
export function intersects(pLeftArray, pRightArray) {
return pLeftArray.some((pLeftItem) => pRightArray.includes(pLeftItem));
}

export function uniq(pArray) {
return [...new Set(pArray)];
}

0 comments on commit d1859f8

Please sign in to comment.