add cleanup method to graph, use node v11, fix tests #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
We've been using sharedstreets-js at RideReport for a couple months now, and it's been a great help to build on the shared streets reference system! Thanks all of the work that has gone into this!
I've included a few changes here that we had to make to get sharedstreets-js working for our use cases. Feel free to use these changes, modify them, or ignore them.
test_core
The only real functionality change is adding a
cleanup
method.When a graph is built, it creates a LevelDB database to use. This node process puts a lock on the database, but doesn't release the lock until the node process ends (usually the node script finishes running, or if there's some error). This causes an issue when the same node process wants to get a new graph instance, built off of the same inputs. When a second graph is built with the same input parameters, it attempts to use the existing LevelDB, but sees the lock and throws an error.
This issue can be avoided by calling
.close()
on an open db connection when it's done being used.These changes expose a
.cleanup()
method on theGraph
, that closes the LevelDB connection. Once.cleanup()
is called on an instance, a new instance can be created that accesses the same data. This allows for one continuous process to create and cleanup multiple sharedstreets Graphs.(a lot of whitespace changes got included by my editor, let me know if you want me to remove them)