The `javascript-astar` package provides an efficient implementation of the A* search algorithm in JavaScript for finding the shortest path on a grid. Currently at version 0.4.1, it has been optimized to use a Binary Heap, resulting in significant performance improvements over its original list-based approach. The library supports various graph configurations, including weighted nodes and diagonal movement. A weight of 0 for a node designates it as an impassable obstacle, and specific constraints apply to other weight values. It is primarily designed for browser environments via script tags, exposing global variables, and likely supports CommonJS environments for server-side usage, given its version and use of Grunt for tooling.
npm install javascript-astarVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing a graph, performing basic A* search, and utilizing options for diagonal movement and custom node weights.
Upgrade to a newer version (0.4.1 or later) to benefit from the performance improvements. Review existing code for any direct reliance on the internal algorithm structures of versions prior to 0.0.1.
Ensure all graph node weights adhere to the specified rules: `0` for walls, `1` for standard passable nodes, or any number `> 1` (including decimals) for custom movement costs. Avoid negative weights or weights between 0 and 1 (exclusive).
To avoid global conflicts, consider using a module bundler (like Webpack or Rollup) to integrate `javascript-astar` as a module. Alternatively, encapsulate its usage within an Immediately Invoked Function Expression (IIFE) in browser scripts to limit variable scope.
In browsers, ensure `<script src='astar.js'></script>` is present and loaded before your code. In Node.js, use `const { astar } = require('javascript-astar');` (for CJS) or `import { astar } from 'javascript-astar';` (for ESM).In module environments, ensure `Graph` is destructured from the package: `const { Graph } = require('javascript-astar');` or `import { Graph } from 'javascript-astar';`. In browsers, verify the `astar.js` script is loaded to expose the global `Graph`.Review the weights defined in your `Graph` grid. Valid weights are `0` (for walls), `1`, or any number `> 1` (including decimals). Adjust any invalid weight values accordingly.
No dependency data recorded yet.