New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

a-star-algo

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-star-algo

Fairly generic A* implementation

latest
Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

A*

A slightly opinionated, cleaned-up version of A-Star implementation

Install

npm install a-star-algo

How to use

const aStar = require('a-star-algo')

// Abuse the fact that objects are call-by-sharing ("pass by reference" with some differences) to chain everything together.
// You have to do it this way for now, or you can submit a PR to add something like https://www.npmjs.com/package/graph-data-structure in. ;)
elements.end = {
  id: 4,
  neighbors: [ elements.middle1 ]
}

elements.middle1 = {
  id: 2,
  neighbors: [ elements.end ]
}

elements.middle2 = {
  id: 3,
  neighbors: []
}

elements.start = {
  id: 1,
  neighbors: [ elements.middle1, elements.middle2 ]
}

// These are all the parameters available or necessary
const as = new aStar({
    // Which element to start from
    start: elements.start,
    // Which element to end at
    end: elements.end,
    // Heuristic for cost to go between two points
    costEstimate: (to, from) => {
      return 1
    },
    // How far apart two points are
    distance: (to, from) => {
      return 1
    }
  })

// [ 1, 2, 4 ]
const result = as.travel()

Methods

travel()

Call when you are ready to traverse

FAQs

Package last updated on 28 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts