egraph 4.0.1-alpha.8 → 6.0.0-alpha.0

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.
Binary file
package/package.json CHANGED
@@ -1,27 +1,40 @@
1
1
  {
2
2
  "name": "egraph",
3
- "version": "4.0.1-alpha.8",
4
- "description": "",
5
- "main": "index.js",
6
- "module": "index.js",
7
- "unpkg": "umd/egraph.js",
8
- "files": [
9
- "index.js",
10
- "graph.js",
11
- "umd"
3
+ "collaborators": [
4
+ "Yosuke Onoue <onoue@likr-lab.com>"
12
5
  ],
13
- "scripts": {
14
- "prepublish": "rollup -c && cp node_modules/egraph-wasm/dist/web/egraph_wasm_bg.wasm umd/egraph_bg.wasm"
15
- },
16
- "keywords": [],
17
- "author": "Yosuke Onoue <onoue@likr-lab.com>",
6
+ "description": "WebAssembly binding of egraph.",
7
+ "version": "6.0.0-alpha.0",
18
8
  "license": "MIT",
19
- "dependencies": {
20
- "egraph-wasm": "^4.0.1-alpha.8"
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/likr/egraph-rs/tree/master/crates/wasm"
21
12
  },
13
+ "files": [
14
+ "dist/bundler/egraph_wasm_bg.wasm",
15
+ "dist/bundler/egraph_wasm.js",
16
+ "dist/bundler/egraph_wasm.d.ts",
17
+ "dist/no-modules/egraph_wasm_bg.wasm",
18
+ "dist/no-modules/egraph_wasm.js",
19
+ "dist/no-modules/egraph_wasm.d.ts",
20
+ "dist/nodejs/egraph_wasm_bg.wasm",
21
+ "dist/nodejs/egraph_wasm.js",
22
+ "dist/nodejs/egraph_wasm.d.ts",
23
+ "dist/web/egraph_wasm_bg.wasm",
24
+ "dist/web/egraph_wasm.js",
25
+ "dist/web/egraph_wasm.d.ts",
26
+ "umd"
27
+ ],
28
+ "main": "dist/nodejs/egraph_wasm.js",
29
+ "module": "dist/bundler/egraph_wasm.js",
30
+ "unpkg": "umd/egraph.js",
31
+ "types": "dist/bundler/egraph_wasm.d.ts",
32
+ "sideEffects": "false",
22
33
  "devDependencies": {
23
- "rollup": "^1.16.7",
24
- "rollup-plugin-node-resolve": "^5.2.0"
34
+ "rollup": "^2.52.2"
25
35
  },
26
- "gitHead": "78dcfc266f97b9a5d2760d48e7e89e5541ffd9e7"
36
+ "scripts": {
37
+ "build-umd": "rollup -c && cp dist/web/egraph_wasm_bg.wasm umd/egraph_bg.wasm",
38
+ "prepublish": "npm run build-umd"
39
+ }
27
40
  }
package/graph.js DELETED
@@ -1,167 +0,0 @@
1
- const privates = new WeakMap()
2
-
3
- const p = (self) => privates.get(self)
4
-
5
- const checkNode = (graph, u) => {
6
- if (!p(graph).nodes.has(u)) {
7
- throw new Error(`Invalid node: ${u}`)
8
- }
9
- }
10
-
11
- export class Graph {
12
- constructor() {
13
- privates.set(this, {
14
- nodes: new Map(),
15
- numNodes: 0,
16
- numEdges: 0
17
- })
18
- }
19
-
20
- node(u) {
21
- const nodes = p(this).nodes
22
- if (nodes.get(u)) {
23
- return nodes.get(u).data
24
- }
25
- return null
26
- }
27
-
28
- edge(u, v) {
29
- const nodes = p(this).nodes
30
- if (nodes.get(u) && nodes.get(u).outNodes.get(v)) {
31
- return nodes.get(u).outNodes.get(v)
32
- }
33
- return null
34
- }
35
-
36
- *nodes() {
37
- for (const key of p(this).nodes.keys()) {
38
- yield key
39
- }
40
- }
41
-
42
- *edges() {
43
- for (const u of this.nodes()) {
44
- for (const v of this.outNodes(u)) {
45
- yield [u, v]
46
- }
47
- }
48
- }
49
-
50
- *outNodes(u) {
51
- checkNode(this, u)
52
- for (const key of p(this)
53
- .nodes.get(u)
54
- .outNodes.keys()) {
55
- yield key
56
- }
57
- }
58
-
59
- *inNodes(u) {
60
- checkNode(this, u)
61
- for (const key of p(this)
62
- .nodes.get(u)
63
- .inNodes.keys()) {
64
- yield key
65
- }
66
- }
67
-
68
- *outEdges(u) {
69
- for (const v of this.outNodes(u)) {
70
- yield [u, v]
71
- }
72
- }
73
-
74
- *inEdges(u) {
75
- for (const v of this.inNodes(u)) {
76
- yield [v, u]
77
- }
78
- }
79
-
80
- nodeCount() {
81
- return p(this).numNodes
82
- }
83
-
84
- edgeCount() {
85
- return p(this).numEdges
86
- }
87
-
88
- outDegree(u) {
89
- checkNode(this, u)
90
- return p(this).nodes.get(u).outNodes.size
91
- }
92
-
93
- inDegree(u) {
94
- checkNode(this, u)
95
- return p(this).nodes.get(u).inNodes.size
96
- }
97
-
98
- addNode(u, obj = {}) {
99
- if (this.node(u)) {
100
- throw new Error(`Duplicated node: ${u}`)
101
- }
102
- p(this).nodes.set(u, {
103
- outNodes: new Map(),
104
- inNodes: new Map(),
105
- data: obj
106
- })
107
- p(this).numNodes++
108
- return this
109
- }
110
-
111
- addEdge(u, v, obj = {}) {
112
- checkNode(this, u)
113
- checkNode(this, v)
114
- if (this.edge(u, v)) {
115
- throw new Error(`Duplicated edge: (${u}, ${v})`)
116
- }
117
- p(this).numEdges++
118
- p(this)
119
- .nodes.get(u)
120
- .outNodes.set(v, obj)
121
- p(this)
122
- .nodes.get(v)
123
- .inNodes.set(u, obj)
124
- return this
125
- }
126
-
127
- removeNode(u) {
128
- for (const v of this.outNodes(u)) {
129
- this.removeEdge(u, v)
130
- }
131
- for (const v of this.inNodes(u)) {
132
- this.removeEdge(v, u)
133
- }
134
- p(this).nodes.delete(u)
135
- p(this).numNodes--
136
- return this
137
- }
138
-
139
- removeEdge(u, v) {
140
- if (this.edge(u, v) === null) {
141
- throw Error(`Invalid edge: (${u}, ${v})`)
142
- }
143
- p(this)
144
- .nodes.get(u)
145
- .outNodes.delete(v)
146
- p(this)
147
- .nodes.get(v)
148
- .inNodes.delete(u)
149
- p(this).numEdges--
150
- return this
151
- }
152
-
153
- toJSON() {
154
- return {
155
- nodes: Array.from(this.nodes()).map((u) =>
156
- Object.assign(this.node(u), { id: u })
157
- ),
158
- links: Array.from(this.edges()).map(([u, v]) =>
159
- Object.assign(this.edge(u, v), { source: u, target: v })
160
- )
161
- }
162
- }
163
-
164
- toString() {
165
- return JSON.stringify(this.toJSON())
166
- }
167
- }
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './graph'
2
- export * from 'egraph-wasm'