dependency-cruiser
Version:
Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.
15 lines (12 loc) • 381 B
JavaScript
import { isDependent } from "../module-utl.mjs";
export default function isOrphan(pModule, pGraph) {
if (pModule.dependencies.length > 0) {
return false;
}
// when dependents already calculated take those
if (pModule.dependents) {
return pModule.dependents.length === 0;
}
// ... otherwise calculate them
return !pGraph.some(isDependent(pModule.source));
}