node-astar
node-astar copied to clipboard
async version
I've got a local promise-based asynchronous version using Q, but it'd take a little finagling to let it share the same implementation with the synchronous version. I don't think A* needs to be synchronous though because it's so slow. Word?
:point_right: erisdiscord@4599ca526517a199a5b629f6eef73a4b5620a6ba
that's cool that it doesn't eat the event loop, but it's still doing the processing in the main thread. It's not really a satisfying solution.
At least this sync version can be used with browser games, for example.
I think it's good enough for cases where you just don't want to block (think of mineflayer, where a poorly timed pathfinding operation could result in a connection timeout). Agree that it's not ideal.
Q.js works in the browser too—you'd just need to replace setImmediate(iterate) in my branch with setTimeout(iterate, 0). I suppose I can see your point, though. I could probably throw together a callback-based interface that could be called synchronously.
It's a hard problem. I agree that your version works better than a pure sync version like this in some use cases.