-
Notifications
You must be signed in to change notification settings - Fork 150
JS to TS : simulator/src/data/load.ts #422 #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2ef15d2
d23d0b6
42aef0f
9f29538
72eef2d
f3cb84d
aedba88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,8 +1,46 @@ | ||||||||||||||||||||||
import { setup } from './setup' | ||||||||||||||||||||||
import { setup } from './setup'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
// Define interfaces for the structure | ||||||||||||||||||||||
interface Device { | ||||||||||||||||||||||
type: 'Input' | 'Output' | 'Memory'; | ||||||||||||||||||||||
net: string; | ||||||||||||||||||||||
order?: number; | ||||||||||||||||||||||
bits: number; | ||||||||||||||||||||||
label?: string; | ||||||||||||||||||||||
abits?: number; | ||||||||||||||||||||||
words?: number; | ||||||||||||||||||||||
offset?: number; | ||||||||||||||||||||||
rdports?: Array<{ | ||||||||||||||||||||||
clock_polarity?: boolean; | ||||||||||||||||||||||
}>; | ||||||||||||||||||||||
wrports?: Array<{ | ||||||||||||||||||||||
clock_polarity?: boolean; | ||||||||||||||||||||||
}>; | ||||||||||||||||||||||
memdata?: (number | string)[]; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
interface Connector { | ||||||||||||||||||||||
to: { | ||||||||||||||||||||||
id: string; | ||||||||||||||||||||||
port: string; | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
from: { | ||||||||||||||||||||||
id: string; | ||||||||||||||||||||||
port: string; | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
name: string; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
interface Circuit { | ||||||||||||||||||||||
devices: Record<string, Device>; | ||||||||||||||||||||||
connectors: Connector[]; | ||||||||||||||||||||||
subcircuits: Record<string, unknown>; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+34
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid using The interface Circuit {
devices: Record<string, Device>;
connectors: Connector[];
- subcircuits: Record<string, unknown>;
+ subcircuits: Record<string, Circuit>;
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
document.addEventListener('DOMContentLoaded', () => { | ||||||||||||||||||||||
setup() | ||||||||||||||||||||||
var js = { | ||||||||||||||||||||||
setup(); | ||||||||||||||||||||||
|
||||||||||||||||||||||
const js: Circuit = { | ||||||||||||||||||||||
devices: { | ||||||||||||||||||||||
dev0: { | ||||||||||||||||||||||
type: 'Input', | ||||||||||||||||||||||
|
@@ -206,5 +244,5 @@ document.addEventListener('DOMContentLoaded', () => { | |||||||||||||||||||||
}, | ||||||||||||||||||||||
], | ||||||||||||||||||||||
subcircuits: {}, | ||||||||||||||||||||||
} | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
}); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Expand device types and add JSDoc documentation.
The
Device
interface has a limited set of device types and lacks documentation for complex fields.📝 Committable suggestion