JSPM

dewdrops

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 11
    • Score
      100M100P100Q49454F
    • License TBD

    Shortest path between any two nodes in any connected graph. BFS and Dijkstra. Zero dependencies.

    Package Exports

    • dewdrops
    • dewdrops/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dewdrops) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    dewdrops

    Shortest path between any two nodes in any connected graph. BFS and Dijkstra. Zero dependencies.

    npm install dewdrops

    What it dews

    dewdrops is an overlay, not a database. You bring the data. dewdrops brings the topology.

    Point it at any flat data structure with nodes and relationships — a skill tree, a supply chain, a hospital floor plan, a freight network — and dewdrops superimposes a weighted graph on top of it. Your data stays your data. dewdrops is the lens.


    Usage

    import { TreeTopologyHeuristics, TreeNode } from 'dewdrops'
    
    const graph: Record<string, TreeNode> = {
      a: { id: 'a', connections: ['b', 'c'], weights: { b: 1, c: 4 } },
      b: { id: 'b', connections: ['d'], weights: { d: 2 } },
      c: { id: 'c', connections: ['d'], weights: { d: 1 } },
      d: { id: 'd', connections: [], weights: {} },
    }
    
    // Weighted shortest path (Dijkstra)
    const result = TreeTopologyHeuristics.findPath(graph, 'a', 'd')
    console.log(result.path)     // ['a', 'c', 'd']
    console.log(result.distance) // 5
    
    // Nearest node from a set of candidates
    const nearest = TreeTopologyHeuristics.findNearest(graph, 'a', ['c', 'd'])
    console.log(nearest.targetId) // 'c'
    console.log(nearest.distance) // 4

    API

    TreeNode

    interface TreeNode {
      id: string
      connections: string[]
      weights: Record<string, number>
    }

    PathResult

    interface PathResult {
      distance: number  // -1 if unreachable
      path: string[]    // empty if unreachable
    }

    NearestResult

    interface NearestResult {
      targetId: string
      distance: number
      path: string[]
    }

    TreeTopologyHeuristics.findPath(graph, start, target)

    Finds the shortest path between two nodes. Auto-selects BFS (unweighted) or Dijkstra (weighted) based on the graph. Returns PathResult with distance: -1 if unreachable.

    TreeTopologyHeuristics.findNearest(graph, start, candidates)

    Finds the closest node from a list of candidates. Returns NearestResult.

    TreeTopologyHeuristics.calculateGraphDistance(graph, start, target)

    Returns the shortest distance as a float. Returns -1 if unreachable.


    The two layers

    dewdrops always works on two layers:

    1. Your flat data — the source of truth. JSON, a database, a game export, whatever you have.
    2. The graph — what dewdrops builds from it. Nodes, edges, weights.

    dewdrops reads both. The flat data is never discarded — it's the context the graph lives on top of. When you apply constraints or query paths, you're querying the overlay, not replacing the source.


    Zero dependencies

    No runtime dependencies. BFS and Dijkstra implemented from scratch. Works in Node, browsers, and any TypeScript environment.


    Part of Dew

    dewdrops is the TypeScript distro of Dew — intent-driven graph routing for any connected system.

    "What do you need it to dew?"