[
https://issues.apache.org/jira/browse/TINKERPOP-1489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15548890#comment-15548890
]
ASF GitHub Bot commented on TINKERPOP-1489:
-------------------------------------------
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
----
> Provide a Javascript Gremlin Language Variant
> ---------------------------------------------
>
> Key: TINKERPOP-1489
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1489
> Project: TinkerPop
> Issue Type: Improvement
> Components: language-variant
> Reporter: Jorge Bay
>
> It would be nice to have a Javascript Gremlin Language Variant that could
> work with any ES5 runtime, specially the ones that support
> [CommonJs|http://requirejs.org/docs/commonjs.html], like Node.js.
> Nashorn, the engine shipped with JDK 8+, does not implement CommonJs but
> provides [additional
> extensions|https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions]
> making modular JavaScript possible. Nashorn should be supported in order to
> run glv tests under the same infrastructure (JDK8).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)