Naughty Pinching Mannequins

    TypeScript icon, indicating that this package has built-in type declarations

    0.2.4 • Public • Published

    A Star

    Downloads Size

    npm install @decoy9697/a-star

    The library presumes you have some kind of linked structure with a start Node and a goal Node. The Node structure can be whatever you like.


    You will need to provide an options object to the aStar function, with the following keys:

    Key Type Description
    start Node The starting node
    goal Node The goal node. The algorithm will attempt to make an array of nodes from the start to the goal.
    getNeighbours Node => Array<Node> A function that finds the directly connected nodes for a given node
    eqNode (Node, Node) => boolean A function for comparing two nodes (true if they are the same)
    heuristic (Node, Node) => number A function that determines the cost of travelling from one node to the other.

    Return type

    Key Type Description
    path Array<Node> The path from the start to the goal (if possible)
    reachedGoal boolean true, given the algorithm found a path from start to goal


    import aStar from "@decoy9697/a-star";
    const result = aStar({
      start: node0,
      goal: node43,
      getNeighbours: (node) => { ... },
      eqNode: (nodeA, nodeB) => { ... },
      heuristic: (nodeA, nodeB ) => { ... }
    if (result.reachedGoal) {
      console.log('Path': result.path);
      } else {
      console.log('Did not reach goal');


    npm i @decoy9697/a-star

    DownloadsWeekly Downloads






    Unpacked Size

    6.76 kB

    Total Files


    Last publish


    • decoy9697