UNPKG

assetgraph

Version:

An auto discovery dependency graph based optimization framework for web pages and applications

19 lines (18 loc) 484 B
module.exports = (queryObj, { detach = false, removeOrphan = false } = {}) => { return function removeRelations(assetGraph) { for (const relation of assetGraph.findRelations(queryObj)) { if (detach) { relation.detach(); } else { relation.remove(); } if ( removeOrphan && relation.to.isAsset && relation.to.incomingRelations.length === 0 ) { assetGraph.removeAsset(relation.to); } } }; };