Install
wires is published on npm as @pbzona/wires. It needs Node.js 24, or 26 and later (no end-of-life releases), Bun, or any modern browser or bundler, and it has no runtime dependencies. The package has two entry points:
Build and simulate a circuit
1
Define a primitive gate
A primitive has an explicit evaluation function. Here is NAND, the only gate you need to build everything else.
@pbzona/wires/components exports this exact gate, so the next steps import it from there.2
Compose it into a circuit
A composite circuit adds parts one at a time, saying what feeds each part’s inputs, then says what drives its outputs.Read it top to bottom: the inputs feed
nand, nand feeds not (a NAND with both inputs tied together is a NOT), and not drives the output.3
Simulate it
A simulation is a sequence of states. Time only moves when you call
simulate() gives you the first one, and set() and run() each return a new state. The old state never changes.run() (or step(), which moves one tick).4
Look inside
Every state can report the value of every port in the hierarchy, and with tracing on, every change that led to it.
Next steps
Composing circuits
Builder rules, naming, fan-out and feedback.
Simulation model
How ticks, delays and unknown values work.