easystarjs icon indicating copy to clipboard operation
easystarjs copied to clipboard

Add findPathSync to find & calculate a path then return the result directly

Open mikedevelops opened this issue 7 years ago • 1 comments

The proposal is an implementation similar to (https://github.com/prettymuchbryce/easystarjs/pull/54).

This change would not remove or modify from the existing public API or existing enableSync() method. It adds an additional method to the public API that allows users to find a path and calculate it's route truly synchronously with no callback.

Example usage...

var easyStar = new EasyStar.js();
var grid = [
    [0, 1, 0],
    [0, 0, 0],
    [0, 0, 0],
];
easyStar.setGrid(grid);
easyStar.setAcceptableTiles([0]);

const path = easyStar.findPathSync(0, 0, 1, 1); // your path array or null

I've done some semicolon and JSDoc housekeeping along the way, as well as added tests for the existing enableSync() behaviour.

mikedevelops avatar Apr 11 '18 09:04 mikedevelops

Thanks very much for the change. This is looking great! Just a couple of small comments around the Zalgo stuff. Thanks for the additional cleanup as well!

Could you bump the minor version in package.json and change it throughout the code? It's kind of annoying right now, as you need to change it in a number of places, so alternatively you could simply remove the files changed in bin and I can create the built files when I go to bump the version and release.

prettymuchbryce avatar Apr 11 '18 14:04 prettymuchbryce