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

libavoided-js

v0.1.2

Published

Deterministic orthogonal edge router with obstacle avoidance

Readme

libavoided-js

Deterministic orthogonal edge router with obstacle avoidance. Zero dependencies.

Install

npm install libavoided-js

Quick Example

import { routeEdges } from 'libavoided-js';

const result = routeEdges({
  obstacles: [
    { id: 'A', x: 0, y: 0, width: 100, height: 60 },
    { id: 'B', x: 300, y: 0, width: 100, height: 60 },
  ],
  edges: [{
    id: 'e1',
    sourceId: 'A',
    targetId: 'B',
    sourcePoint: { x: 100, y: 30 },
    targetPoint: { x: 300, y: 30 },
  }],
}, {
  obstacleMargin: 10,
  bendPenalty: 50,
});

const section = result.edges[0].sections[0];
// section.startPoint, section.bendPoints, section.endPoint

Compat API

An OOP adapter matching libavoid's class names and method signatures is available at libavoided-js/compat.

import {
  Router, ShapeRef, ConnRef, ConnEnd,
  Rectangle, RouterFlag, ConnDirFlag, RoutingParameter,
} from 'libavoided-js/compat';

const router = new Router(RouterFlag.OrthogonalRouting);
router.setRoutingParameter(RoutingParameter.shapeBufferDistance, 10);

const s1 = new ShapeRef(router, new Rectangle({ x: 0, y: 0 }, { x: 100, y: 60 }));
const s2 = new ShapeRef(router, new Rectangle({ x: 300, y: 0 }, { x: 400, y: 60 }));

const conn = new ConnRef(
  router,
  new ConnEnd({ x: 100, y: 30 }, ConnDirFlag.Right),
  new ConnEnd({ x: 300, y: 30 }, ConnDirFlag.Left),
);

router.processTransaction();

const route = conn.route(); // PolyLine
// route.ps → [{x, y}, ...]

API Reference

Core (libavoided-js)

routeEdges(input, options?)

Routes all edges, returning orthogonal paths that avoid obstacles.

  • input{ obstacles: Obstacle[], edges: EdgeRequest[] }
  • optionsRouterOptions (all optional)
  • returns{ edges: RoutedEdge[] }

routeEdgesIncremental(input, previousInput, previousOutput, options?)

Incremental routing that reuses unchanged edges from a previous result.

Types

| Type | Fields | |------|--------| | Obstacle | id, x, y, width, height | | EdgeRequest | id, sourceId, targetId, sourcePoint, targetPoint, sourceDirection?, targetDirection?, pinnedWaypoints?, previousPath? | | RoutedEdge | id, sections[] — each with startPoint, endPoint, bendPoints[], incomingShape, outgoingShape | | CardinalDirection | 'up' \| 'down' \| 'left' \| 'right' |

RouterOptions

| Option | Default | Description | |--------|---------|-------------| | obstacleMargin | 10 | Buffer around obstacles | | edgeSpacing | 8 | Space between parallel segments | | bendPenalty | 50 | Cost per direction change | | crossingPenalty | 200 | Cost per edge crossing | | lengthPenalty | 1 | Cost multiplier for segment length |

Compat (libavoided-js/compat)

OOP facade with libavoid-compatible class names.

| Class | Description | |-------|-------------| | Router(flag) | Main router. Call processTransaction() to route. | | ShapeRef(router, polygon) | Obstacle shape. Auto-registers with router. | | ConnRef(router, srcEnd, dstEnd) | Connector. Call route() after processing. | | ConnEnd(point, directions?) | Connection endpoint with optional direction constraint. | | Rectangle(topLeft, bottomRight) | Axis-aligned rectangle. | | Polygon(points?) | Arbitrary polygon (bounding box used for routing). | | PolyLine(points?) | Routed path result. |

| Enum | Values | |------|--------| | RouterFlag | OrthogonalRouting = 2 | | ConnDirFlag | None, Up, Down, Left, Right, All | | RoutingParameter | segmentPenalty, crossingPenalty, shapeBufferDistance, idealNudgingDistance, ... |

License

MIT