JavaScritpt implementation of A* algorythm.