@atlaspack/graph 3.5.10-typescript-bc4459c37.0 → 3.5.10
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/CHANGELOG.md +7 -0
- package/lib/AdjacencyList.js +3 -26
- package/lib/BitSet.js +1 -0
- package/lib/ContentGraph.js +5 -1
- package/lib/Graph.js +3 -8
- package/lib/shared-buffer.js +1 -5
- package/lib/types.js +0 -1
- package/package.json +8 -11
- package/src/{AdjacencyList.ts → AdjacencyList.js} +101 -127
- package/src/{BitSet.ts → BitSet.js} +3 -0
- package/src/{ContentGraph.ts → ContentGraph.js} +20 -21
- package/src/{Graph.ts → Graph.js} +65 -88
- package/src/{index.ts → index.js} +2 -0
- package/src/{shared-buffer.ts → shared-buffer.js} +3 -6
- package/src/{types.ts → types.js} +7 -5
- package/test/{AdjacencyList.test.ts → AdjacencyList.test.js} +29 -21
- package/test/{BitSet.test.ts → BitSet.test.js} +5 -3
- package/test/{ContentGraph.test.ts → ContentGraph.test.js} +4 -2
- package/test/{Graph.test.ts → Graph.test.js} +24 -22
- package/LICENSE +0 -201
- package/lib/AdjacencyList.d.ts +0 -607
- package/lib/BitSet.d.ts +0 -19
- package/lib/ContentGraph.d.ts +0 -23
- package/lib/Graph.d.ts +0 -91
- package/lib/index.d.ts +0 -7
- package/lib/shared-buffer.d.ts +0 -2
- package/lib/types.d.ts +0 -9
- package/tsconfig.json +0 -4
package/lib/Graph.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import AdjacencyList, { SerializedAdjacencyList } from './AdjacencyList';
|
|
2
|
-
import type { Edge, NodeId } from './types';
|
|
3
|
-
import type { TraversalActions, GraphVisitor, GraphTraversalCallback } from '@atlaspack/types';
|
|
4
|
-
import { BitSet } from './BitSet';
|
|
5
|
-
export type NullEdgeType = 1;
|
|
6
|
-
export declare const NULL_EDGE_TYPE: NullEdgeType;
|
|
7
|
-
export type GraphOpts<TNode, TEdgeType extends number = NullEdgeType> = {
|
|
8
|
-
nodes?: Array<TNode | null>;
|
|
9
|
-
adjacencyList?: SerializedAdjacencyList<TEdgeType>;
|
|
10
|
-
rootNodeId?: NodeId | null | undefined;
|
|
11
|
-
initialCapacity?: number;
|
|
12
|
-
};
|
|
13
|
-
export type SerializedGraph<TNode, TEdgeType extends number = NullEdgeType> = {
|
|
14
|
-
nodes: Array<TNode | null>;
|
|
15
|
-
adjacencyList: SerializedAdjacencyList<TEdgeType>;
|
|
16
|
-
rootNodeId: NodeId | null | undefined;
|
|
17
|
-
};
|
|
18
|
-
export type AllEdgeTypes = -1;
|
|
19
|
-
export declare const ALL_EDGE_TYPES: AllEdgeTypes;
|
|
20
|
-
/**
|
|
21
|
-
* Options for DFS traversal.
|
|
22
|
-
*/
|
|
23
|
-
export type DFSParams<TContext> = {
|
|
24
|
-
visit: GraphVisitor<NodeId, TContext>;
|
|
25
|
-
/**
|
|
26
|
-
* Custom function to get next entries to visit.
|
|
27
|
-
*
|
|
28
|
-
* This can be a performance bottleneck as arrays are created on every node visit.
|
|
29
|
-
*
|
|
30
|
-
* @deprecated This will be replaced by a static `traversalType` set of orders in the future
|
|
31
|
-
*
|
|
32
|
-
* Currently, this is only used in 3 ways:
|
|
33
|
-
*
|
|
34
|
-
* - Traversing down the tree (normal DFS)
|
|
35
|
-
* - Traversing up the tree (ancestors)
|
|
36
|
-
* - Filtered version of traversal; which does not need to exist at the DFS level as the visitor
|
|
37
|
-
* can handle filtering
|
|
38
|
-
* - Sorted traversal of BundleGraph entries, which does not have a clear use-case, but may
|
|
39
|
-
* not be safe to remove
|
|
40
|
-
*
|
|
41
|
-
* Only due to the latter we aren't replacing this.
|
|
42
|
-
*/
|
|
43
|
-
getChildren: (nodeId: NodeId) => Array<NodeId>;
|
|
44
|
-
startNodeId?: NodeId | null | undefined;
|
|
45
|
-
};
|
|
46
|
-
export default class Graph<TNode, TEdgeType extends number = NullEdgeType> {
|
|
47
|
-
nodes: Array<TNode | null>;
|
|
48
|
-
adjacencyList: AdjacencyList<TEdgeType>;
|
|
49
|
-
rootNodeId: NodeId | null | undefined;
|
|
50
|
-
_visited: BitSet | null | undefined;
|
|
51
|
-
constructor(opts?: GraphOpts<TNode, TEdgeType> | null);
|
|
52
|
-
setRootNodeId(id?: NodeId | null): void;
|
|
53
|
-
static deserialize<TNode, TEdgeType extends number = NullEdgeType>(opts: GraphOpts<TNode, TEdgeType>): Graph<TNode, TEdgeType>;
|
|
54
|
-
serialize(): SerializedGraph<TNode, TEdgeType>;
|
|
55
|
-
getAllEdges(): Iterator<Edge<TEdgeType | NullEdgeType>>;
|
|
56
|
-
addNode(node: TNode): NodeId;
|
|
57
|
-
hasNode(id: NodeId): boolean;
|
|
58
|
-
getNode(id: NodeId): TNode | null | undefined;
|
|
59
|
-
addEdge(from: NodeId, to: NodeId, type?: TEdgeType | NullEdgeType): boolean;
|
|
60
|
-
hasEdge(from: NodeId, to: NodeId, type?: TEdgeType | NullEdgeType | Array<TEdgeType | NullEdgeType>): boolean;
|
|
61
|
-
forEachNodeIdConnectedTo(to: NodeId, fn: (nodeId: NodeId) => boolean | undefined, type?: AllEdgeTypes | TEdgeType | NullEdgeType): void;
|
|
62
|
-
forEachNodeIdConnectedFrom(from: NodeId, fn: (nodeId: NodeId) => void, type?: AllEdgeTypes | TEdgeType | NullEdgeType): void;
|
|
63
|
-
getNodeIdsConnectedTo(nodeId: NodeId, type?: TEdgeType | NullEdgeType | Array<TEdgeType | NullEdgeType> | AllEdgeTypes): Array<NodeId>;
|
|
64
|
-
getNodeIdsConnectedFrom(nodeId: NodeId, type?: TEdgeType | NullEdgeType | Array<TEdgeType | NullEdgeType> | AllEdgeTypes): Array<NodeId>;
|
|
65
|
-
removeNode(nodeId: NodeId, removeOrphans?: boolean): void;
|
|
66
|
-
removeEdges(nodeId: NodeId, type?: TEdgeType | NullEdgeType): void;
|
|
67
|
-
removeEdge(from: NodeId, to: NodeId, type?: TEdgeType | NullEdgeType, removeOrphans?: boolean): void;
|
|
68
|
-
_removeEdge(from: NodeId, to: NodeId, type?: TEdgeType | NullEdgeType, removeOrphans?: boolean): void;
|
|
69
|
-
isOrphanedNode(nodeId: NodeId): boolean;
|
|
70
|
-
updateNode(nodeId: NodeId, node: TNode): void;
|
|
71
|
-
replaceNodeIdsConnectedTo(fromNodeId: NodeId, toNodeIds: ReadonlyArray<NodeId>, replaceFilter?: null | ((arg1: NodeId) => boolean), type?: TEdgeType | NullEdgeType, removeOrphans?: boolean): void;
|
|
72
|
-
traverse<TContext>(visit: GraphVisitor<NodeId, TContext>, startNodeId?: NodeId | null, type?: TEdgeType | NullEdgeType | Array<TEdgeType | NullEdgeType> | AllEdgeTypes): TContext | null | undefined;
|
|
73
|
-
filteredTraverse<TValue, TContext>(filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined, visit: GraphVisitor<TValue, TContext>, startNodeId?: NodeId | null, type?: TEdgeType | Array<TEdgeType | NullEdgeType> | AllEdgeTypes): TContext | null | undefined;
|
|
74
|
-
traverseAncestors<TContext>(startNodeId: NodeId | null | undefined, visit: GraphVisitor<NodeId, TContext>, type?: TEdgeType | NullEdgeType | Array<TEdgeType | NullEdgeType> | AllEdgeTypes): TContext | null | undefined;
|
|
75
|
-
dfsFast<TContext>(visit: GraphTraversalCallback<NodeId, TContext>, startNodeId?: NodeId | null): TContext | null | undefined;
|
|
76
|
-
postOrderDfsFast(visit: GraphTraversalCallback<NodeId, TraversalActions>, startNodeId?: NodeId | null): void;
|
|
77
|
-
/**
|
|
78
|
-
* Iterative implementation of DFS that supports all use-cases.
|
|
79
|
-
*
|
|
80
|
-
* This replaces `dfs` and will replace `dfsFast`.
|
|
81
|
-
*/
|
|
82
|
-
dfs<TContext>({ visit, startNodeId, getChildren, }: DFSParams<TContext>): TContext | null | undefined;
|
|
83
|
-
bfs(visit: (nodeId: NodeId) => boolean | null | undefined): NodeId | null | undefined;
|
|
84
|
-
topoSort(type?: TEdgeType): Array<NodeId>;
|
|
85
|
-
findAncestor(nodeId: NodeId, fn: (nodeId: NodeId) => boolean): NodeId | null | undefined;
|
|
86
|
-
findAncestors(nodeId: NodeId, fn: (nodeId: NodeId) => boolean): Array<NodeId>;
|
|
87
|
-
findDescendant(nodeId: NodeId, fn: (nodeId: NodeId) => boolean): NodeId | null | undefined;
|
|
88
|
-
findDescendants(nodeId: NodeId, fn: (nodeId: NodeId) => boolean): Array<NodeId>;
|
|
89
|
-
_assertHasNodeId(nodeId: NodeId): void;
|
|
90
|
-
}
|
|
91
|
-
export declare function mapVisitor<NodeId, TValue, TContext>(filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined, visit: GraphVisitor<TValue, TContext>): GraphVisitor<NodeId, TContext>;
|
package/lib/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { NodeId, ContentKey, Edge } from './types';
|
|
2
|
-
export type { GraphOpts } from './Graph';
|
|
3
|
-
export type { ContentGraphOpts, SerializedContentGraph } from './ContentGraph';
|
|
4
|
-
export { toNodeId, fromNodeId } from './types';
|
|
5
|
-
export { default as Graph, ALL_EDGE_TYPES, mapVisitor } from './Graph';
|
|
6
|
-
export { default as ContentGraph } from './ContentGraph';
|
|
7
|
-
export { BitSet } from './BitSet';
|
package/lib/shared-buffer.d.ts
DELETED
package/lib/types.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type NodeId = number;
|
|
2
|
-
export declare function toNodeId(x: number): NodeId;
|
|
3
|
-
export declare function fromNodeId(x: NodeId): number;
|
|
4
|
-
export type ContentKey = string;
|
|
5
|
-
export type Edge<TEdgeType extends number> = {
|
|
6
|
-
from: NodeId;
|
|
7
|
-
to: NodeId;
|
|
8
|
-
type: TEdgeType;
|
|
9
|
-
};
|
package/tsconfig.json
DELETED