@vltpkg/graph 1.0.0-rc.14 → 1.0.0-rc.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actual/load.d.ts.map +1 -1
- package/dist/actual/load.js +3 -2
- package/dist/actual/load.js.map +1 -1
- package/dist/fixup-added-names.d.ts +4 -1
- package/dist/fixup-added-names.d.ts.map +1 -1
- package/dist/fixup-added-names.js +16 -0
- package/dist/fixup-added-names.js.map +1 -1
- package/dist/graph.d.ts +7 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +7 -0
- package/dist/graph.js.map +1 -1
- package/dist/ideal/append-nodes.d.ts +14 -2
- package/dist/ideal/append-nodes.d.ts.map +1 -1
- package/dist/ideal/append-nodes.js +179 -63
- package/dist/ideal/append-nodes.js.map +1 -1
- package/dist/ideal/build.d.ts.map +1 -1
- package/dist/ideal/build.js +11 -1
- package/dist/ideal/build.js.map +1 -1
- package/dist/ideal/peers.d.ts +70 -7
- package/dist/ideal/peers.d.ts.map +1 -1
- package/dist/ideal/peers.js +350 -170
- package/dist/ideal/peers.js.map +1 -1
- package/dist/ideal/refresh-ideal-graph.d.ts +0 -4
- package/dist/ideal/refresh-ideal-graph.d.ts.map +1 -1
- package/dist/ideal/refresh-ideal-graph.js +2 -24
- package/dist/ideal/refresh-ideal-graph.js.map +1 -1
- package/dist/ideal/sorting.d.ts +46 -0
- package/dist/ideal/sorting.d.ts.map +1 -0
- package/dist/ideal/sorting.js +71 -0
- package/dist/ideal/sorting.js.map +1 -0
- package/dist/ideal/types.d.ts +1 -5
- package/dist/ideal/types.d.ts.map +1 -1
- package/dist/ideal/types.js.map +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +12 -0
- package/dist/install.js.map +1 -1
- package/dist/lockfile/load.d.ts.map +1 -1
- package/dist/lockfile/load.js +21 -0
- package/dist/lockfile/load.js.map +1 -1
- package/dist/lockfile/save.d.ts.map +1 -1
- package/dist/lockfile/save.js +2 -2
- package/dist/lockfile/save.js.map +1 -1
- package/dist/lockfile/types.d.ts +6 -0
- package/dist/lockfile/types.d.ts.map +1 -1
- package/dist/lockfile/types.js +6 -0
- package/dist/lockfile/types.js.map +1 -1
- package/dist/reify/index.d.ts +1 -0
- package/dist/reify/index.d.ts.map +1 -1
- package/dist/reify/index.js +2 -1
- package/dist/reify/index.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +1 -0
- package/dist/update.js.map +1 -1
- package/package.json +22 -22
- package/dist/ideal/get-ordered-dependencies.d.ts +0 -10
- package/dist/ideal/get-ordered-dependencies.d.ts.map +0 -1
- package/dist/ideal/get-ordered-dependencies.js +0 -42
- package/dist/ideal/get-ordered-dependencies.js.map +0 -1
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Computes the ordered list of dependencies for an given node,
|
|
3
|
-
* taking into account additions and removals.
|
|
4
|
-
*/
|
|
5
|
-
export const getNodeOrderedDependencies = (fromNode, options) => {
|
|
6
|
-
// using a map here instead of an array helps us get simpler
|
|
7
|
-
// deduplication while iterating through all the items at hand:
|
|
8
|
-
// existing dependencies in the graph, dependencies to be added, etc.
|
|
9
|
-
const deps = new Map();
|
|
10
|
-
for (const [name, { spec, type }] of fromNode.edgesOut.entries()) {
|
|
11
|
-
deps.set(name, { spec, type });
|
|
12
|
-
}
|
|
13
|
-
// next iterate through the list of dependencies to be added
|
|
14
|
-
const addedDeps = options?.add.get(fromNode.id);
|
|
15
|
-
if (addedDeps) {
|
|
16
|
-
for (const [name, { spec, type }] of addedDeps.entries()) {
|
|
17
|
-
deps.set(name, { spec, type });
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// finally iterate through the list of dependencies to be removed
|
|
21
|
-
const removedDeps = options?.remove.get(fromNode.id);
|
|
22
|
-
if (removedDeps) {
|
|
23
|
-
for (const name of removedDeps) {
|
|
24
|
-
deps.delete(name);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// now turn the map into a sorted array
|
|
28
|
-
return getOrderedDependencies([...deps.values()]);
|
|
29
|
-
};
|
|
30
|
-
export const getOrderedDependencies = (deps) => {
|
|
31
|
-
const orderedDeps = [...deps].sort(({ spec: aSpec, type: aType }, { spec: bSpec, type: bType }) => {
|
|
32
|
-
const aIsPeer = aType === 'peer' || aType === 'peerOptional' ? 1 : 0;
|
|
33
|
-
const bIsPeer = bType === 'peer' || bType === 'peerOptional' ? 1 : 0;
|
|
34
|
-
// regular dependencies first, peer dependencies last
|
|
35
|
-
if (aIsPeer !== bIsPeer) {
|
|
36
|
-
return aIsPeer - bIsPeer;
|
|
37
|
-
}
|
|
38
|
-
return aSpec.name.localeCompare(bSpec.name, 'en');
|
|
39
|
-
});
|
|
40
|
-
return orderedDeps;
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=get-ordered-dependencies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-ordered-dependencies.js","sourceRoot":"","sources":["../../src/ideal/get-ordered-dependencies.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,QAAc,EACd,OAAwD,EAC1C,EAAE;IAChB,4DAA4D;IAC5D,+DAA+D;IAC/D,qEAAqE;IACrE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC1C,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACjE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAChC,CAAC;IACD,4DAA4D;IAC5D,MAAM,SAAS,GAAG,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC/C,IAAI,SAAS,EAAE,CAAC;QACd,KAAK,MAA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,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC,CACF,CAAA;IACD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA","sourcesContent":["import type { Node } from '../node.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\n\n/**\n * Computes the ordered list of dependencies for an given node,\n * taking into account additions and removals.\n */\nexport const getNodeOrderedDependencies = (\n fromNode: Node,\n options?: BuildIdealAddOptions & BuildIdealRemoveOptions,\n): Dependency[] => {\n // using a map here instead of an array helps us get simpler\n // deduplication while iterating through all the items at hand:\n // existing dependencies in the graph, dependencies to be added, etc.\n const deps = new Map<string, Dependency>()\n for (const [name, { spec, type }] of fromNode.edgesOut.entries()) {\n deps.set(name, { spec, type })\n }\n // next iterate through the list of dependencies to be added\n const addedDeps = options?.add.get(fromNode.id)\n if (addedDeps) {\n for (const [name, { spec, type }] of addedDeps.entries()) {\n deps.set(name, { spec, type })\n }\n }\n // finally iterate through the list of dependencies to be removed\n const removedDeps = options?.remove.get(fromNode.id)\n if (removedDeps) {\n for (const name of removedDeps) {\n deps.delete(name)\n }\n }\n\n // now turn the map into a sorted array\n return getOrderedDependencies([...deps.values()])\n}\n\nexport const getOrderedDependencies = (\n deps: Dependency[],\n): Dependency[] => {\n const orderedDeps = [...deps].sort(\n ({ spec: aSpec, type: aType }, { spec: bSpec, type: bType }) => {\n const aIsPeer =\n aType === 'peer' || aType === 'peerOptional' ? 1 : 0\n const bIsPeer =\n bType === 'peer' || bType === 'peerOptional' ? 1 : 0\n\n // regular dependencies first, peer dependencies last\n if (aIsPeer !== bIsPeer) {\n return aIsPeer - bIsPeer\n }\n\n return aSpec.name.localeCompare(bSpec.name, 'en')\n },\n )\n return orderedDeps\n}\n"]}
|