npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rulecad/smooth

v0.3.0

Published

Autorouted circuit-board tracks pulled tight: wiggles, detours and doubling-backs straightened wherever the straight run keeps its clearance. Only bend points are dropped, so ends, vias and every other track stay put. Works on Circuit JSON (tscircuit) or

Readme

@rulecad/smooth

Autorouted circuit-board tracks, pulled tight. An autorouter searching a grid leaves wiggles, small detours, hooks and places where a track doubles back on itself. smooth() straightens them:

  • Pulling tight: along each track, it joins each point it keeps straight to the farthest point after it that it can reach with clearance, and drops the bend points in between. It repeats until nothing changes.
  • Sharp bends: a bend sharper than a right angle (a hook, or a spike out and back) is cut across, as far back as the cut keeps its clearance.
  • Never worse: a new straight run must keep its clearance from all other copper, holes and the board's edge, or at least come no closer to anything than the stretch it replaces already did. So a track the router packed in tight can still be tidied, and nothing ends up closer than before.

A track's ends and vias stay exactly where they were, so it still starts and finishes on the same pads and changes layer in the same places. Tracks you don't pass in are never moved, only kept clear of. No dependencies.

Lead-ins: a track may carry on from copper you keep, such as a stub of an earlier board's routing. Pass it as the track's leads ({ start, end }, points from the stub's root to the track's end). Where the track turns straight back on it, it is cut back to where the track can leave cleanly, never into its first segment. trimmed then says what's left of it, so you can shorten that copper to match.

import { smoothCircuit } from '@rulecad/smooth';

// Circuit JSON (tscircuit's board format): pick the tracks that may change
const { json, changed, dropped, trimmed } = smoothCircuit(circuitJson, { movable: (trace) => trace.autorouted, clearance: 0.15, leads });
  • Clearance: copper to copper is clearance (default: the board's min_trace_to_pad_edge_clearance, else 0.1 mm). Holes keep min_trace_to_hole_edge_clearance (0.2 mm) from their edge. The board's edge keeps min_board_edge_clearance (0.2 mm), measured to the outline, or to the board's rectangle.
  • Nets: copper of a track's own net isn't in its way. Nets come from the board's source traces.
  • What's in the way: pads (rectangles, turned rectangles, circles, pills, polygons), plated holes and their pads, vias, mounting holes (with rulecad_keepout, a screw head's room, from the centre), and every other track.
  • Runs: a track is pulled tight one run at a time. A run is the points on one layer at one width, so a via or a necked-down stretch stays where it is.
  • Result: json is a copy with the changed tracks replaced. routes maps each changed track's pcb_trace_id to its new route.

For any other board description, smooth(tracks, obstacles, { clearance, outline, edge }) does the geometry: tracks are { route, net }, and obstacles are { layer, net, shape }. A shape is { circle: { x, y, r } }, { capsule: { a, b, r } } or { polygon: [{ x, y }, ...] }. The layer may be '*' for every layer, and an optional clear overrides the clearance.

Finishing: square exits and no acute angles

finishCircuit(json, { movable, clearance, stubs }) finishes a board's tracks the way a fab's engineer asks:

  • Square exits: a track leaving a surface-mount pad at an angle is redrawn to leave straight out of the pad's nearest edge, for a short run past it (stubs, tried longest first: 0.3, 0.2, 0.12 mm) before it turns, never through a new bend sharper than a right angle. A small part whose tracks pull off its pads at an angle can be drawn up on one end as its solder melts (tombstoning); square exits pull evenly.
  • Acute corners: where two tracks of a net meet at under 90° (a bend, a junction, at a via or a pad), a short piece of the same copper is laid across the corner, so the notch between them, where etchant pools (an acid trap), becomes two obtuse corners. A corner whose notch is already inside copper of its net (a pad, a via) isn't one.
  • Every new piece keeps the board's clearance from all other copper and the edge. What it can't finish is in left.

It returns { json, exits, fills, left }. A redrawn kept track (rulecad_kept) carries its first shape as rulecad_squared; fill copper is a track of its own, marked rulecad_fill. unfinished(json) lists what a board still has: { exits, acute }, for checks.

The straight runs can be at any angle; they aren't snapped to 45°. Check the board again after smoothing, as with any change to copper. @rulecad/pcb does that itself: with smooth: true, it smooths the router's tracks, and puts back any track the design checks then find in a new error.