DEV Community

Ankit Chauhan
Ankit Chauhan

Posted on

d3-force-wasm: same output as d3-force to the last bit, ~5 faster, one-line switch

A Zig → WebAssembly port of d3-force. The interesting part is keeping it bit-exact: only correctly rounded float ops in wasm, d3's exact operation order, and an O(n) radix-sort tree build that reproduces d3-quadtree's tree exactly. A parity harness compares every node after every tick; I validated the harness by planting 5 bugs (including a 1-ulp reassociation) and checking it caught them all.

Zero runtime dependencies, wasm inlined, 25 kB on npm.

Demo: https://ankitc1010.github.io/d3-force-wasm/
GitHub: https://github.com/ankitc1010/d3-force-wasm

Top comments (0)