circuit-json-to-connectivity-map 0.0.4 → 0.0.6

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.
Files changed (2) hide show
  1. package/README.md +52 -17
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,20 +1,21 @@
1
1
  # Circuit JSON to Connectivity Map
2
2
 
3
- This project provides utilities to generate connectivity maps from circuit JSON data. It's designed to work with the `@tscircuit/soup` library and offers functionality to find connected networks and create source port connectivity maps.
4
-
5
- ## Features
6
-
7
- - Find connected networks from a list of connections
8
- - Generate source port connectivity maps from circuit JSON data
3
+ This library provides utilities to generate connectivity maps from circuit JSON data. It's designed to work with the `@tscircuit/soup` library and offers functionality to find connected networks and create connectivity maps.
9
4
 
10
5
  ## Installation
11
6
 
12
- To install dependencies:
7
+ To install the library, use npm or bun:
13
8
 
14
9
  ```bash
15
- bun install
10
+ npm add circuit-json-to-connectivity-map
16
11
  ```
17
12
 
13
+ ## Features
14
+
15
+ - Find connected networks from a list of connections
16
+ - Generate source port connectivity maps from circuit JSON data
17
+ - Generate full connectivity maps from circuit JSON data
18
+
18
19
  ## Usage
19
20
 
20
21
  ### Finding Connected Networks
@@ -30,6 +31,12 @@ const connections = [
30
31
 
31
32
  const result = findConnectedNetworks(connections)
32
33
  console.log(result)
34
+
35
+ // Output:
36
+ // {
37
+ // connectivity_net0: ["A", "B", "C"],
38
+ // connectivity_net3: ["D", "E"],
39
+ // }
33
40
  ```
34
41
 
35
42
  ### Generating Source Port Connectivity Map
@@ -43,7 +50,15 @@ const circuitJson: AnySoupElement[] = [
43
50
  ]
44
51
 
45
52
  const connectivityMap = getSourcePortConnectivityMapFromCircuitJson(circuitJson)
46
- console.log(connectivityMap)
53
+
54
+ // Check if two IDs are connected
55
+ console.log(connectivityMap.areIdsConnected("port1", "port2"))
56
+
57
+ // Get all IDs connected to a specific net
58
+ console.log(connectivityMap.getIdsConnectedToNet("net1"))
59
+
60
+ // Get the net connected to a specific ID
61
+ console.log(connectivityMap.getNetConnectedToId("port1"))
47
62
  ```
48
63
 
49
64
  ### Generating Full Connectivity Map
@@ -57,22 +72,42 @@ const circuitJson: AnySoupElement[] = [
57
72
  ]
58
73
 
59
74
  const fullConnectivityMap = getFullConnectivityMapFromCircuitJson(circuitJson)
60
- console.log(fullConnectivityMap)
61
- ```
62
75
 
63
- ## Running Tests
76
+ // Check if two IDs are connected (including PCB elements)
77
+ console.log(fullConnectivityMap.areIdsConnected("smtpad1", "port1"))
64
78
 
65
- To run the tests:
79
+ // Get all IDs connected to a specific net
80
+ console.log(fullConnectivityMap.getIdsConnectedToNet("net1"))
66
81
 
67
- ```bash
68
- bun test
82
+ // Get the net connected to a specific ID
83
+ console.log(fullConnectivityMap.getNetConnectedToId("pcb_port1"))
69
84
  ```
70
85
 
71
- This will run all tests, including the newly added test for `getFullConnectivityMapFromCircuitJson`.
86
+ ## API Reference
87
+
88
+ ### `findConnectedNetworks(connections: Array<string[]>): Record<string, string[]>`
89
+
90
+ Finds connected networks from a list of connections.
91
+
92
+ ### `getSourcePortConnectivityMapFromCircuitJson(circuitJson: AnySoupElement[]): ConnectivityMap`
93
+
94
+ Generates a source port connectivity map from circuit JSON data.
95
+
96
+ ### `getFullConnectivityMapFromCircuitJson(circuitJson: AnySoupElement[]): ConnectivityMap`
97
+
98
+ Generates a full connectivity map from circuit JSON data, including PCB elements.
99
+
100
+ ### `ConnectivityMap`
101
+
102
+ A class representing the connectivity map with methods:
103
+
104
+ - `areIdsConnected(id1: string, id2: string): boolean`
105
+ - `getIdsConnectedToNet(netId: string): string[]`
106
+ - `getNetConnectedToId(id: string): string | undefined`
72
107
 
73
108
  ## Development
74
109
 
75
- This project uses [Bun](https://bun.sh) as its JavaScript runtime. Bun is a fast all-in-one JavaScript runtime.
110
+ This project uses [Bun](https://bun.sh) as its JavaScript runtime.
76
111
 
77
112
  To start development:
78
113
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "circuit-json-to-connectivity-map",
3
- "module": "dist/index.js",
3
+ "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.4",
5
+ "version": "0.0.6",
6
6
  "files": [
7
7
  "dist"
8
8
  ],