Skip to content

Commit 5e35bb2

Browse files
committed
feat!: remove graph constructor capability to deserialize data
1 parent 36faa6a commit 5e35bb2

2 files changed

Lines changed: 2 additions & 16 deletions

File tree

src/Graph.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { invariant } from './invariant.js';
2-
import { EdgeWeight, SerializedInput } from './types.js';
3-
import { deserializeGraph } from './utils/deserializeGraph.js';
2+
import { EdgeWeight } from './types.js';
43

54
export class Graph<Node = string, LinkProps = never> {
65
/**
@@ -26,12 +25,6 @@ export class Graph<Node = string, LinkProps = never> {
2625
*/
2726
edgeProperties: Map<Node, Map<Node, LinkProps>> = new Map();
2827

29-
constructor(serialized?: SerializedInput<Node, LinkProps>) {
30-
if (serialized) {
31-
return deserializeGraph(serialized);
32-
}
33-
}
34-
3528
/**
3629
* Adds a node to the graph.
3730
* If node was already added, this function does nothing.

src/utils/deserializeGraph.spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ describe('serializeGraph', () => {
1414
checkSerialized(serializeGraph(graph));
1515
});
1616

17-
it('should deserialize a graph passed to constructor', () => {
18-
const g = new Graph<string>().addEdge('a', 'b').addEdge('b', 'c');
19-
const serialized = serializeGraph(g);
20-
const graph = new Graph(serialized);
21-
checkSerialized(serializeGraph(graph));
22-
});
23-
2417
it('should not duplicate nodes when they are objects', () => {
2518
const nodeA = { id: 1, title: 'a' };
2619
const nodeB = { id: 2, title: 'b' };
@@ -61,6 +54,6 @@ describe('serializeGraph', () => {
6154
};
6255

6356
// @ts-expect-error Missing identity function
64-
const graph = deserializeGraph(serialized);
57+
deserializeGraph(serialized);
6558
});
6659
});

0 commit comments

Comments
 (0)