A* algorithm javascript implementation