GitHub user jorgebay opened a pull request:
https://github.com/apache/tinkerpop/pull/450
Javascript GLV
For [TINKERPOP-1489](https://issues.apache.org/jira/browse/TINKERPOP-1489).
- Should work with any ES5 engine that supports CommonJs: tested with
Nashorn and Node.js.
- Maintained the same structure as the Python GLV.
- Used groovy classes to generate all the traversal methods.
- Javascript tests run in the test maven phase (JS test names are not
printed though...)
- Javascript engines are designed to run user code in a single thread, IO
libraries (like libuv on Node.js) are async only. With that in mind, there
isn't sync IO methods exposed in the Traversal (ie: `#next()`, `#toList()`).
Instead I exposed `#list()` and `one()` that take a callback as a parameter:
```javascript
g.V().hasLabel('software').list((err, vertices) => {
vertices.forEach(console.log);
});
g.V().has('name','marko').one((err, vertex) => {
console.log(vertex.label); // person
});
```
This patch is focused in providing a Javascript GLV that would be useful
for most runtimes, most notably Node.js. It implements a Graph, GraphTraversal
and GraphTraversalSource, along with GraphSONReader and GraphSONWriter.
It includes base classes for RemoteConnection, RemoteTraversal and
RemoteStrategy, but doesn't include DriverRemoteConnection implementation as
Javascript engines does not provide a standard IO library.
As a first step, the idea is to include in the TinkerPop project the
specification for the language variant, the serialization functionality and the
execution methods (currently named `list()` and `one()`).
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/jorgebay/tinkerpop javascript-glv
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/tinkerpop/pull/450.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #450
----
commit 5f7a670bceedd0c65f5c1b8e00a06f4d8cdac912
Author: Jorge Bay Gondra <[email protected]>
Date: 2016-10-05T14:14:46Z
Javascript GLV
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---