You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2018/01/17 15:52:27 UTC

[01/47] tinkerpop git commit: TINKERPOP-1863 Delaying the setting of requestId till the RequestMessage instantiation time [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1489 ee8ac381c -> bf43cdc57 (forced update)


TINKERPOP-1863 Delaying the setting of requestId till the RequestMessage instantiation time

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7e80bccb
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7e80bccb
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7e80bccb

Branch: refs/heads/TINKERPOP-1489
Commit: 7e80bccb4c0195a510bb20be4d5da65629ee2a7f
Parents: fbcb044
Author: Eugene Chung <bl...@gmail.com>
Authored: Sat Jan 6 07:46:42 2018 +0900
Committer: GitHub <no...@github.com>
Committed: Sat Jan 6 07:46:42 2018 +0900

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/driver/message/RequestMessage.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7e80bccb/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
index 7a2ad3d..e836568 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
@@ -112,7 +112,7 @@ public final class RequestMessage {
      */
     public static final class Builder {
         public static final String OP_PROCESSOR_NAME = "";
-        private UUID requestId = UUID.randomUUID();
+        private UUID requestId;
         private String op;
         private String processor = OP_PROCESSOR_NAME;
         private Map<String, Object> args = new HashMap<>();
@@ -155,7 +155,7 @@ public final class RequestMessage {
          * Create the request message given the settings provided to the {@link Builder}.
          */
         public RequestMessage create() {
-            return new RequestMessage(requestId, op, processor, args);
+            return new RequestMessage(requestId == null ? UUID.randomUUID() : requestId, op, processor, args);
         }
     }
 


[12/47] tinkerpop git commit: Parse Edge and VertexProperty properties

Posted by jo...@apache.org.
Parse Edge and VertexProperty properties

To follow the decision around TINKERPOP-1474 for the GLV to parse properties.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8818b574
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8818b574
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8818b574

Branch: refs/heads/TINKERPOP-1489
Commit: 8818b57498b3ca96e318f6a7e74c856f9049676b
Parents: 9d7687f
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 16 13:41:46 2016 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:18 2018 +0100

----------------------------------------------------------------------
 .../javascript/gremlin-javascript/structure/graph.js | 15 +++++++++++++--
 .../structure/io/graph-serializer.js                 | 13 +++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8818b574/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
index 7c48819..cd408ae 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
@@ -68,10 +68,20 @@
 
   inherits(Vertex, Element);
 
-  function Edge(id, outV, label, inV) {
+  function Edge(id, outV, label, inV, properties) {
     Element.call(this, id, label);
     this.outV = outV;
     this.inV = inV;
+    this.properties = {};
+    (function adaptProperties(self) {
+      if (properties) {
+        var keys = Object.keys(properties);
+        for (var i = 0; i < keys.length; i++) {
+          var k = keys[i];
+          self.properties[k] = properties[k].value;
+        }
+      }
+    })(this);
   }
 
   inherits(Edge, Element);
@@ -80,10 +90,11 @@
     return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
   };
 
-  function VertexProperty(id, label, value) {
+  function VertexProperty(id, label, value, properties) {
     Element.call(this, id, label);
     this.value = value;
     this.key = this.label;
+    this.properties = properties;
   }
 
   inherits(VertexProperty, Element);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8818b574/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
index 2dde340..31652da 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
@@ -155,6 +155,9 @@
   }
 
   GraphSONReader.prototype.read = function (obj) {
+    if (obj === undefined) {
+      return undefined;
+    }
     if (Array.isArray(obj)) {
       return obj.map(function mapEach(item) {
         return this.read(item);
@@ -340,7 +343,12 @@
 
   VertexPropertySerializer.prototype.deserialize = function (obj) {
     var value = obj[valueKey];
-    return new g.VertexProperty(this.reader.read(value['id']), value['label'], this.reader.read(value['value']));
+    return new g.VertexProperty(
+      this.reader.read(value['id']),
+      value['label'],
+      this.reader.read(value['value']),
+      this.reader.read(value['properties'])
+    );
   };
 
   function PropertySerializer() {
@@ -364,7 +372,8 @@
       this.reader.read(value['id']),
       this.reader.read(value['outV']),
       value['label'],
-      this.reader.read(value['inV'])
+      this.reader.read(value['inV']),
+      this.reader.read(value['properties'])
     );
   };
 


[41/47] tinkerpop git commit: Use ES6 syntax

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index f6a0de1..6dcd8f6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -22,1141 +22,1144 @@
  */
 'use strict';
 
-var t = require('./traversal.js');
-var remote = require('../driver/remote-connection');
-var utils = require('../utils');
-var Bytecode = require('./bytecode');
-var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-var inherits = utils.inherits;
-var parseArgs = utils.parseArgs;
-
-/**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
-function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-  this.graph = graph;
-  this.traversalStrategies = traversalStrategies;
-  this.bytecode = bytecode || new Bytecode();
+const Traversal = require('./traversal').Traversal;
+const remote = require('../driver/remote-connection');
+const utils = require('../utils');
+const Bytecode = require('./bytecode');
+const TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+const parseArgs = utils.parseArgs;
+
+
+/**
+ * Represents the primary DSL of the Gremlin traversal machine.
+ */
+class GraphTraversalSource {
+  /**
+   * @param {Graph} graph
+   * @param {TraversalStrategies} traversalStrategies
+   * @param {Bytecode} [bytecode]
+   */
+  constructor(graph, traversalStrategies, bytecode) {
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode || new Bytecode();
+  }
+
+  /**
+   * @param remoteConnection
+   * @returns {GraphTraversalSource}
+   */
+  withRemote(remoteConnection) {
+    const traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+  }
+
+  /**
+   * Returns the string representation of the GraphTraversalSource.
+   * @returns {string}
+   */
+  toString() {
+    return 'graphtraversalsource[' + this.graph.toString() + ']';
+  }
+  
+  /**
+   * Graph Traversal Source withBulk method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  withBulk(args) {
+    const b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * Graph Traversal Source withPath method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  withPath(args) {
+    const b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * Graph Traversal Source withSack method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  withSack(args) {
+    const b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * Graph Traversal Source withSideEffect method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  withSideEffect(args) {
+    const b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * Graph Traversal Source withStrategies method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  withStrategies(args) {
+    const b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * Graph Traversal Source withoutStrategies method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  withoutStrategies(args) {
+    const b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * E GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  E(args) {
+    const b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * V GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  V(args) {
+    const b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * addV GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  addV(args) {
+    const b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * inject GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  inject(args) {
+    const b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
 }
 
 /**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-  var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
-  traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-  return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-};
-
-/**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
-GraphTraversalSource.prototype.toString = function () {
-  return 'graphtraversalsource[' + this.graph.toString() + ']';
-};
-
-/**
- * Graph Traversal Source withBulk method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withBulk = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withPath method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withPath = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withSack method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withSack = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withSideEffect method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withSideEffect = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withStrategies method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withStrategies = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withoutStrategies method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withoutStrategies = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * E GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.E = function (args) {
-  var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
-  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * V GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.V = function (args) {
-  var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
-  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * addV GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.addV = function (args) {
-  var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
-  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * inject GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.inject = function (args) {
-  var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
-  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
  * Represents a graph traversal.
- * @extends Traversal
- * @constructor
  */
-function GraphTraversal(graph, traversalStrategies, bytecode) {
-  t.Traversal.call(this, graph, traversalStrategies, bytecode);
+class GraphTraversal extends Traversal {
+  constructor(graph, traversalStrategies, bytecode) {
+    super(graph, traversalStrategies, bytecode);
+  }
+  
+  /**
+   * Graph traversal V method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  V(args) {
+    this.bytecode.addStep('V', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal addE method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  addE(args) {
+    this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal addInE method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  addInE(args) {
+    this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal addOutE method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  addOutE(args) {
+    this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal addV method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  addV(args) {
+    this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal aggregate method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  aggregate(args) {
+    this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal and method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  and(args) {
+    this.bytecode.addStep('and', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal as method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  as(args) {
+    this.bytecode.addStep('as', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal barrier method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  barrier(args) {
+    this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal both method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  both(args) {
+    this.bytecode.addStep('both', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal bothE method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  bothE(args) {
+    this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal bothV method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  bothV(args) {
+    this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal branch method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  branch(args) {
+    this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal by method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  by(args) {
+    this.bytecode.addStep('by', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal cap method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  cap(args) {
+    this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal choose method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  choose(args) {
+    this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal coalesce method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  coalesce(args) {
+    this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal coin method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  coin(args) {
+    this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal constant method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  constant(args) {
+    this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal count method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  count(args) {
+    this.bytecode.addStep('count', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal cyclicPath method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  cyclicPath(args) {
+    this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal dedup method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  dedup(args) {
+    this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal drop method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  drop(args) {
+    this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal emit method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  emit(args) {
+    this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal filter method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  filter(args) {
+    this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal flatMap method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  flatMap(args) {
+    this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal fold method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  fold(args) {
+    this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal from method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  from_(args) {
+    this.bytecode.addStep('from', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal group method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  group(args) {
+    this.bytecode.addStep('group', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal groupCount method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  groupCount(args) {
+    this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal groupV3d0 method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  groupV3d0(args) {
+    this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal has method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  has(args) {
+    this.bytecode.addStep('has', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal hasId method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  hasId(args) {
+    this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal hasKey method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  hasKey(args) {
+    this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal hasLabel method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  hasLabel(args) {
+    this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal hasNot method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  hasNot(args) {
+    this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal hasValue method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  hasValue(args) {
+    this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal id method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  id(args) {
+    this.bytecode.addStep('id', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal identity method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  identity(args) {
+    this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal in method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  in_(args) {
+    this.bytecode.addStep('in', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal inE method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  inE(args) {
+    this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal inV method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  inV(args) {
+    this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal inject method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  inject(args) {
+    this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal is method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  is(args) {
+    this.bytecode.addStep('is', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal key method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  key(args) {
+    this.bytecode.addStep('key', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal label method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  label(args) {
+    this.bytecode.addStep('label', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal limit method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  limit(args) {
+    this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal local method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  local(args) {
+    this.bytecode.addStep('local', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal loops method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  loops(args) {
+    this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal map method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  map(args) {
+    this.bytecode.addStep('map', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal mapKeys method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  mapKeys(args) {
+    this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal mapValues method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  mapValues(args) {
+    this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal match method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  match(args) {
+    this.bytecode.addStep('match', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal max method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  max(args) {
+    this.bytecode.addStep('max', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal mean method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  mean(args) {
+    this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal min method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  min(args) {
+    this.bytecode.addStep('min', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal not method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  not(args) {
+    this.bytecode.addStep('not', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal option method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  option(args) {
+    this.bytecode.addStep('option', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal optional method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  optional(args) {
+    this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal or method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  or(args) {
+    this.bytecode.addStep('or', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal order method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  order(args) {
+    this.bytecode.addStep('order', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal otherV method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  otherV(args) {
+    this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal out method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  out(args) {
+    this.bytecode.addStep('out', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal outE method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  outE(args) {
+    this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal outV method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  outV(args) {
+    this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal pageRank method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  pageRank(args) {
+    this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal path method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  path(args) {
+    this.bytecode.addStep('path', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal peerPressure method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  peerPressure(args) {
+    this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal profile method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  profile(args) {
+    this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal program method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  program(args) {
+    this.bytecode.addStep('program', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal project method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  project(args) {
+    this.bytecode.addStep('project', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal properties method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  properties(args) {
+    this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal property method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  property(args) {
+    this.bytecode.addStep('property', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal propertyMap method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  propertyMap(args) {
+    this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal range method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  range(args) {
+    this.bytecode.addStep('range', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal repeat method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  repeat(args) {
+    this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal sack method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  sack(args) {
+    this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal sample method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  sample(args) {
+    this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal select method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  select(args) {
+    this.bytecode.addStep('select', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal sideEffect method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  sideEffect(args) {
+    this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal simplePath method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  simplePath(args) {
+    this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal store method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  store(args) {
+    this.bytecode.addStep('store', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal subgraph method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  subgraph(args) {
+    this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal sum method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  sum(args) {
+    this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal tail method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  tail(args) {
+    this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal timeLimit method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  timeLimit(args) {
+    this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal times method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  times(args) {
+    this.bytecode.addStep('times', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal to method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  to(args) {
+    this.bytecode.addStep('to', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal toE method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  toE(args) {
+    this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal toV method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  toV(args) {
+    this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal tree method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  tree(args) {
+    this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal unfold method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  unfold(args) {
+    this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal union method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  union(args) {
+    this.bytecode.addStep('union', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal until method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  until(args) {
+    this.bytecode.addStep('until', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal value method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  value(args) {
+    this.bytecode.addStep('value', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal valueMap method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  valueMap(args) {
+    this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal values method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  values(args) {
+    this.bytecode.addStep('values', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
+  /**
+   * Graph traversal where method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  where(args) {
+    this.bytecode.addStep('where', parseArgs.apply(null, arguments));
+    return this;
+  }
+  
 }
 
-inherits(GraphTraversal, t.Traversal);
-
-/**
- * Graph traversal V method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.V = function (args) {
-  this.bytecode.addStep('V', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal addE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addE = function (args) {
-  this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal addInE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addInE = function (args) {
-  this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal addOutE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addOutE = function (args) {
-  this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal addV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addV = function (args) {
-  this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal aggregate method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.aggregate = function (args) {
-  this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal and method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.and = function (args) {
-  this.bytecode.addStep('and', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal as method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.as = function (args) {
-  this.bytecode.addStep('as', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal barrier method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.barrier = function (args) {
-  this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal both method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.both = function (args) {
-  this.bytecode.addStep('both', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal bothE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.bothE = function (args) {
-  this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal bothV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.bothV = function (args) {
-  this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal branch method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.branch = function (args) {
-  this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal by method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.by = function (args) {
-  this.bytecode.addStep('by', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal cap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.cap = function (args) {
-  this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal choose method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.choose = function (args) {
-  this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal coalesce method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.coalesce = function (args) {
-  this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal coin method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.coin = function (args) {
-  this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal constant method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.constant = function (args) {
-  this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal count method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.count = function (args) {
-  this.bytecode.addStep('count', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal cyclicPath method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.cyclicPath = function (args) {
-  this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal dedup method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.dedup = function (args) {
-  this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal drop method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.drop = function (args) {
-  this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal emit method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.emit = function (args) {
-  this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal filter method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.filter = function (args) {
-  this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal flatMap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.flatMap = function (args) {
-  this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal fold method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.fold = function (args) {
-  this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal from method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.from_ = function (args) {
-  this.bytecode.addStep('from', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal group method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.group = function (args) {
-  this.bytecode.addStep('group', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal groupCount method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.groupCount = function (args) {
-  this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal groupV3d0 method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.groupV3d0 = function (args) {
-  this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal has method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.has = function (args) {
-  this.bytecode.addStep('has', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal hasId method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasId = function (args) {
-  this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal hasKey method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasKey = function (args) {
-  this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal hasLabel method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasLabel = function (args) {
-  this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal hasNot method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasNot = function (args) {
-  this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal hasValue method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasValue = function (args) {
-  this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal id method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.id = function (args) {
-  this.bytecode.addStep('id', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal identity method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.identity = function (args) {
-  this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal in method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.in_ = function (args) {
-  this.bytecode.addStep('in', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal inE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.inE = function (args) {
-  this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal inV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.inV = function (args) {
-  this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal inject method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.inject = function (args) {
-  this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal is method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.is = function (args) {
-  this.bytecode.addStep('is', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal key method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.key = function (args) {
-  this.bytecode.addStep('key', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal label method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.label = function (args) {
-  this.bytecode.addStep('label', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal limit method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.limit = function (args) {
-  this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal local method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.local = function (args) {
-  this.bytecode.addStep('local', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal loops method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.loops = function (args) {
-  this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal map method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.map = function (args) {
-  this.bytecode.addStep('map', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal mapKeys method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.mapKeys = function (args) {
-  this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal mapValues method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.mapValues = function (args) {
-  this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal match method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.match = function (args) {
-  this.bytecode.addStep('match', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal max method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.max = function (args) {
-  this.bytecode.addStep('max', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal mean method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.mean = function (args) {
-  this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal min method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.min = function (args) {
-  this.bytecode.addStep('min', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal not method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.not = function (args) {
-  this.bytecode.addStep('not', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal option method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.option = function (args) {
-  this.bytecode.addStep('option', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal optional method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.optional = function (args) {
-  this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal or method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.or = function (args) {
-  this.bytecode.addStep('or', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal order method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.order = function (args) {
-  this.bytecode.addStep('order', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal otherV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.otherV = function (args) {
-  this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal out method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.out = function (args) {
-  this.bytecode.addStep('out', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal outE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.outE = function (args) {
-  this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal outV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.outV = function (args) {
-  this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal pageRank method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.pageRank = function (args) {
-  this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal path method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.path = function (args) {
-  this.bytecode.addStep('path', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal peerPressure method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.peerPressure = function (args) {
-  this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal profile method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.profile = function (args) {
-  this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal program method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.program = function (args) {
-  this.bytecode.addStep('program', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal project method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.project = function (args) {
-  this.bytecode.addStep('project', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal properties method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.properties = function (args) {
-  this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal property method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.property = function (args) {
-  this.bytecode.addStep('property', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal propertyMap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.propertyMap = function (args) {
-  this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal range method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.range = function (args) {
-  this.bytecode.addStep('range', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal repeat method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.repeat = function (args) {
-  this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal sack method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sack = function (args) {
-  this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal sample method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sample = function (args) {
-  this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal select method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.select = function (args) {
-  this.bytecode.addStep('select', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal sideEffect method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sideEffect = function (args) {
-  this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal simplePath method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.simplePath = function (args) {
-  this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal store method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.store = function (args) {
-  this.bytecode.addStep('store', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal subgraph method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.subgraph = function (args) {
-  this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal sum method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sum = function (args) {
-  this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal tail method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.tail = function (args) {
-  this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal timeLimit method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.timeLimit = function (args) {
-  this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal times method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.times = function (args) {
-  this.bytecode.addStep('times', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal to method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.to = function (args) {
-  this.bytecode.addStep('to', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal toE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.toE = function (args) {
-  this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal toV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.toV = function (args) {
-  this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal tree method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.tree = function (args) {
-  this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal unfold method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.unfold = function (args) {
-  this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal union method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.union = function (args) {
-  this.bytecode.addStep('union', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal until method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.until = function (args) {
-  this.bytecode.addStep('until', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal value method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.value = function (args) {
-  this.bytecode.addStep('value', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal valueMap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.valueMap = function (args) {
-  this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal values method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.values = function (args) {
-  this.bytecode.addStep('values', parseArgs.apply(null, arguments));
-  return this;
-};
-
-/**
- * Graph traversal where method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.where = function (args) {
-  this.bytecode.addStep('where', parseArgs.apply(null, arguments));
-  return this;
-};
-
 /**
  * Contains the static method definitions
  * @type {Object}
  */
-var statics = {};
+const statics = {};
 
 /**
  * V() static method
@@ -1164,7 +1167,7 @@ var statics = {};
  * @returns {GraphTraversal}
  */
 statics.V = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.V.apply(g, arguments);
 };
 
@@ -1174,7 +1177,7 @@ statics.V = function (args) {
  * @returns {GraphTraversal}
  */
 statics.addE = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.addE.apply(g, arguments);
 };
 
@@ -1184,7 +1187,7 @@ statics.addE = function (args) {
  * @returns {GraphTraversal}
  */
 statics.addInE = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.addInE.apply(g, arguments);
 };
 
@@ -1194,7 +1197,7 @@ statics.addInE = function (args) {
  * @returns {GraphTraversal}
  */
 statics.addOutE = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.addOutE.apply(g, arguments);
 };
 
@@ -1204,7 +1207,7 @@ statics.addOutE = function (args) {
  * @returns {GraphTraversal}
  */
 statics.addV = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.addV.apply(g, arguments);
 };
 
@@ -1214,7 +1217,7 @@ statics.addV = function (args) {
  * @returns {GraphTraversal}
  */
 statics.aggregate = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.aggregate.apply(g, arguments);
 };
 
@@ -1224,7 +1227,7 @@ statics.aggregate = function (args) {
  * @returns {GraphTraversal}
  */
 statics.and = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.and.apply(g, arguments);
 };
 
@@ -1234,7 +1237,7 @@ statics.and = function (args) {
  * @returns {GraphTraversal}
  */
 statics.as = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.as.apply(g, arguments);
 };
 
@@ -1244,7 +1247,7 @@ statics.as = function (args) {
  * @returns {GraphTraversal}
  */
 statics.barrier = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.barrier.apply(g, arguments);
 };
 
@@ -1254,7 +1257,7 @@ statics.barrier = function (args) {
  * @returns {GraphTraversal}
  */
 statics.both = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.both.apply(g, arguments);
 };
 
@@ -1264,7 +1267,7 @@ statics.both = function (args) {
  * @returns {GraphTraversal}
  */
 statics.bothE = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.bothE.apply(g, arguments);
 };
 
@@ -1274,7 +1277,7 @@ statics.bothE = function (args) {
  * @returns {GraphTraversal}
  */
 statics.bothV = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.bothV.apply(g, arguments);
 };
 
@@ -1284,7 +1287,7 @@ statics.bothV = function (args) {
  * @returns {GraphTraversal}
  */
 statics.branch = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.branch.apply(g, arguments);
 };
 
@@ -1294,7 +1297,7 @@ statics.branch = function (args) {
  * @returns {GraphTraversal}
  */
 statics.cap = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.cap.apply(g, arguments);
 };
 
@@ -1304,7 +1307,7 @@ statics.cap = function (args) {
  * @returns {GraphTraversal}
  */
 statics.choose = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.choose.apply(g, arguments);
 };
 
@@ -1314,7 +1317,7 @@ statics.choose = function (args) {
  * @returns {GraphTraversal}
  */
 statics.coalesce = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.coalesce.apply(g, arguments);
 };
 
@@ -1324,7 +1327,7 @@ statics.coalesce = function (args) {
  * @returns {GraphTraversal}
  */
 statics.coin = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.coin.apply(g, arguments);
 };
 
@@ -1334,7 +1337,7 @@ statics.coin = function (args) {
  * @returns {GraphTraversal}
  */
 statics.constant = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.constant.apply(g, arguments);
 };
 
@@ -1344,7 +1347,7 @@ statics.constant = function (args) {
  * @returns {GraphTraversal}
  */
 statics.count = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.count.apply(g, arguments);
 };
 
@@ -1354,7 +1357,7 @@ statics.count = function (args) {
  * @returns {GraphTraversal}
  */
 statics.cyclicPath = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.cyclicPath.apply(g, arguments);
 };
 
@@ -1364,7 +1367,7 @@ statics.cyclicPath = function (args) {
  * @returns {GraphTraversal}
  */
 statics.dedup = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.dedup.apply(g, arguments);
 };
 
@@ -1374,7 +1377,7 @@ statics.dedup = function (args) {
  * @returns {GraphTraversal}
  */
 statics.drop = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.drop.apply(g, arguments);
 };
 
@@ -1384,7 +1387,7 @@ statics.drop = function (args) {
  * @returns {GraphTraversal}
  */
 statics.emit = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.emit.apply(g, arguments);
 };
 
@@ -1394,7 +1397,7 @@ statics.emit = function (args) {
  * @returns {GraphTraversal}
  */
 statics.filter = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.filter.apply(g, arguments);
 };
 
@@ -1404,7 +1407,7 @@ statics.filter = function (args) {
  * @returns {GraphTraversal}
  */
 statics.flatMap = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.flatMap.apply(g, arguments);
 };
 
@@ -1414,7 +1417,7 @@ statics.flatMap = function (args) {
  * @returns {GraphTraversal}
  */
 statics.fold = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.fold.apply(g, arguments);
 };
 
@@ -1424,7 +1427,7 @@ statics.fold = function (args) {
  * @returns {GraphTraversal}
  */
 statics.group = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.group.apply(g, arguments);
 };
 
@@ -1434,7 +1437,7 @@ statics.group = function (args) {
  * @returns {GraphTraversal}
  */
 statics.groupCount = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.groupCount.apply(g, arguments);
 };
 
@@ -1444,7 +1447,7 @@ statics.groupCount = function (args) {
  * @returns {GraphTraversal}
  */
 statics.groupV3d0 = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.groupV3d0.apply(g, arguments);
 };
 
@@ -1454,7 +1457,7 @@ statics.groupV3d0 = function (args) {
  * @returns {GraphTraversal}
  */
 statics.has = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.has.apply(g, arguments);
 };
 
@@ -1464,7 +1467,7 @@ statics.has = function (args) {
  * @returns {GraphTraversal}
  */
 statics.hasId = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.hasId.apply(g, arguments);
 };
 
@@ -1474,7 +1477,7 @@ statics.hasId = function (args) {
  * @returns {GraphTraversal}
  */
 statics.hasKey = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.hasKey.apply(g, arguments);
 };
 
@@ -1484,7 +1487,7 @@ statics.hasKey = function (args) {
  * @returns {GraphTraversal}
  */
 statics.hasLabel = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.hasLabel.apply(g, arguments);
 };
 
@@ -1494,7 +1497,7 @@ statics.hasLabel = function (args) {
  * @returns {GraphTraversal}
  */
 statics.hasNot = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.hasNot.apply(g, arguments);
 };
 
@@ -1504,7 +1507,7 @@ statics.hasNot = function (args) {
  * @returns {GraphTraversal}
  */
 statics.hasValue = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.hasValue.apply(g, arguments);
 };
 
@@ -1514,7 +1517,7 @@ statics.hasValue = function (args) {
  * @returns {GraphTraversal}
  */
 statics.id = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.id.apply(g, arguments);
 };
 
@@ -1524,7 +1527,7 @@ statics.id = function (args) {
  * @returns {GraphTraversal}
  */
 statics.identity = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.identity.apply(g, arguments);
 };
 
@@ -1534,7 +1537,7 @@ statics.identity = function (args) {
  * @returns {GraphTraversal}
  */
 statics.in_ = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.in_.apply(g, arguments);
 };
 
@@ -1544,7 +1547,7 @@ statics.in_ = function (args) {
  * @returns {GraphTraversal}
  */
 statics.inE = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.inE.apply(g, arguments);
 };
 
@@ -1554,7 +1557,7 @@ statics.inE = function (args) {
  * @returns {GraphTraversal}
  */
 statics.inV = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.inV.apply(g, arguments);
 };
 
@@ -1564,7 +1567,7 @@ statics.inV = function (args) {
  * @returns {GraphTraversal}
  */
 statics.inject = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.inject.apply(g, arguments);
 };
 
@@ -1574,7 +1577,7 @@ statics.inject = function (args) {
  * @returns {GraphTraversal}
  */
 statics.is = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.is.apply(g, arguments);
 };
 
@@ -1584,7 +1587,7 @@ statics.is = function (args) {
  * @returns {GraphTraversal}
  */
 statics.key = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.key.apply(g, arguments);
 };
 
@@ -1594,7 +1597,7 @@ statics.key = function (args) {
  * @returns {GraphTraversal}
  */
 statics.label = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.label.apply(g, arguments);
 };
 
@@ -1604,7 +1607,7 @@ statics.label = function (args) {
  * @returns {GraphTraversal}
  */
 statics.limit = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.limit.apply(g, arguments);
 };
 
@@ -1614,7 +1617,7 @@ statics.limit = function (args) {
  * @returns {GraphTraversal}
  */
 statics.local = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.local.apply(g, arguments);
 };
 
@@ -1624,7 +1627,7 @@ statics.local = function (args) {
  * @returns {GraphTraversal}
  */
 statics.loops = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.loops.apply(g, arguments);
 };
 
@@ -1634,7 +1637,7 @@ statics.loops = function (args) {
  * @returns {GraphTraversal}
  */
 statics.map = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.map.apply(g, arguments);
 };
 
@@ -1644,7 +1647,7 @@ statics.map = function (args) {
  * @returns {GraphTraversal}
  */
 statics.mapKeys = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.mapKeys.apply(g, arguments);
 };
 
@@ -1654,7 +1657,7 @@ statics.mapKeys = function (args) {
  * @returns {GraphTraversal}
  */
 statics.mapValues = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.mapValues.apply(g, arguments);
 };
 
@@ -1664,7 +1667,7 @@ statics.mapValues = function (args) {
  * @returns {GraphTraversal}
  */
 statics.match = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.match.apply(g, arguments);
 };
 
@@ -1674,7 +1677,7 @@ statics.match = function (args) {
  * @returns {GraphTraversal}
  */
 statics.max = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.max.apply(g, arguments);
 };
 
@@ -1684,7 +1687,7 @@ statics.max = function (args) {
  * @returns {GraphTraversal}
  */
 statics.mean = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.mean.apply(g, arguments);
 };
 
@@ -1694,7 +1697,7 @@ statics.mean = function (args) {
  * @returns {GraphTraversal}
  */
 statics.min = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.min.apply(g, arguments);
 };
 
@@ -1704,7 +1707,7 @@ statics.min = function (args) {
  * @returns {GraphTraversal}
  */
 statics.not = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.not.apply(g, arguments);
 };
 
@@ -1714,7 +1717,7 @@ statics.not = function (args) {
  * @returns {GraphTraversal}
  */
 statics.optional = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.optional.apply(g, arguments);
 };
 
@@ -1724,7 +1727,7 @@ statics.optional = function (args) {
  * @returns {GraphTraversal}
  */
 statics.or = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.or.apply(g, arguments);
 };
 
@@ -1734,7 +1737,7 @@ statics.or = function (args) {
  * @returns {GraphTraversal}
  */
 statics.order = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.order.apply(g, arguments);
 };
 
@@ -1744,7 +1747,7 @@ statics.order = function (args) {
  * @returns {GraphTraversal}
  */
 statics.otherV = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.otherV.apply(g, arguments);
 };
 
@@ -1754,7 +1757,7 @@ statics.otherV = function (args) {
  * @returns {GraphTraversal}
  */
 statics.out = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.out.apply(g, arguments);
 };
 
@@ -1764,7 +1767,7 @@ statics.out = function (args) {
  * @returns {GraphTraversal}
  */
 statics.outE = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.outE.apply(g, arguments);
 };
 
@@ -1774,7 +1777,7 @@ statics.outE = function (args) {
  * @returns {GraphTraversal}
  */
 statics.outV = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.outV.apply(g, arguments);
 };
 
@@ -1784,7 +1787,7 @@ statics.outV = function (args) {
  * @returns {GraphTraversal}
  */
 statics.path = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.path.apply(g, arguments);
 };
 
@@ -1794,7 +1797,7 @@ statics.path = function (args) {
  * @returns {GraphTraversal}
  */
 statics.project = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.project.apply(g, arguments);
 };
 
@@ -1804,7 +1807,7 @@ statics.project = function (args) {
  * @returns {GraphTraversal}
  */
 statics.properties = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.properties.apply(g, arguments);
 };
 
@@ -1814,7 +1817,7 @@ statics.properties = function (args) {
  * @returns {GraphTraversal}
  */
 statics.property = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.property.apply(g, arguments);
 };
 
@@ -1824,7 +1827,7 @@ statics.property = function (args) {
  * @returns {GraphTraversal}
  */
 statics.propertyMap = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.propertyMap.apply(g, arguments);
 };
 
@@ -1834,7 +1837,7 @@ statics.propertyMap = function (args) {
  * @returns {GraphTraversal}
  */
 statics.range = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.range.apply(g, arguments);
 };
 
@@ -1844,7 +1847,7 @@ statics.range = function (args) {
  * @returns {GraphTraversal}
  */
 statics.repeat = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.repeat.apply(g, arguments);
 };
 
@@ -1854,7 +1857,7 @@ statics.repeat = function (args) {
  * @returns {GraphTraversal}
  */
 statics.sack = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.sack.apply(g, arguments);
 };
 
@@ -1864,7 +1867,7 @@ statics.sack = function (args) {
  * @returns {GraphTraversal}
  */
 statics.sample = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.sample.apply(g, arguments);
 };
 
@@ -1874,7 +1877,7 @@ statics.sample = function (args) {
  * @returns {GraphTraversal}
  */
 statics.select = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.select.apply(g, arguments);
 };
 
@@ -1884,7 +1887,7 @@ statics.select = function (args) {
  * @returns {GraphTraversal}
  */
 statics.sideEffect = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.sideEffect.apply(g, arguments);
 };
 
@@ -1894,7 +1897,7 @@ statics.sideEffect = function (args) {
  * @returns {GraphTraversal}
  */
 statics.simplePath = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.simplePath.apply(g, arguments);
 };
 
@@ -1904,7 +1907,7 @@ statics.simplePath = function (args) {
  * @returns {GraphTraversal}
  */
 statics.store = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.store.apply(g, arguments);
 };
 
@@ -1914,7 +1917,7 @@ statics.store = function (args) {
  * @returns {GraphTraversal}
  */
 statics.subgraph = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.subgraph.apply(g, arguments);
 };
 
@@ -1924,7 +1927,7 @@ statics.subgraph = function (args) {
  * @returns {GraphTraversal}
  */
 statics.sum = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.sum.apply(g, arguments);
 };
 
@@ -1934,7 +1937,7 @@ statics.sum = function (args) {
  * @returns {GraphTraversal}
  */
 statics.tail = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.tail.apply(g, arguments);
 };
 
@@ -1944,7 +1947,7 @@ statics.tail = function (args) {
  * @returns {GraphTraversal}
  */
 statics.timeLimit = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.timeLimit.apply(g, arguments);
 };
 
@@ -1954,7 +1957,7 @@ statics.timeLimit = function (args) {
  * @returns {GraphTraversal}
  */
 statics.times = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.times.apply(g, arguments);
 };
 
@@ -1964,7 +1967,7 @@ statics.times = function (args) {
  * @returns {GraphTraversal}
  */
 statics.to = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.to.apply(g, arguments);
 };
 
@@ -1974,7 +1977,7 @@ statics.to = function (args) {
  * @returns {GraphTraversal}
  */
 statics.toE = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.toE.apply(g, arguments);
 };
 
@@ -1984,7 +1987,7 @@ statics.toE = function (args) {
  * @returns {GraphTraversal}
  */
 statics.toV = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.toV.apply(g, arguments);
 };
 
@@ -1994,7 +1997,7 @@ statics.toV = function (args) {
  * @returns {GraphTraversal}
  */
 statics.tree = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.tree.apply(g, arguments);
 };
 
@@ -2004,7 +2007,7 @@ statics.tree = function (args) {
  * @returns {GraphTraversal}
  */
 statics.unfold = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.unfold.apply(g, arguments);
 };
 
@@ -2014,7 +2017,7 @@ statics.unfold = function (args) {
  * @returns {GraphTraversal}
  */
 statics.union = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.union.apply(g, arguments);
 };
 
@@ -2024,7 +2027,7 @@ statics.union = function (args) {
  * @returns {GraphTraversal}
  */
 statics.until = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.until.apply(g, arguments);
 };
 
@@ -2034,7 +2037,7 @@ statics.until = function (args) {
  * @returns {GraphTraversal}
  */
 statics.value = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.value.apply(g, arguments);
 };
 
@@ -2044,7 +2047,7 @@ statics.value = function (args) {
  * @returns {GraphTraversal}
  */
 statics.valueMap = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.valueMap.apply(g, arguments);
 };
 
@@ -2054,7 +2057,7 @@ statics.valueMap = function (args) {
  * @returns {GraphTraversal}
  */
 statics.values = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.values.apply(g, arguments);
 };
 
@@ -2064,12 +2067,12 @@ statics.values = function (args) {
  * @returns {GraphTraversal}
  */
 statics.where = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.where.apply(g, arguments);
 };
 
 module.exports = {
-  GraphTraversal: GraphTraversal,
-  GraphTraversalSource: GraphTraversalSource,
-  statics: statics
+  GraphTraversal,
+  GraphTraversalSource,
+  statics
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
index 22d6498..fbc3fba 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
@@ -22,66 +22,63 @@
  */
 'use strict';
 
-var utils = require('../utils');
+const utils = require('../utils');
 
-/**
- * Creates a new instance of TraversalStrategies.
- * @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from.
- * @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to
- * create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises.
- * @constructor
- */
-function TraversalStrategies(parent, promiseFactory) {
-  if (parent) {
-    // Clone the strategies
-    this.strategies = parent.strategies.slice(0);
-    this.promiseFactory = parent.promiseFactory;
+class TraversalStrategies {
+  /**
+   * Creates a new instance of TraversalStrategies.
+   * @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from.
+   * @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to
+   * create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises.
+   * @constructor
+   */
+  constructor(parent, promiseFactory) {
+    if (parent) {
+      // Clone the strategies
+      this.strategies = parent.strategies.slice(0);
+      this.promiseFactory = parent.promiseFactory;
+    }
+    else {
+      this.strategies = [];
+    }
+    if (promiseFactory) {
+      this.promiseFactory = promiseFactory;
+    }
   }
-  else {
-    this.strategies = [];
+
+  /** @param {TraversalStrategy} strategy */
+  addStrategy(strategy) {
+    this.strategies.push(strategy);
   }
-  if (promiseFactory) {
-    this.promiseFactory = promiseFactory;
+
+  /**
+   * @param {Traversal} traversal
+   * @returns {Promise}
+   */
+  applyStrategies(traversal) {
+    // Apply all strategies serially
+    const self = this;
+    return this.strategies.reduce(function reduceItem(promise, strategy) {
+      return promise.then(function () {
+        return strategy.apply(traversal, self.promiseFactory);
+      });
+    }, utils.resolvedPromise(this.promiseFactory));
   }
 }
 
-/** @param {TraversalStrategy} strategy */
-TraversalStrategies.prototype.addStrategy = function (strategy) {
-  this.strategies.push(strategy);
-};
-
-/**
- * @param {Traversal} traversal
- * @returns {Promise}
- */
-TraversalStrategies.prototype.applyStrategies = function (traversal) {
-  // Apply all strategies serially
-  var self = this;
-  return this.strategies.reduce(function reduceItem(promise, strategy) {
-    return promise.then(function () {
-      return strategy.apply(traversal, self.promiseFactory);
-    });
-  }, utils.resolvedPromise(this.promiseFactory));
-};
-
-/**
- * @abstract
- * @constructor
- */
-function TraversalStrategy() {
+/** @abstract */
+class TraversalStrategy {
+  /**
+   * @abstract
+   * @param {Traversal} traversal
+   * @param {Function|undefined} promiseFactory
+   * @returns {Promise}
+   */
+  apply(traversal, promiseFactory) {
 
+  }
 }
 
-/**
- * @abstract
- * @param {Traversal} traversal
- * @param {Function|undefined} promiseFactory
- * @returns {Promise}
- */
-TraversalStrategy.prototype.apply = function (traversal, promiseFactory) {
-
-};
-
 module.exports = {
   TraversalStrategies: TraversalStrategies,
   TraversalStrategy: TraversalStrategy


[36/47] tinkerpop git commit: Support ignore scenarios

Posted by jo...@apache.org.
Support ignore scenarios


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/700cc68c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/700cc68c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/700cc68c

Branch: refs/heads/TINKERPOP-1489
Commit: 700cc68cb8c6a342a5f65653f712aa9a38a7cb54
Parents: 4f432c6
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 13:14:26 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:21 2018 +0100

----------------------------------------------------------------------
 .../test/cucumber/feature-steps.js              | 20 ++++++++++++++------
 .../gremlin-javascript/test/cucumber/world.js   |  4 +++-
 2 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/700cc68c/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 99e2ec8..06a3283 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -52,8 +52,20 @@ const parsers = [
   [ 'c\\[(.+)\\]', toLambda ]
 ].map(x => [ new RegExp('^' + x[0] + '$'), x[1] ]);
 
+const ignoreReason = {
+  lambdaNotSupported: 'Lambdas are not supported on gremlin-javascript',
+};
+
+const ignoredScenarios = {
+  // An associative array containing the scenario name as key, for example:
+  // 'g_V_branchXlabel_eq_person': new IgnoreError(ignoreReason.lambdaNotSupported),
+};
+
 defineSupportCode(function(methods) {
   methods.Given(/^the (.+) graph$/, function (graphName) {
+    if (ignoredScenarios[this.scenario]) {
+      return 'skipped';
+    }
     this.graphName = graphName;
     const data = this.getData();
     this.g = new Graph().traversal().withRemote(data.connection);
@@ -282,7 +294,7 @@ function parseMapValue(value) {
 }
 
 function toLambda() {
-  throw new IgnoreError(IgnoreError.reason.lambdaNotSupported);
+  throw new IgnoreError(ignoreReason.lambdaNotSupported);
 }
 
 /**
@@ -310,8 +322,4 @@ function IgnoreError(reason) {
   Error.captureStackTrace(this, IgnoreError);
 }
 
-util.inherits(IgnoreError, Error);
-
-IgnoreError.reason = {
-  lambdaNotSupported: 'Lambdas are not supported on gremlin-javascript',
-};
\ No newline at end of file
+util.inherits(IgnoreError, Error);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/700cc68c/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 03febd1..ae3f9a6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -33,6 +33,7 @@ defineSupportCode(function (methods) {
   const cache = {};
 
   function TinkerPopWorld(){
+    this.scenario = null;
     this.g = null;
     this.traversal = null;
     this.result = null;
@@ -91,7 +92,8 @@ defineSupportCode(function (methods) {
     return Promise.all(Object.keys(cache).map(graphName => cache[graphName].connection.close()));
   });
 
-  methods.Before(function () {
+  methods.Before(function (info) {
+    this.scenario = info.pickle.name;
     this.cache = cache;
   });
 });


[07/47] tinkerpop git commit: Export enums and fix TraversalStrategies#applyStrategies()

Posted by jo...@apache.org.
Export enums and fix TraversalStrategies#applyStrategies()


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b509fd12
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b509fd12
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b509fd12

Branch: refs/heads/TINKERPOP-1489
Commit: b509fd12d0f77ff32f5966d8723965927701ed17
Parents: 4e768a8
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Fri Oct 7 12:01:30 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:17 2018 +0100

----------------------------------------------------------------------
 .../GraphTraversalSourceGenerator.groovy        |  4 +-
 .../javascript/TraversalSourceGenerator.groovy  | 52 +++++++++-----------
 .../driver/remote-connection.js                 |  2 +-
 .../main/javascript/gremlin-javascript/index.js | 11 ++++-
 .../process/graph-traversal.js                  |  4 +-
 .../gremlin-javascript/process/traversal.js     | 44 ++++++++---------
 .../gremlin-javascript/test-exports.js          | 15 ++++--
 .../gremlin-javascript/test-graphson.js         |  2 +-
 .../gremlin-javascript/test-traversal.js        | 17 ++++++-
 9 files changed, 87 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index 81c38dc..b569292 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -87,12 +87,12 @@ class GraphTraversalSourceGenerator {
 
   /**
    * @param remoteConnection
-   * @returns {GraphTraversal}
+   * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
     var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
   };
 
   /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index efcb826..5b07a32 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -177,11 +177,14 @@ class TraversalSourceGenerator {
     this.strategies.push(strategy);
   };
 
-  /** @param {Traversal} traversal */
-  TraversalStrategies.prototype.applyStrategies = function (traversal) {
-    this.strategies.forEach(function eachStrategy(s) {
-      s.apply(traversal);
-    });
+  /**
+   * @param {Traversal} traversal
+   * @param {Function} callback
+   */
+  TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
+    eachSeries(this.strategies, function eachStrategy(s, next) {
+      s.apply(traversal, next);
+    }, callback);
   };
 
   /**
@@ -195,8 +198,9 @@ class TraversalSourceGenerator {
   /**
    * @abstract
    * @param {Traversal} traversal
+   * @param {Function} callback
    */
-  TraversalStrategy.prototype.apply = function (traversal) {
+  TraversalStrategy.prototype.apply = function (traversal, callback) {
 
   };
 
@@ -290,24 +294,6 @@ class TraversalSourceGenerator {
     this.elementName = elementName;
   }
 
-  /**
-   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
-   */
-  var enums = {};\n""")
-
-        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
-                .findAll { Enum.class.isAssignableFrom(it) }
-                .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
-                .collect()) {
-            moduleOutput.append("  enums.${SymbolHelper.decapitalize(enumClass.getSimpleName())} = " +
-                    "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
-            enumClass.getEnumConstants()
-                    .sort { a, b -> a.name() <=> b.name() }
-                    .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
-            moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("');\n")
-        }
-
-        moduleOutput.append("""
   // Utility functions
   /** @returns {Array} */
   function parseArgs() {
@@ -376,11 +362,21 @@ class TraversalSourceGenerator {
     TraversalSideEffects: TraversalSideEffects,
     TraversalStrategies: TraversalStrategies,
     TraversalStrategy: TraversalStrategy,
-    Traverser: Traverser
+    Traverser: Traverser""")
+        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
+                .findAll { Enum.class.isAssignableFrom(it) }
+                .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
+                .collect()) {
+            moduleOutput.append(",\n    ${SymbolHelper.decapitalize(enumClass.getSimpleName())}: " +
+                    "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
+            enumClass.getEnumConstants()
+                    .sort { a, b -> a.name() <=> b.name() }
+                    .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
+            moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("')")
+        }
+
+        moduleOutput.append("""
   };
-  Object.keys(enums).forEach(function (k) {
-    toExport[k] = enums[k];
-  });
   if (typeof module !== 'undefined') {
     // CommonJS
     module.exports = toExport;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
index 99b177f..e19b537 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
@@ -68,7 +68,7 @@
   /** @override */
   RemoteStrategy.prototype.apply = function (traversal, callback) {
     if (traversal.traversers) {
-      return;
+      return callback();
     }
     this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
       if (err) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index cda8200..ddcdac2 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -49,14 +49,21 @@
     process: {
       Bytecode: t.Bytecode,
       EnumValue: t.EnumValue,
-      inherits: t.inherits,
       P: t.P,
-      parseArgs: t.parseArgs,
       Traversal: t.Traversal,
       TraversalSideEffects: t.TraversalSideEffects,
       TraversalStrategies: t.TraversalStrategies,
       TraversalStrategy: t.TraversalStrategy,
       Traverser: t.Traverser,
+      barrier: t.barrier,
+      cardinality: t.cardinality,
+      column: t.column,
+      direction: t.direction,
+      operator: t.operator,
+      order: t.order,
+      pop: t.pop,
+      scope: t.scope,
+      t: t.t,
       GraphTraversal: gt.GraphTraversal,
       GraphTraversalSource: gt.GraphTraversalSource,
       statics: gt.statics

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index d9803ba..1a6356b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -44,12 +44,12 @@
 
   /**
    * @param remoteConnection
-   * @returns {GraphTraversal}
+   * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
     var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
   };
 
   /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index 5c9bf6c..ff2927e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -185,11 +185,14 @@
     this.strategies.push(strategy);
   };
 
-  /** @param {Traversal} traversal */
-  TraversalStrategies.prototype.applyStrategies = function (traversal) {
-    this.strategies.forEach(function eachStrategy(s) {
-      s.apply(traversal);
-    });
+  /**
+   * @param {Traversal} traversal
+   * @param {Function} callback
+   */
+  TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
+    eachSeries(this.strategies, function eachStrategy(s, next) {
+      s.apply(traversal, next);
+    }, callback);
   };
 
   /**
@@ -203,8 +206,9 @@
   /**
    * @abstract
    * @param {Traversal} traversal
+   * @param {Function} callback
    */
-  TraversalStrategy.prototype.apply = function (traversal) {
+  TraversalStrategy.prototype.apply = function (traversal, callback) {
 
   };
 
@@ -298,20 +302,6 @@
     this.elementName = elementName;
   }
 
-  /**
-   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
-   */
-  var enums = {};
-  enums.barrier = toEnum('Barrier', 'normSack');
-  enums.cardinality = toEnum('Cardinality', 'list set single');
-  enums.column = toEnum('Column', 'keys values');
-  enums.direction = toEnum('Direction', 'BOTH IN OUT');
-  enums.operator = toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong');
-  enums.order = toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr');
-  enums.pop = toEnum('Pop', 'all first last');
-  enums.scope = toEnum('Scope', 'global local');
-  enums.t = toEnum('T', 'id key label value');
-
   // Utility functions
   /** @returns {Array} */
   function parseArgs() {
@@ -380,11 +370,17 @@
     TraversalSideEffects: TraversalSideEffects,
     TraversalStrategies: TraversalStrategies,
     TraversalStrategy: TraversalStrategy,
-    Traverser: Traverser
+    Traverser: Traverser,
+    barrier: toEnum('Barrier', 'normSack'),
+    cardinality: toEnum('Cardinality', 'list set single'),
+    column: toEnum('Column', 'keys values'),
+    direction: toEnum('Direction', 'BOTH IN OUT'),
+    operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
+    order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+    pop: toEnum('Pop', 'all first last'),
+    scope: toEnum('Scope', 'global local'),
+    t: toEnum('T', 'id key label value')
   };
-  Object.keys(enums).forEach(function (k) {
-    toExport[k] = enums[k];
-  });
   if (typeof module !== 'undefined') {
     // CommonJS
     module.exports = toExport;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
index 6edb323..b9265c7 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
@@ -34,9 +34,7 @@
       assert.ok(glvModule.process);
       assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
       assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
-      assert.strictEqual(typeof glvModule.process.inherits, 'function');
       assert.strictEqual(typeof glvModule.process.P, 'function');
-      assert.strictEqual(typeof glvModule.process.parseArgs, 'function');
       assert.strictEqual(typeof glvModule.process.Traversal, 'function');
       assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
       assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
@@ -44,6 +42,17 @@
       assert.strictEqual(typeof glvModule.process.Traverser, 'function');
       assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
       assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+      assert.strictEqual(typeof glvModule.process.barrier, 'object');
+      assert.strictEqual(typeof glvModule.process.cardinality, 'object');
+      assert.strictEqual(typeof glvModule.process.column, 'object');
+      assert.strictEqual(typeof glvModule.process.direction, 'object');
+      assert.strictEqual(typeof glvModule.process.operator, 'object');
+      assert.strictEqual(typeof glvModule.process.order, 'object');
+      assert.strictEqual(typeof glvModule.process.pop, 'object');
+      assert.strictEqual(typeof glvModule.process.scope, 'object');
+      assert.strictEqual(typeof glvModule.process.t, 'object');
+
+
       assert.ok(glvModule.process.statics);
 
       assert.ok(glvModule.structure);
@@ -75,4 +84,4 @@
     }
     throw new Error('No module loader was found');
   }
-}).call(this)
\ No newline at end of file
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
index e44ef90..418a9dd 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
@@ -87,7 +87,7 @@
       assert.strictEqual(writer.write(true), 'true');
       assert.strictEqual(writer.write(false), 'false');
     },
-    function testWriteNumber() {
+    function testWriteP() {
       var writer = new GraphSONWriter();
       var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
       assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b509fd12/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
index 477df91..1ec4253 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
@@ -26,9 +26,10 @@
   var helper = loadModule.call(this, './helper.js');
   var assert = helper.assert;
   var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+  var t = helper.loadLibModule.call(this, 'process/traversal.js');
 
   [
-    function testBytecode() {
+    function testBytecode1() {
       var g = new graph.Graph().traversal();
       var bytecode = g.V().out('created').getBytecode();
       assert.ok(bytecode);
@@ -37,6 +38,20 @@
       assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
       assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
       assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+    },
+    function testBytecode2() {
+      var g = new graph.Graph().traversal();
+      var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
+      assert.ok(bytecode);
+      assert.strictEqual(bytecode.sourceInstructions.length, 0);
+      assert.strictEqual(bytecode.stepInstructions.length, 3);
+      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+      assert.strictEqual(bytecode.stepInstructions[1][0], 'order');
+      assert.strictEqual(bytecode.stepInstructions[2][0], 'by');
+      assert.strictEqual(bytecode.stepInstructions[2][1], 'age');
+      assert.strictEqual(typeof bytecode.stepInstructions[2][2], 'object');
+      assert.strictEqual(bytecode.stepInstructions[2][2].typeName, 'Order');
+      assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
     }
   ].forEach(function (testCase) {
     testCase.call(null);


[16/47] tinkerpop git commit: Graph, traversalStrategies and graph as Traversal properties

Posted by jo...@apache.org.
Graph, traversalStrategies and graph as Traversal properties

Expose those properties as in the Python GLV and the Java implementation. Previously, those properties where exposed using the private notation (ie: _graph).


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e1097e90
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e1097e90
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e1097e90

Branch: refs/heads/TINKERPOP-1489
Commit: e1097e90ec52533dcbca65c5667810270bd81663
Parents: b509fd1
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Oct 18 16:22:23 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:18 2018 +0100

----------------------------------------------------------------------
 .../GraphTraversalSourceGenerator.groovy        |  23 +-
 .../javascript/TraversalSourceGenerator.groovy  |  12 +-
 .../process/graph-traversal.js                  | 253 ++++++++++---------
 .../gremlin-javascript/process/traversal.js     |  12 +-
 4 files changed, 151 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e1097e90/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index b569292..a8217e2 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -80,9 +80,9 @@ class GraphTraversalSourceGenerator {
    * @constructor
    */
   function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode || new Bytecode();
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode || new Bytecode();
   }
 
   /**
@@ -90,9 +90,9 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
   };
 
   /**
@@ -100,7 +100,7 @@ class GraphTraversalSourceGenerator {
    * @returns {string}
    */
   GraphTraversalSource.prototype.toString = function () {
-    return 'graphtraversalsource[' + this._graph.toString() + ']';
+    return 'graphtraversalsource[' + this.graph.toString() + ']';
   };
 """)
         GraphTraversalSource.getMethods(). // SOURCE STEPS
@@ -122,8 +122,8 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.${method} = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 """)
                 }
@@ -141,8 +141,8 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.${method} = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 """)
                 }
@@ -153,6 +153,7 @@ class GraphTraversalSourceGenerator {
                 """
   /**
    * Represents a graph traversal.
+   * @extends Traversal
    * @constructor
    */
   function GraphTraversal(graph, traversalStrategies, bytecode) {
@@ -175,7 +176,7 @@ class GraphTraversalSourceGenerator {
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.${method} = function (args) {
-    this._bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
     return this;
   };
 """)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e1097e90/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index 5b07a32..46f65a4 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -61,22 +61,22 @@ class TraversalSourceGenerator {
   "use strict";
 
   function Traversal(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode;
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode;
     this.traversers = null;
     this.sideEffects = null;
   }
 
   /** @returns {Bytecode} */
   Traversal.prototype.getBytecode = function () {
-    return this._bytecode;
+    return this.bytecode;
   };
 
   /** @param {Function} callback */
   Traversal.prototype.list = function (callback) {
     var self = this;
-    this._traversalStrategies.applyStrategies(this, function (err) {
+    this.traversalStrategies.applyStrategies(this, function (err) {
       if (err) {
         return callback(err);
       }
@@ -96,7 +96,7 @@ class TraversalSourceGenerator {
    * @returns {String}
    */
   Traversal.prototype.toString = function () {
-    return this._bytecode.toString();
+    return this.bytecode.toString();
   };
   """);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e1097e90/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index 1a6356b..663a24d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -37,9 +37,9 @@
    * @constructor
    */
   function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode || new Bytecode();
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode || new Bytecode();
   }
 
   /**
@@ -47,9 +47,9 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
     traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
   };
 
   /**
@@ -57,7 +57,7 @@
    * @returns {string}
    */
   GraphTraversalSource.prototype.toString = function () {
-    return 'graphtraversalsource[' + this._graph.toString() + ']';
+    return 'graphtraversalsource[' + this.graph.toString() + ']';
   };
 
   /**
@@ -66,8 +66,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withBulk = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -76,8 +76,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withComputer = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -86,8 +86,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withPath = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withPath', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -96,8 +96,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withSack = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withSack', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -106,8 +106,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withSideEffect = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -116,8 +116,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withStrategies = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -126,8 +126,8 @@
    * @returns {GraphTraversalSource}
    */
   GraphTraversalSource.prototype.withoutStrategies = function (args) {
-    var b = new Bytecode(this._bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -136,8 +136,8 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.E = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('E', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -146,8 +146,8 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.V = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('V', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -156,8 +156,8 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.addV = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('addV', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
@@ -166,12 +166,13 @@
    * @returns {GraphTraversal}
    */
   GraphTraversalSource.prototype.inject = function (args) {
-    var b = new Bytecode(this._bytecode).addStep('inject', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+    var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
   };
 
   /**
    * Represents a graph traversal.
+   * @extends Traversal
    * @constructor
    */
   function GraphTraversal(graph, traversalStrategies, bytecode) {
@@ -185,7 +186,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.V = function (args) {
-    this._bytecode.addStep('V', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('V', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -194,7 +195,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addE = function (args) {
-    this._bytecode.addStep('addE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -203,7 +204,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addInE = function (args) {
-    this._bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -212,7 +213,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addOutE = function (args) {
-    this._bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -221,7 +222,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.addV = function (args) {
-    this._bytecode.addStep('addV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -230,7 +231,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.aggregate = function (args) {
-    this._bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -239,7 +240,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.and = function (args) {
-    this._bytecode.addStep('and', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('and', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -248,7 +249,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.as = function (args) {
-    this._bytecode.addStep('as', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('as', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -257,7 +258,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.barrier = function (args) {
-    this._bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -266,7 +267,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.both = function (args) {
-    this._bytecode.addStep('both', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('both', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -275,7 +276,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.bothE = function (args) {
-    this._bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -284,7 +285,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.bothV = function (args) {
-    this._bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -293,7 +294,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.branch = function (args) {
-    this._bytecode.addStep('branch', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -302,7 +303,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.by = function (args) {
-    this._bytecode.addStep('by', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('by', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -311,7 +312,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.cap = function (args) {
-    this._bytecode.addStep('cap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -320,7 +321,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.choose = function (args) {
-    this._bytecode.addStep('choose', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -329,7 +330,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.coalesce = function (args) {
-    this._bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -338,7 +339,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.coin = function (args) {
-    this._bytecode.addStep('coin', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -347,7 +348,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.constant = function (args) {
-    this._bytecode.addStep('constant', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -356,7 +357,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.count = function (args) {
-    this._bytecode.addStep('count', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('count', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -365,7 +366,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.cyclicPath = function (args) {
-    this._bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -374,7 +375,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.dedup = function (args) {
-    this._bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -383,7 +384,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.drop = function (args) {
-    this._bytecode.addStep('drop', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -392,7 +393,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.emit = function (args) {
-    this._bytecode.addStep('emit', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -401,7 +402,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.filter = function (args) {
-    this._bytecode.addStep('filter', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -410,7 +411,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.flatMap = function (args) {
-    this._bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -419,7 +420,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.fold = function (args) {
-    this._bytecode.addStep('fold', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -428,7 +429,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.from_ = function (args) {
-    this._bytecode.addStep('from', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('from', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -437,7 +438,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.group = function (args) {
-    this._bytecode.addStep('group', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('group', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -446,7 +447,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.groupCount = function (args) {
-    this._bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -455,7 +456,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.groupV3d0 = function (args) {
-    this._bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -464,7 +465,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.has = function (args) {
-    this._bytecode.addStep('has', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('has', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -473,7 +474,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasId = function (args) {
-    this._bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -482,7 +483,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasKey = function (args) {
-    this._bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -491,7 +492,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasLabel = function (args) {
-    this._bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -500,7 +501,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasNot = function (args) {
-    this._bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -509,7 +510,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.hasValue = function (args) {
-    this._bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -518,7 +519,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.id = function (args) {
-    this._bytecode.addStep('id', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('id', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -527,7 +528,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.identity = function (args) {
-    this._bytecode.addStep('identity', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -536,7 +537,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.inE = function (args) {
-    this._bytecode.addStep('inE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -545,7 +546,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.inV = function (args) {
-    this._bytecode.addStep('inV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -554,7 +555,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.in_ = function (args) {
-    this._bytecode.addStep('in', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('in', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -563,7 +564,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.inject = function (args) {
-    this._bytecode.addStep('inject', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -572,7 +573,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.is = function (args) {
-    this._bytecode.addStep('is', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('is', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -581,7 +582,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.key = function (args) {
-    this._bytecode.addStep('key', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('key', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -590,7 +591,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.label = function (args) {
-    this._bytecode.addStep('label', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('label', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -599,7 +600,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.limit = function (args) {
-    this._bytecode.addStep('limit', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -608,7 +609,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.local = function (args) {
-    this._bytecode.addStep('local', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('local', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -617,7 +618,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.loops = function (args) {
-    this._bytecode.addStep('loops', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -626,7 +627,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.map = function (args) {
-    this._bytecode.addStep('map', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('map', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -635,7 +636,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.mapKeys = function (args) {
-    this._bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -644,7 +645,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.mapValues = function (args) {
-    this._bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -653,7 +654,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.match = function (args) {
-    this._bytecode.addStep('match', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('match', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -662,7 +663,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.max = function (args) {
-    this._bytecode.addStep('max', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('max', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -671,7 +672,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.mean = function (args) {
-    this._bytecode.addStep('mean', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -680,7 +681,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.min = function (args) {
-    this._bytecode.addStep('min', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('min', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -689,7 +690,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.not = function (args) {
-    this._bytecode.addStep('not', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('not', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -698,7 +699,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.option = function (args) {
-    this._bytecode.addStep('option', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('option', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -707,7 +708,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.optional = function (args) {
-    this._bytecode.addStep('optional', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -716,7 +717,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.or = function (args) {
-    this._bytecode.addStep('or', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('or', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -725,7 +726,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.order = function (args) {
-    this._bytecode.addStep('order', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('order', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -734,7 +735,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.otherV = function (args) {
-    this._bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -743,7 +744,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.out = function (args) {
-    this._bytecode.addStep('out', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('out', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -752,7 +753,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.outE = function (args) {
-    this._bytecode.addStep('outE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -761,7 +762,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.outV = function (args) {
-    this._bytecode.addStep('outV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -770,7 +771,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.pageRank = function (args) {
-    this._bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -779,7 +780,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.path = function (args) {
-    this._bytecode.addStep('path', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('path', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -788,7 +789,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.peerPressure = function (args) {
-    this._bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -797,7 +798,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.profile = function (args) {
-    this._bytecode.addStep('profile', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -806,7 +807,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.program = function (args) {
-    this._bytecode.addStep('program', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('program', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -815,7 +816,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.project = function (args) {
-    this._bytecode.addStep('project', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('project', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -824,7 +825,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.properties = function (args) {
-    this._bytecode.addStep('properties', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -833,7 +834,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.property = function (args) {
-    this._bytecode.addStep('property', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('property', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -842,7 +843,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.propertyMap = function (args) {
-    this._bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -851,7 +852,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.range = function (args) {
-    this._bytecode.addStep('range', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('range', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -860,7 +861,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.repeat = function (args) {
-    this._bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -869,7 +870,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sack = function (args) {
-    this._bytecode.addStep('sack', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -878,7 +879,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sample = function (args) {
-    this._bytecode.addStep('sample', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -887,7 +888,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.select = function (args) {
-    this._bytecode.addStep('select', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('select', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -896,7 +897,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sideEffect = function (args) {
-    this._bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -905,7 +906,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.simplePath = function (args) {
-    this._bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -914,7 +915,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.store = function (args) {
-    this._bytecode.addStep('store', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('store', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -923,7 +924,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.subgraph = function (args) {
-    this._bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -932,7 +933,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.sum = function (args) {
-    this._bytecode.addStep('sum', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -941,7 +942,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.tail = function (args) {
-    this._bytecode.addStep('tail', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -950,7 +951,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.timeLimit = function (args) {
-    this._bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -959,7 +960,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.times = function (args) {
-    this._bytecode.addStep('times', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('times', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -968,7 +969,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.to = function (args) {
-    this._bytecode.addStep('to', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('to', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -977,7 +978,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.toE = function (args) {
-    this._bytecode.addStep('toE', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -986,7 +987,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.toV = function (args) {
-    this._bytecode.addStep('toV', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -995,7 +996,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.tree = function (args) {
-    this._bytecode.addStep('tree', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1004,7 +1005,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.unfold = function (args) {
-    this._bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1013,7 +1014,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.union = function (args) {
-    this._bytecode.addStep('union', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('union', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1022,7 +1023,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.until = function (args) {
-    this._bytecode.addStep('until', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('until', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1031,7 +1032,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.value = function (args) {
-    this._bytecode.addStep('value', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('value', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1040,7 +1041,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.valueMap = function (args) {
-    this._bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1049,7 +1050,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.values = function (args) {
-    this._bytecode.addStep('values', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('values', parseArgs.apply(null, arguments));
     return this;
   };
 
@@ -1058,7 +1059,7 @@
    * @returns {GraphTraversal}
    */
   GraphTraversal.prototype.where = function (args) {
-    this._bytecode.addStep('where', parseArgs.apply(null, arguments));
+    this.bytecode.addStep('where', parseArgs.apply(null, arguments));
     return this;
   };
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e1097e90/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index ff2927e..a7a9bb7 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -24,22 +24,22 @@
   "use strict";
 
   function Traversal(graph, traversalStrategies, bytecode) {
-    this._graph = graph;
-    this._traversalStrategies = traversalStrategies;
-    this._bytecode = bytecode;
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode;
     this.traversers = null;
     this.sideEffects = null;
   }
 
   /** @returns {Bytecode} */
   Traversal.prototype.getBytecode = function () {
-    return this._bytecode;
+    return this.bytecode;
   };
 
   /** @param {Function} callback */
   Traversal.prototype.list = function (callback) {
     var self = this;
-    this._traversalStrategies.applyStrategies(this, function (err) {
+    this.traversalStrategies.applyStrategies(this, function (err) {
       if (err) {
         return callback(err);
       }
@@ -59,7 +59,7 @@
    * @returns {String}
    */
   Traversal.prototype.toString = function () {
-    return this._bytecode.toString();
+    return this.bytecode.toString();
   };
   
   /**


[22/47] tinkerpop git commit: Update Javascript GLV

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
new file mode 100644
index 0000000..5ee734a1
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -0,0 +1,2095 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ 
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('./traversal.js');
+var remote = require('../driver/remote-connection');
+var utils = require('../utils');
+var Bytecode = require('./bytecode');
+var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+var inherits = utils.inherits;
+var parseArgs = utils.parseArgs;
+
+/**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+  this.graph = graph;
+  this.traversalStrategies = traversalStrategies;
+  this.bytecode = bytecode || new Bytecode();
+}
+
+/**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+  var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+  traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+  return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+};
+
+/**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+GraphTraversalSource.prototype.toString = function () {
+  return 'graphtraversalsource[' + this.graph.toString() + ']';
+};
+
+/**
+ * Graph Traversal Source withBulk method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withBulk = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withComputer method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withComputer = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withPath method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withPath = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withSack method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withSack = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withSideEffect method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withSideEffect = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withStrategies method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withStrategies = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withoutStrategies method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withoutStrategies = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * E GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.E = function (args) {
+  var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * V GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.V = function (args) {
+  var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * addV GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.addV = function (args) {
+  var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * inject GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.inject = function (args) {
+  var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Represents a graph traversal.
+ * @extends Traversal
+ * @constructor
+ */
+function GraphTraversal(graph, traversalStrategies, bytecode) {
+  t.Traversal.call(this, graph, traversalStrategies, bytecode);
+}
+
+inherits(GraphTraversal, t.Traversal);
+
+/**
+ * Graph traversal V method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.V = function (args) {
+  this.bytecode.addStep('V', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal addE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addE = function (args) {
+  this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal addInE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addInE = function (args) {
+  this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal addOutE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addOutE = function (args) {
+  this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal addV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addV = function (args) {
+  this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal aggregate method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.aggregate = function (args) {
+  this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal and method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.and = function (args) {
+  this.bytecode.addStep('and', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal as method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.as = function (args) {
+  this.bytecode.addStep('as', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal barrier method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.barrier = function (args) {
+  this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal both method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.both = function (args) {
+  this.bytecode.addStep('both', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal bothE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.bothE = function (args) {
+  this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal bothV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.bothV = function (args) {
+  this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal branch method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.branch = function (args) {
+  this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal by method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.by = function (args) {
+  this.bytecode.addStep('by', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal cap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.cap = function (args) {
+  this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal choose method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.choose = function (args) {
+  this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal coalesce method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.coalesce = function (args) {
+  this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal coin method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.coin = function (args) {
+  this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal constant method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.constant = function (args) {
+  this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal count method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.count = function (args) {
+  this.bytecode.addStep('count', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal cyclicPath method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.cyclicPath = function (args) {
+  this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal dedup method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.dedup = function (args) {
+  this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal drop method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.drop = function (args) {
+  this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal emit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.emit = function (args) {
+  this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal filter method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.filter = function (args) {
+  this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal flatMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.flatMap = function (args) {
+  this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal fold method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.fold = function (args) {
+  this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal from method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.from_ = function (args) {
+  this.bytecode.addStep('from', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal group method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.group = function (args) {
+  this.bytecode.addStep('group', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal groupCount method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.groupCount = function (args) {
+  this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal groupV3d0 method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.groupV3d0 = function (args) {
+  this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal has method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.has = function (args) {
+  this.bytecode.addStep('has', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal hasId method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasId = function (args) {
+  this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal hasKey method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasKey = function (args) {
+  this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal hasLabel method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasLabel = function (args) {
+  this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal hasNot method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasNot = function (args) {
+  this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal hasValue method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasValue = function (args) {
+  this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal id method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.id = function (args) {
+  this.bytecode.addStep('id', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal identity method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.identity = function (args) {
+  this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal in method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.in_ = function (args) {
+  this.bytecode.addStep('in', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal inE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.inE = function (args) {
+  this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal inV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.inV = function (args) {
+  this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal inject method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.inject = function (args) {
+  this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal is method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.is = function (args) {
+  this.bytecode.addStep('is', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal key method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.key = function (args) {
+  this.bytecode.addStep('key', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal label method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.label = function (args) {
+  this.bytecode.addStep('label', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal limit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.limit = function (args) {
+  this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal local method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.local = function (args) {
+  this.bytecode.addStep('local', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal loops method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.loops = function (args) {
+  this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal map method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.map = function (args) {
+  this.bytecode.addStep('map', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal mapKeys method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.mapKeys = function (args) {
+  this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal mapValues method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.mapValues = function (args) {
+  this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal match method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.match = function (args) {
+  this.bytecode.addStep('match', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal max method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.max = function (args) {
+  this.bytecode.addStep('max', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal mean method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.mean = function (args) {
+  this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal min method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.min = function (args) {
+  this.bytecode.addStep('min', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal not method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.not = function (args) {
+  this.bytecode.addStep('not', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal option method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.option = function (args) {
+  this.bytecode.addStep('option', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal optional method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.optional = function (args) {
+  this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal or method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.or = function (args) {
+  this.bytecode.addStep('or', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal order method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.order = function (args) {
+  this.bytecode.addStep('order', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal otherV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.otherV = function (args) {
+  this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal out method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.out = function (args) {
+  this.bytecode.addStep('out', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal outE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.outE = function (args) {
+  this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal outV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.outV = function (args) {
+  this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal pageRank method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.pageRank = function (args) {
+  this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal path method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.path = function (args) {
+  this.bytecode.addStep('path', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal peerPressure method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.peerPressure = function (args) {
+  this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal profile method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.profile = function (args) {
+  this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal program method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.program = function (args) {
+  this.bytecode.addStep('program', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal project method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.project = function (args) {
+  this.bytecode.addStep('project', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal properties method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.properties = function (args) {
+  this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal property method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.property = function (args) {
+  this.bytecode.addStep('property', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal propertyMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.propertyMap = function (args) {
+  this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal range method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.range = function (args) {
+  this.bytecode.addStep('range', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal repeat method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.repeat = function (args) {
+  this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal sack method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sack = function (args) {
+  this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal sample method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sample = function (args) {
+  this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal select method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.select = function (args) {
+  this.bytecode.addStep('select', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal sideEffect method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sideEffect = function (args) {
+  this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal simplePath method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.simplePath = function (args) {
+  this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal store method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.store = function (args) {
+  this.bytecode.addStep('store', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal subgraph method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.subgraph = function (args) {
+  this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal sum method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sum = function (args) {
+  this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal tail method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.tail = function (args) {
+  this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal timeLimit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.timeLimit = function (args) {
+  this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal times method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.times = function (args) {
+  this.bytecode.addStep('times', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal to method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.to = function (args) {
+  this.bytecode.addStep('to', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal toE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.toE = function (args) {
+  this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal toV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.toV = function (args) {
+  this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal tree method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.tree = function (args) {
+  this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal unfold method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.unfold = function (args) {
+  this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal union method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.union = function (args) {
+  this.bytecode.addStep('union', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal until method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.until = function (args) {
+  this.bytecode.addStep('until', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal value method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.value = function (args) {
+  this.bytecode.addStep('value', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal valueMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.valueMap = function (args) {
+  this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal values method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.values = function (args) {
+  this.bytecode.addStep('values', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Graph traversal where method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.where = function (args) {
+  this.bytecode.addStep('where', parseArgs.apply(null, arguments));
+  return this;
+};
+
+/**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+var statics = {};
+
+/**
+ * V() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.V = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.V.apply(g, arguments);
+};
+
+/**
+ * addE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addE = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.addE.apply(g, arguments);
+};
+
+/**
+ * addInE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addInE = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.addInE.apply(g, arguments);
+};
+
+/**
+ * addOutE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addOutE = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.addOutE.apply(g, arguments);
+};
+
+/**
+ * addV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addV = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.addV.apply(g, arguments);
+};
+
+/**
+ * aggregate() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.aggregate = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.aggregate.apply(g, arguments);
+};
+
+/**
+ * and() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.and = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.and.apply(g, arguments);
+};
+
+/**
+ * as() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.as = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.as.apply(g, arguments);
+};
+
+/**
+ * barrier() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.barrier = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.barrier.apply(g, arguments);
+};
+
+/**
+ * both() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.both = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.both.apply(g, arguments);
+};
+
+/**
+ * bothE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.bothE = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.bothE.apply(g, arguments);
+};
+
+/**
+ * bothV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.bothV = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.bothV.apply(g, arguments);
+};
+
+/**
+ * branch() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.branch = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.branch.apply(g, arguments);
+};
+
+/**
+ * cap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.cap = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.cap.apply(g, arguments);
+};
+
+/**
+ * choose() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.choose = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.choose.apply(g, arguments);
+};
+
+/**
+ * coalesce() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.coalesce = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.coalesce.apply(g, arguments);
+};
+
+/**
+ * coin() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.coin = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.coin.apply(g, arguments);
+};
+
+/**
+ * constant() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.constant = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.constant.apply(g, arguments);
+};
+
+/**
+ * count() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.count = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.count.apply(g, arguments);
+};
+
+/**
+ * cyclicPath() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.cyclicPath = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.cyclicPath.apply(g, arguments);
+};
+
+/**
+ * dedup() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.dedup = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.dedup.apply(g, arguments);
+};
+
+/**
+ * drop() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.drop = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.drop.apply(g, arguments);
+};
+
+/**
+ * emit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.emit = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.emit.apply(g, arguments);
+};
+
+/**
+ * filter() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.filter = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.filter.apply(g, arguments);
+};
+
+/**
+ * flatMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.flatMap = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.flatMap.apply(g, arguments);
+};
+
+/**
+ * fold() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.fold = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.fold.apply(g, arguments);
+};
+
+/**
+ * group() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.group = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.group.apply(g, arguments);
+};
+
+/**
+ * groupCount() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.groupCount = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.groupCount.apply(g, arguments);
+};
+
+/**
+ * groupV3d0() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.groupV3d0 = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.groupV3d0.apply(g, arguments);
+};
+
+/**
+ * has() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.has = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.has.apply(g, arguments);
+};
+
+/**
+ * hasId() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasId = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.hasId.apply(g, arguments);
+};
+
+/**
+ * hasKey() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasKey = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.hasKey.apply(g, arguments);
+};
+
+/**
+ * hasLabel() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasLabel = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.hasLabel.apply(g, arguments);
+};
+
+/**
+ * hasNot() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasNot = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.hasNot.apply(g, arguments);
+};
+
+/**
+ * hasValue() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasValue = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.hasValue.apply(g, arguments);
+};
+
+/**
+ * id() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.id = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.id.apply(g, arguments);
+};
+
+/**
+ * identity() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.identity = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.identity.apply(g, arguments);
+};
+
+/**
+ * inE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.inE = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.inE.apply(g, arguments);
+};
+
+/**
+ * inV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.inV = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.inV.apply(g, arguments);
+};
+
+/**
+ * in_() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.in_ = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.in_.apply(g, arguments);
+};
+
+/**
+ * inject() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.inject = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.inject.apply(g, arguments);
+};
+
+/**
+ * is() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.is = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.is.apply(g, arguments);
+};
+
+/**
+ * key() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.key = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.key.apply(g, arguments);
+};
+
+/**
+ * label() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.label = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.label.apply(g, arguments);
+};
+
+/**
+ * limit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.limit = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.limit.apply(g, arguments);
+};
+
+/**
+ * local() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.local = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.local.apply(g, arguments);
+};
+
+/**
+ * loops() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.loops = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.loops.apply(g, arguments);
+};
+
+/**
+ * map() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.map = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.map.apply(g, arguments);
+};
+
+/**
+ * mapKeys() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.mapKeys = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.mapKeys.apply(g, arguments);
+};
+
+/**
+ * mapValues() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.mapValues = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.mapValues.apply(g, arguments);
+};
+
+/**
+ * match() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.match = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.match.apply(g, arguments);
+};
+
+/**
+ * max() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.max = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.max.apply(g, arguments);
+};
+
+/**
+ * mean() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.mean = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.mean.apply(g, arguments);
+};
+
+/**
+ * min() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.min = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.min.apply(g, arguments);
+};
+
+/**
+ * not() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.not = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.not.apply(g, arguments);
+};
+
+/**
+ * optional() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.optional = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.optional.apply(g, arguments);
+};
+
+/**
+ * or() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.or = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.or.apply(g, arguments);
+};
+
+/**
+ * order() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.order = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.order.apply(g, arguments);
+};
+
+/**
+ * otherV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.otherV = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.otherV.apply(g, arguments);
+};
+
+/**
+ * out() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.out = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.out.apply(g, arguments);
+};
+
+/**
+ * outE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.outE = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.outE.apply(g, arguments);
+};
+
+/**
+ * outV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.outV = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.outV.apply(g, arguments);
+};
+
+/**
+ * path() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.path = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.path.apply(g, arguments);
+};
+
+/**
+ * project() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.project = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.project.apply(g, arguments);
+};
+
+/**
+ * properties() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.properties = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.properties.apply(g, arguments);
+};
+
+/**
+ * property() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.property = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.property.apply(g, arguments);
+};
+
+/**
+ * propertyMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.propertyMap = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.propertyMap.apply(g, arguments);
+};
+
+/**
+ * range() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.range = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.range.apply(g, arguments);
+};
+
+/**
+ * repeat() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.repeat = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.repeat.apply(g, arguments);
+};
+
+/**
+ * sack() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sack = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.sack.apply(g, arguments);
+};
+
+/**
+ * sample() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sample = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.sample.apply(g, arguments);
+};
+
+/**
+ * select() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.select = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.select.apply(g, arguments);
+};
+
+/**
+ * sideEffect() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sideEffect = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.sideEffect.apply(g, arguments);
+};
+
+/**
+ * simplePath() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.simplePath = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.simplePath.apply(g, arguments);
+};
+
+/**
+ * start() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.start = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.start.apply(g, arguments);
+};
+
+/**
+ * store() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.store = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.store.apply(g, arguments);
+};
+
+/**
+ * subgraph() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.subgraph = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.subgraph.apply(g, arguments);
+};
+
+/**
+ * sum() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sum = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.sum.apply(g, arguments);
+};
+
+/**
+ * tail() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.tail = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.tail.apply(g, arguments);
+};
+
+/**
+ * timeLimit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.timeLimit = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.timeLimit.apply(g, arguments);
+};
+
+/**
+ * times() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.times = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.times.apply(g, arguments);
+};
+
+/**
+ * to() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.to = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.to.apply(g, arguments);
+};
+
+/**
+ * toE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.toE = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.toE.apply(g, arguments);
+};
+
+/**
+ * toV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.toV = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.toV.apply(g, arguments);
+};
+
+/**
+ * tree() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.tree = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.tree.apply(g, arguments);
+};
+
+/**
+ * unfold() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.unfold = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.unfold.apply(g, arguments);
+};
+
+/**
+ * union() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.union = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.union.apply(g, arguments);
+};
+
+/**
+ * until() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.until = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.until.apply(g, arguments);
+};
+
+/**
+ * value() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.value = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.value.apply(g, arguments);
+};
+
+/**
+ * valueMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.valueMap = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.valueMap.apply(g, arguments);
+};
+
+/**
+ * values() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.values = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.values.apply(g, arguments);
+};
+
+/**
+ * where() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.where = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.where.apply(g, arguments);
+};
+
+module.exports = {
+  GraphTraversal: GraphTraversal,
+  GraphTraversalSource: GraphTraversalSource,
+  statics: statics
+};

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
new file mode 100644
index 0000000..22d6498
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
@@ -0,0 +1,88 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var utils = require('../utils');
+
+/**
+ * Creates a new instance of TraversalStrategies.
+ * @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from.
+ * @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to
+ * create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises.
+ * @constructor
+ */
+function TraversalStrategies(parent, promiseFactory) {
+  if (parent) {
+    // Clone the strategies
+    this.strategies = parent.strategies.slice(0);
+    this.promiseFactory = parent.promiseFactory;
+  }
+  else {
+    this.strategies = [];
+  }
+  if (promiseFactory) {
+    this.promiseFactory = promiseFactory;
+  }
+}
+
+/** @param {TraversalStrategy} strategy */
+TraversalStrategies.prototype.addStrategy = function (strategy) {
+  this.strategies.push(strategy);
+};
+
+/**
+ * @param {Traversal} traversal
+ * @returns {Promise}
+ */
+TraversalStrategies.prototype.applyStrategies = function (traversal) {
+  // Apply all strategies serially
+  var self = this;
+  return this.strategies.reduce(function reduceItem(promise, strategy) {
+    return promise.then(function () {
+      return strategy.apply(traversal, self.promiseFactory);
+    });
+  }, utils.resolvedPromise(this.promiseFactory));
+};
+
+/**
+ * @abstract
+ * @constructor
+ */
+function TraversalStrategy() {
+
+}
+
+/**
+ * @abstract
+ * @param {Traversal} traversal
+ * @param {Function|undefined} promiseFactory
+ * @returns {Promise}
+ */
+TraversalStrategy.prototype.apply = function (traversal, promiseFactory) {
+
+};
+
+module.exports = {
+  TraversalStrategies: TraversalStrategies,
+  TraversalStrategy: TraversalStrategy
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
new file mode 100644
index 0000000..1cd6b53
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -0,0 +1,236 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var utils = require('../utils');
+var parseArgs = utils.parseArgs;
+var itemDone = Object.freeze({ value: null, done: true });
+var emptyArray = Object.freeze([]);
+
+function Traversal(graph, traversalStrategies, bytecode) {
+  this.graph = graph;
+  this.traversalStrategies = traversalStrategies;
+  this.bytecode = bytecode;
+  this.traversers = null;
+  this.sideEffects = null;
+  this._traversalStrategiesPromise = null;
+  this._traversersIteratorIndex = 0;
+}
+
+/** @returns {Bytecode} */
+Traversal.prototype.getBytecode = function () {
+  return this.bytecode;
+};
+
+/**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+Traversal.prototype.toList = function () {
+  var self = this;
+  return this._applyStrategies().then(function () {
+    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+      return emptyArray;
+    }
+    var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
+    for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
+      arr[i] = self.traversers[i].object;
+    }
+    self._traversersIteratorIndex = self.traversers.length;
+    return arr;
+  });
+};
+
+/**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+Traversal.prototype.next = function () {
+  var self = this;
+  return this._applyStrategies().then(function () {
+    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+      return itemDone;
+    }
+    return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
+  });
+};
+
+Traversal.prototype._applyStrategies = function () {
+  if (this._traversalStrategiesPromise) {
+    // Apply strategies only once
+    return this._traversalStrategiesPromise;
+  }
+  return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+};
+
+/**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+Traversal.prototype.toString = function () {
+  return this.bytecode.toString();
+};
+  
+/**
+ * Represents an operation.
+ * @constructor
+ */
+function P(operator, value, other) {
+  this.operator = operator;
+  this.value = value;
+  this.other = other;
+}
+
+/**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+P.prototype.toString = function () {
+  if (this.other === undefined) {
+    return this.operator + '(' + this.value + ')';
+  }
+  return this.operator + '(' + this.value + ', ' + this.other + ')';
+};
+
+function createP(operator, args) {
+  args.unshift(null, operator);
+  return new (Function.prototype.bind.apply(P, args));
+}
+
+/** @param {...Object} args */
+P.between = function (args) {
+  return createP('between', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.eq = function (args) {
+  return createP('eq', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.gt = function (args) {
+  return createP('gt', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.gte = function (args) {
+  return createP('gte', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.inside = function (args) {
+  return createP('inside', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.lt = function (args) {
+  return createP('lt', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.lte = function (args) {
+  return createP('lte', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.neq = function (args) {
+  return createP('neq', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.not = function (args) {
+  return createP('not', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.outside = function (args) {
+  return createP('outside', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.test = function (args) {
+  return createP('test', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.within = function (args) {
+  return createP('within', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.without = function (args) {
+  return createP('without', parseArgs.apply(null, arguments));
+};
+
+P.prototype.and = function (arg) {
+  return new P('and', this, arg);
+};
+
+P.prototype.or = function (arg) {
+  return new P('or', this, arg);
+};
+
+function Traverser(object, bulk) {
+  this.object = object;
+  this.bulk = bulk == undefined ? 1 : bulk;
+}
+
+function TraversalSideEffects() {
+
+}
+
+function toEnum(typeName, keys) {
+  var result = {};
+  keys.split(' ').forEach(function (k) {
+    var jsKey = k;
+    if (jsKey === jsKey.toUpperCase()) {
+      jsKey = jsKey.toLowerCase();
+    }
+    result[jsKey] = new EnumValue(typeName, k);
+  });
+  return result;
+}
+
+function EnumValue(typeName, elementName) {
+  this.typeName = typeName;
+  this.elementName = elementName;
+}
+
+module.exports = {
+  EnumValue: EnumValue,
+  P: P,
+  Traversal: Traversal,
+  TraversalSideEffects: TraversalSideEffects,
+  Traverser: Traverser,
+  barrier: toEnum('Barrier', 'normSack'),
+  cardinality: toEnum('Cardinality', 'list set single'),
+  column: toEnum('Column', 'keys values'),
+  direction: toEnum('Direction', 'BOTH IN OUT'),
+  operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
+  order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+  pick: toEnum('Pick', 'any none'),
+  pop: toEnum('Pop', 'all first last'),
+  scope: toEnum('Scope', 'global local'),
+  t: toEnum('T', 'id key label value')
+};

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
new file mode 100644
index 0000000..4ef3fd5
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -0,0 +1,138 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var gt = require('../process/graph-traversal');
+var t = require('../process/traversal');
+var TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
+var utils = require('../utils');
+var inherits = utils.inherits;
+
+function Graph() {
+
+}
+
+/**
+ * Returns the graph traversal source.
+ * @returns {GraphTraversalSource}
+ */
+Graph.prototype.traversal = function () {
+  return new gt.GraphTraversalSource(this, new TraversalStrategies());
+};
+
+Graph.prototype.toString = function () {
+  return 'graph[empty]';
+};
+
+function Element(id, label) {
+  this.id = id;
+  this.label = label;
+}
+
+/**
+ * Compares this instance to another and determines if they can be considered as equal.
+ * @param {Element} other
+ * @returns {boolean}
+ */
+Element.prototype.equals = function (other) {
+  return (other instanceof Element) && this.id === other.id;
+};
+
+function Vertex(id, label, properties) {
+  Element.call(this, id, label);
+  this.properties = properties;
+}
+
+Vertex.prototype.toString = function () {
+  return 'v[' + this.id + ']';
+};
+
+inherits(Vertex, Element);
+
+function Edge(id, outV, label, inV, properties) {
+  Element.call(this, id, label);
+  this.outV = outV;
+  this.inV = inV;
+  this.properties = {};
+  (function adaptProperties(self) {
+    if (properties) {
+      var keys = Object.keys(properties);
+      for (var i = 0; i < keys.length; i++) {
+        var k = keys[i];
+        self.properties[k] = properties[k].value;
+      }
+    }
+  })(this);
+}
+
+inherits(Edge, Element);
+
+Edge.prototype.toString = function () {
+  return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
+};
+
+function VertexProperty(id, label, value, properties) {
+  Element.call(this, id, label);
+  this.value = value;
+  this.key = this.label;
+  this.properties = properties;
+}
+
+inherits(VertexProperty, Element);
+
+VertexProperty.prototype.toString = function () {
+  return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
+};
+
+function Property(key, value) {
+  this.key = key;
+  this.value = value;
+}
+
+Property.prototype.toString = function () {
+  return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
+};
+
+Property.prototype.equals = function (other) {
+  return (other instanceof Property) && this.key === other.key && this.value === other.value;
+};
+
+/**
+ * Represents a walk through a graph as defined by a traversal.
+ * @param {Array} labels
+ * @param {Array} objects
+ * @constructor
+ */
+function Path(labels, objects) {
+  this.labels = labels;
+  this.objects = objects;
+}
+
+module.exports = {
+  Edge: Edge,
+  Graph: Graph,
+  Path: Path,
+  Property: Property,
+  Vertex: Vertex,
+  VertexProperty: VertexProperty
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
new file mode 100644
index 0000000..46d251e
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -0,0 +1,398 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('../../process/traversal');
+var Bytecode = require('../../process/bytecode');
+var g = require('../graph.js');
+
+/**
+ * A type serializer
+ * @typedef {Object} Serializer
+ * @property {Function} serialize
+ * @property {Function} deserialize
+ * @property {Function} [canBeUsedFor]
+ */
+
+/**
+ * @const
+ * @private
+ */
+var valueKey = '@value';
+
+/**
+ * @const
+ * @private
+ */
+var typeKey = '@type';
+
+var deserializers = {
+  'g:Traverser': TraverserSerializer,
+  'g:Int32':  NumberSerializer,
+  'g:Int64':  NumberSerializer,
+  'g:Float':  NumberSerializer,
+  'g:Double': NumberSerializer,
+  'g:Vertex': VertexSerializer,
+  'g:Edge': EdgeSerializer,
+  'g:VertexProperty': VertexPropertySerializer,
+  'g:Property': PropertySerializer,
+  'g:Path': PathSerializer
+};
+
+var serializers = [
+  NumberSerializer,
+  BytecodeSerializer,
+  TraverserSerializer,
+  PSerializer,
+  LambdaSerializer,
+  EnumSerializer
+];
+
+/**
+ * GraphSON Writer
+ * @param {Object} [options]
+ * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
+ * serializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+function GraphSONWriter(options) {
+  this._options = options || {};
+  // Create instance of the default serializers
+  this._serializers = serializers.map(function (serializerConstructor) {
+    var s = new serializerConstructor();
+    s.writer = this;
+    return s;
+  }, this);
+  var customSerializers = this._options.serializers || {};
+  Object.keys(customSerializers).forEach(function (key) {
+    var s = customSerializers[key];
+    if (!s.serialize) {
+      return;
+    }
+    s.writer = this;
+    // Insert custom serializers first
+    this._serializers.unshift(s);
+  }, this);
+}
+
+GraphSONWriter.prototype.adaptObject = function (value) {
+  var s;
+  if (Array.isArray(value)) {
+    return value.map(function (item) {
+      return this.adaptObject(item);
+    }, this);
+  }
+  for (var i = 0; i < this._serializers.length; i++) {
+    var currentSerializer = this._serializers[i];
+    if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
+      s = currentSerializer;
+      break;
+    }
+  }
+  if (s) {
+    return s.serialize(value);
+  }
+  // Default (strings / objects / ...)
+  return value;
+};
+
+/**
+ * Returns the GraphSON representation of the provided object instance.
+ * @param {Object} obj
+ * @returns {String}
+ */
+GraphSONWriter.prototype.write = function (obj) {
+  return JSON.stringify(this.adaptObject(obj));
+};
+
+/**
+ * GraphSON Reader
+ * @param {Object} [options]
+ * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
+ * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+function GraphSONReader(options) {
+  this._options = options || {};
+  this._deserializers = {};
+  Object.keys(deserializers).forEach(function (typeName) {
+    var serializerConstructor = deserializers[typeName];
+    var s = new serializerConstructor();
+    s.reader = this;
+    this._deserializers[typeName] = s;
+  }, this);
+  if (this._options.serializers) {
+    var customSerializers = this._options.serializers || {};
+    Object.keys(customSerializers).forEach(function (key) {
+      var s = customSerializers[key];
+      if (!s.deserialize) {
+        return;
+      }
+      s.reader = this;
+      this._deserializers[key] = s;
+    }, this);
+  }
+}
+
+GraphSONReader.prototype.read = function (obj) {
+  if (obj === undefined) {
+    return undefined;
+  }
+  if (obj === null) {
+    return null;
+  }
+  if (Array.isArray(obj)) {
+    return obj.map(function mapEach(item) {
+      return this.read(item);
+    }, this);
+  }
+  var type = obj[typeKey];
+  if (type) {
+    var d = this._deserializers[type];
+    if (d) {
+      // Use type serializer
+      return d.deserialize(obj);
+    }
+    return obj[valueKey];
+  }
+  if (obj && typeof obj === 'object' && obj.constructor === Object) {
+    return this._deserializeObject(obj);
+  }
+  // Default (for boolean, number and other scalars)
+  return obj;
+};
+
+GraphSONReader.prototype._deserializeObject = function (obj) {
+  var keys = Object.keys(obj);
+  var result = {};
+  for (var i = 0; i < keys.length; i++) {
+    result[keys[i]] = this.read(obj[keys[i]]);
+  }
+  return result;
+};
+
+function NumberSerializer() {
+
+}
+
+NumberSerializer.prototype.serialize = function (item) {
+  return item;
+};
+
+NumberSerializer.prototype.deserialize = function (obj) {
+  var value = obj[valueKey];
+  return parseFloat(value);
+};
+
+NumberSerializer.prototype.canBeUsedFor = function (value) {
+  return (typeof value === 'number');
+};
+
+function BytecodeSerializer() {
+
+}
+
+BytecodeSerializer.prototype.serialize = function (item) {
+  var bytecode = item;
+  if (item instanceof t.Traversal) {
+    bytecode = item.getBytecode();
+  }
+  var result = {};
+  result[typeKey] = 'g:Bytecode';
+  var resultValue = result[valueKey] = {};
+  var sources = this._serializeInstructions(bytecode.sourceInstructions);
+  if (sources) {
+    resultValue['source'] = sources;
+  }
+  var steps = this._serializeInstructions(bytecode.stepInstructions);
+  if (steps) {
+    resultValue['step'] = steps;
+  }
+  return result;
+};
+
+BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
+  if (instructions.length === 0) {
+    return null;
+  }
+  var result = new Array(instructions.length);
+  result[0] = instructions[0];
+  for (var i = 1; i < instructions.length; i++) {
+    result[i] = this.writer.adaptObject(instructions[i]);
+  }
+  return result;
+};
+
+BytecodeSerializer.prototype.canBeUsedFor = function (value) {
+  return (value instanceof Bytecode) || (value instanceof t.Traversal);
+};
+
+function PSerializer() {
+
+}
+
+/** @param {P} item */
+PSerializer.prototype.serialize = function (item) {
+  var result = {};
+  result[typeKey] = 'g:P';
+  var resultValue = result[valueKey] = {
+    'predicate': item.operator
+  };
+  if (item.other == undefined) {
+    resultValue['value'] = this.writer.adaptObject(item.value);
+  }
+  else {
+    resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+  }
+  return result;
+};
+
+PSerializer.prototype.canBeUsedFor = function (value) {
+  return (value instanceof t.P);
+};
+
+function LambdaSerializer() {
+
+}
+
+/** @param {Function} item */
+LambdaSerializer.prototype.serialize = function (item) {
+  var result = {};
+  result[typeKey] = 'g:Lambda';
+  result[valueKey] = {
+    'arguments': item.length,
+    'language': 'gremlin-javascript',
+    'script': item.toString()
+  };
+  return result;
+};
+
+LambdaSerializer.prototype.canBeUsedFor = function (value) {
+  return (typeof value === 'function');
+};
+
+function EnumSerializer() {
+
+}
+
+/** @param {EnumValue} item */
+EnumSerializer.prototype.serialize = function (item) {
+  var result = {};
+  result[typeKey] = 'g:' + item.typeName;
+  result[valueKey] = item.elementName;
+  return result;
+};
+
+EnumSerializer.prototype.canBeUsedFor = function (value) {
+  return value && value.typeName && value instanceof t.EnumValue;
+};
+
+function TraverserSerializer() {
+
+}
+
+/** @param {Traverser} item */
+TraverserSerializer.prototype.serialize = function (item) {
+  var result = {};
+  result[typeKey] = 'g:Traverser';
+  result[valueKey] = {
+    'value': this.writer.adaptObject(item.object),
+    'bulk': this.writer.adaptObject(item.bulk)
+  };
+  return result;
+};
+
+TraverserSerializer.prototype.deserialize = function (obj) {
+  var value = obj[valueKey];
+  return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
+};
+
+TraverserSerializer.prototype.canBeUsedFor = function (value) {
+  return (value instanceof t.Traverser);
+};
+
+function VertexSerializer() {
+
+}
+
+VertexSerializer.prototype.deserialize = function (obj) {
+  var value = obj[valueKey];
+  return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
+};
+
+function VertexPropertySerializer() {
+
+}
+
+VertexPropertySerializer.prototype.deserialize = function (obj) {
+  var value = obj[valueKey];
+  return new g.VertexProperty(
+    this.reader.read(value['id']),
+    value['label'],
+    this.reader.read(value['value']),
+    this.reader.read(value['properties'])
+  );
+};
+
+function PropertySerializer() {
+
+}
+
+PropertySerializer.prototype.deserialize = function (obj) {
+  var value = obj[valueKey];
+  return new g.Property(
+    value['key'],
+    this.reader.read(value['value']));
+};
+
+function EdgeSerializer() {
+
+}
+
+EdgeSerializer.prototype.deserialize = function (obj) {
+  var value = obj[valueKey];
+  return new g.Edge(
+    this.reader.read(value['id']),
+    this.reader.read(value['outV']),
+    value['label'],
+    this.reader.read(value['inV']),
+    this.reader.read(value['properties'])
+  );
+};
+
+function PathSerializer() {
+
+}
+
+PathSerializer.prototype.deserialize = function (obj) {
+  var value = obj[valueKey];
+  var objects = value['objects'].map(function objectMapItem(o) {
+    return this.reader.read(o);
+  }, this);
+  return new g.Path(this.reader.read(value['labels']), objects);
+};
+
+module.exports = {
+  GraphSONWriter: GraphSONWriter,
+  GraphSONReader: GraphSONReader
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
new file mode 100644
index 0000000..7691dda
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * A module containing any utility functions.
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+var util = require('util');
+
+exports.inherits = util.inherits;
+
+exports.parseArgs = function parseArgs() {
+  return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+};
+
+/**
+ * @param {Function} handler
+ * @returns {Promise}
+ */
+function defaultPromiseFactory(handler) {
+  return new Promise(function executor(resolve, reject) {
+    handler(function handlerCallback(err, result) {
+      if (err) {
+        return reject(err);
+      }
+      resolve(result);
+    });
+  });
+}
+
+/**
+ * Gets a resolved Promise instance.
+ * @param {Function} promiseFactory
+ * @returns {Promise}
+ */
+exports.resolvedPromise = function (promiseFactory) {
+  return toPromise(promiseFactory, function handler(cb) {
+    cb();
+  });
+};
+
+var toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
+  promiseFactory = promiseFactory || defaultPromiseFactory;
+  return promiseFactory(handler);
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
new file mode 100644
index 0000000..0976f31
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -0,0 +1,36 @@
+{
+  "name": "gremlin-javascript",
+  "version": "3.2.5-alpha1",
+  "description": "JavaScript Gremlin Language Variant",
+  "author": "Apache TinkerPop team",
+  "keywords": [
+    "graph",
+    "gremlin",
+    "tinkerpop",
+    "connection",
+    "glv",
+    "driver",
+    "graphdb"
+  ],
+  "license": "Apache-2.0",
+  "dependencies": {
+    "ws": "^3.0.0"
+  },
+  "devDependencies": {
+    "mocha": ">= 1.14.0"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/tinkerpop.git"
+  },
+  "bugs": {
+    "url": "https://issues.apache.org/jira/browse/TINKERPOP"
+  },
+  "scripts": {
+    "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+    "unit-test": "./node_modules/.bin/mocha test/unit"
+  },
+  "engines": {
+    "node": ">=4"
+  }
+}


[27/47] tinkerpop git commit: Support bulk

Posted by jo...@apache.org.
Support bulk


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/746356ec
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/746356ec
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/746356ec

Branch: refs/heads/TINKERPOP-1489
Commit: 746356ec989b9ec343d0f703a63c35ab43181315
Parents: 1cfbf05
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Nov 27 12:13:28 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:20 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/TraversalSource.template | 48 +++++++------
 .../gremlin-javascript/lib/process/traversal.js | 48 +++++++------
 .../test/unit/traversal-test.js                 | 71 ++++++++++++++++++--
 3 files changed, 119 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/746356ec/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index dbb7bc4..f75765f 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -22,15 +22,15 @@
  */
 'use strict';
 
-var utils = require('../utils');
-var parseArgs = utils.parseArgs;
-var itemDone = Object.freeze({ value: null, done: true });
-var emptyArray = Object.freeze([]);
+const utils = require('../utils');
+const parseArgs = utils.parseArgs;
+const itemDone = Object.freeze({ value: null, done: true });
 
 function Traversal(graph, traversalStrategies, bytecode) {
   this.graph = graph;
   this.traversalStrategies = traversalStrategies;
   this.bytecode = bytecode;
+  /** @type {Array<Traverser>} */
   this.traversers = null;
   this.sideEffects = null;
   this._traversalStrategiesPromise = null;
@@ -47,17 +47,13 @@ Traversal.prototype.getBytecode = function () {
  * @returns {Promise.<Array>}
  */
 Traversal.prototype.toList = function () {
-  var self = this;
-  return this._applyStrategies().then(function () {
-    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
-      return emptyArray;
+  return this._applyStrategies().then(() => {
+    const result = [];
+    let it;
+    while ((it = this._getNext()) && !it.done) {
+      result.push(it.value);
     }
-    var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
-    for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
-      arr[i] = self.traversers[i].object;
-    }
-    self._traversersIteratorIndex = self.traversers.length;
-    return arr;
+    return result;
   });
 };
 
@@ -67,13 +63,23 @@ Traversal.prototype.toList = function () {
  * @returns {Promise.<{value, done}>}
  */
 Traversal.prototype.next = function () {
-  var self = this;
-  return this._applyStrategies().then(function () {
-    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
-      return itemDone;
+  return this._applyStrategies().then(() => this._getNext());
+};
+
+/**
+ * Synchronous iterator of traversers including
+ * @private
+ */
+Traversal.prototype._getNext = function () {
+  while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+    let traverser = this.traversers[this._traversersIteratorIndex];
+    if (traverser.bulk > 0) {
+      traverser.bulk--;
+      return { value: traverser.object, done: false };
     }
-    return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
-  });
+    this._traversersIteratorIndex++;
+  }
+  return itemDone;
 };
 
 Traversal.prototype._applyStrategies = function () {
@@ -133,7 +139,7 @@ P.prototype.or = function (arg) {
 
 function Traverser(object, bulk) {
   this.object = object;
-  this.bulk = bulk == undefined ? 1 : bulk;
+  this.bulk = bulk || 1;
 }
 
 function TraversalSideEffects() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/746356ec/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 49c6aef..ebf8755 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -22,15 +22,15 @@
  */
 'use strict';
 
-var utils = require('../utils');
-var parseArgs = utils.parseArgs;
-var itemDone = Object.freeze({ value: null, done: true });
-var emptyArray = Object.freeze([]);
+const utils = require('../utils');
+const parseArgs = utils.parseArgs;
+const itemDone = Object.freeze({ value: null, done: true });
 
 function Traversal(graph, traversalStrategies, bytecode) {
   this.graph = graph;
   this.traversalStrategies = traversalStrategies;
   this.bytecode = bytecode;
+  /** @type {Array<Traverser>} */
   this.traversers = null;
   this.sideEffects = null;
   this._traversalStrategiesPromise = null;
@@ -47,17 +47,13 @@ Traversal.prototype.getBytecode = function () {
  * @returns {Promise.<Array>}
  */
 Traversal.prototype.toList = function () {
-  var self = this;
-  return this._applyStrategies().then(function () {
-    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
-      return emptyArray;
+  return this._applyStrategies().then(() => {
+    const result = [];
+    let it;
+    while ((it = this._getNext()) && !it.done) {
+      result.push(it.value);
     }
-    var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
-    for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
-      arr[i] = self.traversers[i].object;
-    }
-    self._traversersIteratorIndex = self.traversers.length;
-    return arr;
+    return result;
   });
 };
 
@@ -67,13 +63,23 @@ Traversal.prototype.toList = function () {
  * @returns {Promise.<{value, done}>}
  */
 Traversal.prototype.next = function () {
-  var self = this;
-  return this._applyStrategies().then(function () {
-    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
-      return itemDone;
+  return this._applyStrategies().then(() => this._getNext());
+};
+
+/**
+ * Synchronous iterator of traversers including
+ * @private
+ */
+Traversal.prototype._getNext = function () {
+  while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+    let traverser = this.traversers[this._traversersIteratorIndex];
+    if (traverser.bulk > 0) {
+      traverser.bulk--;
+      return { value: traverser.object, done: false };
     }
-    return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
-  });
+    this._traversersIteratorIndex++;
+  }
+  return itemDone;
 };
 
 Traversal.prototype._applyStrategies = function () {
@@ -193,7 +199,7 @@ P.prototype.or = function (arg) {
 
 function Traverser(object, bulk) {
   this.object = object;
-  this.bulk = bulk == undefined ? 1 : bulk;
+  this.bulk = bulk || 1;
 }
 
 function TraversalSideEffects() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/746356ec/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index c5271c9..635c7e8 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -22,14 +22,17 @@
  */
 'use strict';
 
-var assert = require('assert');
-var graph = require('../../lib/structure/graph');
-var utils = require('../../lib/utils');
-var t = require('../../lib/process/traversal');
-var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
+const assert = require('assert');
+const expect = require('chai').expect;
+const graph = require('../../lib/structure/graph');
+const utils = require('../../lib/utils');
+const t = require('../../lib/process/traversal');
+const TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
 
 describe('Traversal', function () {
+
   describe('#getByteCode()', function () {
+
     it('should add steps for with a string parameter', function () {
       var g = new graph.Graph().traversal();
       var bytecode = g.V().out('created').getBytecode();
@@ -40,6 +43,7 @@ describe('Traversal', function () {
       assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
       assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
     });
+
     it('should add steps with an enum value', function () {
       var g = new graph.Graph().traversal();
       var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
@@ -55,7 +59,9 @@ describe('Traversal', function () {
       assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
     });
   });
+
   describe('#next()', function () {
+
     it('should apply the strategies and return a Promise with the iterator item', function () {
       var strategyMock = {
         apply: function (traversal) {
@@ -83,8 +89,43 @@ describe('Traversal', function () {
           return traversal.next();
         });
     });
+
+    it('should support bulk', function () {
+      const strategyMock = {
+        apply: function (traversal) {
+          traversal.traversers = [ new t.Traverser(1, 2), new t.Traverser(2, 1) ];
+          return utils.resolvedPromise();
+        }
+      };
+      const strategies = new TraversalStrategies();
+      strategies.addStrategy(strategyMock);
+      const traversal = new t.Traversal(null, strategies, null);
+      return traversal.next()
+        .then(function (item) {
+          assert.strictEqual(item.value, 1);
+          assert.strictEqual(item.done, false);
+          return traversal.next();
+        })
+        .then(function (item) {
+          assert.strictEqual(item.value, 1);
+          assert.strictEqual(item.done, false);
+          return traversal.next();
+        })
+        .then(function (item) {
+          assert.strictEqual(item.value, 2);
+          assert.strictEqual(item.done, false);
+          return traversal.next();
+        })
+        .then(function (item) {
+          assert.strictEqual(item.value, null);
+          assert.strictEqual(item.done, true);
+          return traversal.next();
+        });
+    });
   });
+
   describe('#toList()', function () {
+
     it('should apply the strategies and return a Promise with an array', function () {
       var strategyMock = {
         apply: function (traversal) {
@@ -100,6 +141,7 @@ describe('Traversal', function () {
         assert.deepEqual(list, [ 'a', 'b' ]);
       });
     });
+
     it('should return an empty array when traversers is empty', function () {
       var strategyMock = {
         apply: function (traversal) {
@@ -114,6 +156,23 @@ describe('Traversal', function () {
         assert.ok(Array.isArray(list));
         assert.strictEqual(list.length, 0);
       });
-    })
+    });
+
+    it('should support bulk', function () {
+      const strategyMock = {
+        apply: function (traversal) {
+          traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 3), new t.Traverser(3, 2),
+            new t.Traverser(4, 1) ];
+          return utils.resolvedPromise();
+        }
+      };
+      const strategies = new TraversalStrategies();
+      strategies.addStrategy(strategyMock);
+      const traversal = new t.Traversal(null, strategies, null);
+      return traversal.toList()
+        .then(list => {
+          expect(list).to.have.members([1, 2, 2, 2, 3, 3, 4]);
+        });
+    });
   });
 });
\ No newline at end of file


[06/47] tinkerpop git commit: Added some more details on collections recipe for List CTR

Posted by jo...@apache.org.
Added some more details on collections recipe for List CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4eb80bd4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4eb80bd4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4eb80bd4

Branch: refs/heads/TINKERPOP-1489
Commit: 4eb80bd4878d455bff761c091b8fcd8414d59660
Parents: 586e432
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jan 16 14:31:55 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jan 16 14:31:55 2018 -0500

----------------------------------------------------------------------
 docs/src/recipes/collections.asciidoc | 282 ++++++++++++++++++++++++++++-
 1 file changed, 279 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4eb80bd4/docs/src/recipes/collections.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/collections.asciidoc b/docs/src/recipes/collections.asciidoc
index 446ed46..5db1e6b 100644
--- a/docs/src/recipes/collections.asciidoc
+++ b/docs/src/recipes/collections.asciidoc
@@ -21,9 +21,237 @@ image:gremlin-collections.png[width=400]
 
 Lists and maps form the basis for much of the processing in Gremlin traversals. They are core to how side-effects
 are typically held and how results are generally produced. Being able to pick them apart and reformat them is sometimes
-required.
+required. This need to shape the date within a traversal may arise both at the
+link:http://tinkerpop.apache.org/docs/current/reference/#terminal-steps[terminal step] of the traversal (technically
+just prior to the terminal step) or in the middle of a traversal. Considering the former, a transformation just prior
+to iteration will get the result into the form required by the application which would remove the need for additional
+application level manipulation. Moreover, a transformation at this stage may reduce the size of the payload being
+returned which could be useful in remote applications. Examining the latter, there may be times where a `List` or `Map`
+requires some mid-traversal transformation so as to continue with the general logic of the traversal itself. For
+example, a traversal at some point might produce a `Map` of `List` objects where the lists contain vertices, where each
+`List` might need to be sorted by some criteria and then the top item for each extracted to become the basis for the
+continued traversal. Executing transformations for either of these types of situations can be made possible with the
+patterns described in this section.
 
-One of the most common ways to end up with a `Map` is with `valueMap()`:
+The appearance of a `List` as a traverser in Gremlin usually arises as a result of a `fold()` operation, but may also
+appear by way of some side-effect steps like `store()`:
+
+[gremlin-groovy,modern]
+----
+g.V().fold()
+g.V().store('a').cap('a')
+----
+
+It is worth noting that while a `Path` is not technically a `List` it does present like one and can be manipulated in
+similar fashion to lists:
+
+[gremlin-groovy,modern]
+----
+g.V().out().out().path()
+----
+
+These examples are obviously trivial and there are other ways that a traverser might end up in a `List` form, but, at
+this moment, the point here is to focus less on how to get a `List` and more on how to manipulate one within the
+Gremlin language. The examples going forward will also be similarly contrived insofar as producing a usable `List` to
+manipulate. Bear in mind that it may be quite possible to get the same end results of these examples using more direct
+means than what is demonstrated.
+
+It may seem simple, but the most obvious choice to modifying what is in a list is to simply `unfold()` the `List`:
+
+[gremlin-groovy,modern]
+----
+g.V().fold().unfold().values('name')
+g.V().store('a').cap('a').unfold().values('name')
+----
+
+The above examples show that `unfold()` works quite well when you want don't want to preserve the `List` structure of
+the traverser as it just flattens `List` traversers to the traversal stream. The above examples only have one `List`
+as a result, but consider what happens when there is more than one:
+
+[gremlin-groovy,modern]
+----
+g.V().union(fold(),fold())
+g.V().union(fold(),fold()).unfold().values('name')
+----
+
+The two separate `List` traversers are flattened to a single traversal stream and all the results are mixed together.
+While this approach may be acceptable, there are many cases where it might not be so. To preserve the individual
+structure of the `List` traversers "locally" `unfold()` the lists to transform them:
+
+[gremlin-groovy,modern]
+----
+g.V().
+  union(fold(),fold()).
+  local(unfold().values('name').fold())
+----
+
+The call to `local()` executes its anonymous sub-traversal over each individual `List` iterator and as the
+sub-traversal ends with a `fold()` step, the results are reduced back into a `List` to preserve the original structure,
+thus maintaining two traverser results.
+
+This pattern for unfolding and folding `List` traversers ends up having other applications:
+
+[gremlin-groovy,modern]
+----
+g.V().union(limit(3).fold(),tail(3).fold())    <1>
+g.V().union(limit(3).fold(),tail(3).fold()).
+  local(unfold().                              <2>
+        order().
+          by(bothE().count(),decr).
+        limit(1).
+        fold())
+g.V().union(limit(3).fold(),tail(3).fold()).   <3>
+  local(unfold().
+        has('age',gte(29)).
+        values('age').
+        mean())
+----
+
+<1> The output consists of two `List` traversers.
+<2> For each `List` of vertices, order them by their number of edges, and choose the first one which will be the one
+with the highest degree (i.e. number of edges). By ending with `fold()` the `List` traverser structure is preserved
+thus returning two `List` objects. Consider this a method for choosing a "max" or a highly ranked vertex. In this case
+the rank was determined by the number of edges, but it could have just as easily been determined by a vertex property,
+edge property, a calculated value, etc. - one simply needs to alter the `by()` step modulator to `order()`.
+<3> For each `List` of vertices, filter that `List` to only include vertices that have an "age" property with a
+value greater than or equal to "29" and then average the results of each list. More generally, consider how this
+approach performs some kind of reducing calculation on each `List` traverser. In this case, an average was calculated,
+but it might also have been a `sum()`, `count()` or similar operation that reduced the list to a single calculated
+value.
+
+So far, this section has focused on what to do with a `List` traverser once there is one present and there have been
+fairly contrived examples for how to produce one in the first place. The use of `fold()` has been used most frequently
+at this point to achieve list creation and that step should be recalled whenever there is a need to reduce some
+traversal stream to an actual `List`. Of course, it may become necessary to more manually construct a `List`,
+especially in cases where the expected output of the traversal is composed of one or more ordered results in the
+form of a `List`. For example, consider the following three traversals:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').values('age')     <1>
+g.V().has('name','marko').                  <2>
+  repeat(out()).
+    until(has('lang','java')).
+  path().
+    by('name')
+g.V().has('name','marko').                  <3>
+  repeat(outE().inV()).
+    until(has('lang','java')).
+  path().
+  local(unfold().
+        has('weight').
+        values('weight').
+        mean())
+----
+
+<1> Get the age of "marko"
+<2> get the "name" values of the vertices in the collected paths that traverse out from "marko" to any vertex with
+the "lang" of "java".
+<3> Get the average of the "weight" values of edges in the collected paths that traverse out from "marko" to any vertex
+with the "lang" of "java". Note the use of the earlier defined pattern that used `local()` in conjunction with
+`unfold()`. In this case it filters out vertices from the `Path` as they are not relevant as the concern is only with
+the "weight" property on the edges.
+
+For purposes of this example, the three traversals above happen to represent three pieces of data that are required by
+an application. It is plain to note that all of the above traversals hold a similar pattern that starts with
+"getting 'marko'" and, in the case of the latter two, traversing on outgoing edges away from him and collecting data
+from that path. Ideally, all three of these traversals should execute as one to prevent having to submit three separate
+traversals, thus incurring additional query execution costs for what amounts to be largely the same underlying data but
+with different transformations applied. The goal here would be to return the results of this data as a `List` with
+three results (i.e. triple) that could then be submitted once by the application. The following example demonstrates
+the use of `store()` to aid in construction of this `List`:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').as('v').                             <1>
+  store('a').                                                  <2>
+    by('age').
+  repeat(outE().as('e').inV().as('v')).                        <3>
+    until(has('lang','java')).
+  aggregate('b').                                              <4>
+    by(select(all,'v').unfold().values('name').fold()).
+  aggregate('c').                                              <5>
+    by(select(all,'e').unfold().values('weight').mean()).
+  fold().                                                      <6>
+  store('a').                                                  <7>
+    by(cap('b')).
+  store('a').                                                  <8>
+    by(cap('c')).
+  cap('a')
+----
+
+<1> Get the "marko" vertex and label that step as "v".
+<2> Store the first "age" of "marko" as the first item in the `List` called "a", which will ultimately be the result.
+<3> Execute the traversal away from "marko" and continue to traverse on outgoing edges until the vertex has the value
+of "java" for the "lang" property. Note the labels of "e" and "v". Note that "e" will contain a `List` of all of the
+edges that have been traversed and "v" will contain a `List` of all the vertices that have been traversed.
+<4> The incoming traverser to `aggregate('b')` are vertices that terminate the `repeat()` (i.e. those with the "lang"
+of "java"). Note however that the `by()` modulator overrides that traverser completely by starting a fresh stream of
+the list of vertices in "v". Those vertices are unfolded to retrieve the name property from each and then are reduced
+with `fold()` back into a list to be stored in the side-effected named "b".
+<5> A similar use of `aggregate()` as the previous step, though this one turns "e" into a stream of edges to calculate
+the `mean()` to store in a `List` called "c". Note that `aggregate()` was used here instead of `store()`, as
+the former is an eager collection of the elements in the stream (`store()` is lazy) and will force the traversal to be
+iterated up to that point before moving forward. Without that eager collection, "v" and "e" would not contain the
+complete information required for the production of "b" and "c".
+<6> Adding `fold()` step here is a bit of a trick. To see the trick, copy and paste all lines of Gremlin up to but
+not including this `fold()` step and run them against the "modern" graph. The output is three vertices and if the
+`profile()` step was added one would also see that the traversal contained three traversers. These three traversers
+with a vertex in each one were produced from the `repeat()` step (i.e. those vertices that had the "lang" of "java"
+when traversing away from "marko"). The `aggregate()` steps are side-effects and just allow the traversers to pass
+through them unchanged. The `fold()` obviously converts those three traversers to a single `List` to make one
+traverser with a `List` inside. That means that the remaining steps following the `fold()` will only be executed one
+time each instead of three, which, as will be shown, is critical to the proper result.
+<7> The single traverser with the `List` of three vertices in it passes to `store()`. The `by()` modulator presents an
+override telling Gremlin to ignore the `List` of three vertices and simply grab the "b" side effect created earlier and
+stick that into "a" as part of the result. The `List` with three vertices passes out unchanged as `store()` is a
+side-effect step.
+<8> Again, the single traverser with the `List` of three vertices passes to `store()` and again, the `by()` modulator
+presents an override to include "c" into the result.
+
+All of the above code and explanation show that `store()` can be used to construct `List` objects as side-effects
+which can then be used as a result. Note that `aggregate()` can be used to similar effect, should it make sense that
+lazy `List` creation is not acceptable with respect to the nature of the traversal. An interesting sub-pattern that
+emerges here is that the `by()` step can modulate its step to completely override the current traverser and ignore its
+contents for purpose of that step. This ability to override a traverser acts as a powerful and flexible tool as it
+means that each traverser can effectively become a completely different object as determined by a sub-traversal.
+
+Another interesting method for `List` creation was demonstrated a bit earlier but not examined in detail - the use of
+`union()`. It was shown earlier in the following context where it helped create a `List` of two lists of three
+vertices each:
+
+[gremlin-groovy,modern]
+----
+g.V().union(limit(3).fold(),tail(3).fold())
+----
+
+By folding the results of `union()`, it becomes possible to essentially construct lists with arbitrary traversal
+results.
+
+[gremlin-groovy,modern]
+----
+g.V().
+  local(union(identity(),                   <1>
+              bothE().count()).
+        fold())
+g.V().
+  store('x').
+    by(union(select('x').count(local),      <2>
+             identity(),
+             bothE().count()).
+             fold()).
+  cap('x')
+----
+
+<1> For each vertex, create a "pair" (i.e. a `List` of two objects) of the vertex itself and its edge count.
+<2> For each vertex, create a "triple" (i.e. a `List`of three objects) of the index of the vertex (starting at zero),
+the vertex itself and its edge count.
+
+The pattern here is to use `union()` in conjunction with `fold()`. As explained earlier, the `fold()` operation reduces
+the stream from `union()` to a single `List` that is then fed forward to the next step in the traversal.
+
+Now that `List` patterns have been explained, there can now be some attention on `Map`. One of the most common ways
+to end up with a `Map` is with `valueMap()`:
 
 [gremlin-groovy,modern]
 ----
@@ -64,4 +292,52 @@ on that sub-traversal (it does not iterate the entire thing).
 Generally speaking, a `Map` constructed as part of `group()` or `project()` will already be in the form required as
 the `by()` modulators would be written in such a fashion as to produce that final output. It would be unnecessary to
 deconstruct/reconstruct it. Be certain that there isn't a way to re-write the `group()` or `project()` to get the
-desired output before taking this approach.
\ No newline at end of file
+desired output before taking this approach.
+
+In the following case, `project()` is used to create a `Map` that does not meet this requirement as it contains some
+unavoidable extraneous keys in the output `Map`:
+
+[gremlin-groovy,modern]
+----
+g.V().
+  project('name','age','lang').
+    by('name').
+    by(coalesce(values('age'),constant('n/a'))).
+    by(coalesce(values('lang'),constant('n/a')))
+----
+
+The use of `coalesce()` works around the problem where "age" and "lang" are not necessarily property keys present on
+every single vertex in the traversal stream. When the "age" or "lang" are not present, the constant of "n/a" is
+supplied. While this may be an acceptable output, it is possible to shape the `Map` to be "nicer":
+
+[gremlin-groovy,modern]
+----
+g.V().
+  project('name','age','lang').
+    by('name').
+    by(coalesce(values('age'),constant('n/a'))).
+    by(coalesce(values('lang'),constant('n/a'))).
+  local(unfold().
+        filter(select(values).is(P.neq('n/a'))).
+        group().
+          by(keys).
+          by(values))
+----
+
+The addition steps above `unfold()` the `Map` to key-value entries and filter the values for "n/a" and remove them
+prior to reconstructing the `Map` with the method shown earlier. To go a step further, apply the pattern presented
+earlier to flatten `List` values within a `Map`:
+
+[gremlin-groovy,modern]
+----
+g.V().
+  project('name','age','lang').
+    by('name').
+    by(coalesce(values('age'),constant('n/a'))).
+    by(coalesce(values('lang'),constant('n/a'))).
+  local(unfold().
+        filter(select(values).is(P.neq('n/a'))).
+        group().
+          by(keys).
+          by(select(values).unfold()))
+----
\ No newline at end of file


[26/47] tinkerpop git commit: Use cucumber-js

Posted by jo...@apache.org.
Use cucumber-js


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a0275d05
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a0275d05
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a0275d05

Branch: refs/heads/TINKERPOP-1489
Commit: a0275d05c993db81b7e6cbc7ccbbcd2c06332f36
Parents: 033c8af
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 22 17:44:18 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:20 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/PackageJson.template     |  4 +-
 gremlin-javascript/pom.xml                      | 16 ++++-
 .../javascript/gremlin-javascript/package.json  |  4 +-
 .../test/cucumber/feature-steps.js              | 69 ++++++++++++++++++++
 .../gremlin-javascript/test/cucumber/world.js   | 33 ++++++++++
 5 files changed, 121 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a0275d05/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index f61913f..3ff17af 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -36,7 +36,8 @@
     "ws": "^3.0.0"
   },
   "devDependencies": {
-    "mocha": ">= 1.14.0"
+    "mocha": "~4.0.1",
+    "cucumber": "~3.1.0"
   },
   "repository": {
     "type": "git",
@@ -47,6 +48,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+    "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a0275d05/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index c08b59b..871fd7a 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -269,31 +269,41 @@ server.stop().join()
                 <executions>
                     <execution>
                         <id>install node and npm</id>
+                        <phase>generate-test-resources</phase>
                         <goals>
                             <goal>install-node-and-npm</goal>
                         </goals>
-                        <phase>generate-test-resources</phase>
                     </execution>
                     <execution>
                         <id>npm install</id>
+                        <phase>generate-test-resources</phase>
                         <goals>
                             <goal>npm</goal>
                         </goals>
-                        <phase>generate-test-resources</phase>
                         <configuration>
                             <arguments>install</arguments>
                         </configuration>
                     </execution>
                     <execution>
                         <id>npm test</id>
+                        <phase>integration-test</phase>
                         <goals>
                             <goal>npm</goal>
                         </goals>
-                        <phase>integration-test</phase>
                         <configuration>
                             <arguments>test</arguments>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>npm test gherkin features</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>npm</goal>
+                        </goals>
+                        <configuration>
+                            <arguments>run-script features</arguments>
+                        </configuration>
+                    </execution>
                 </executions>
                 <configuration>
                     <skip>${skipIntegrationTests}</skip>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a0275d05/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 1228dd4..dfbaff2 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -17,7 +17,8 @@
     "ws": "^3.0.0"
   },
   "devDependencies": {
-    "mocha": ">= 1.14.0"
+    "mocha": "~4.0.1",
+    "cucumber": "~3.1.0"
   },
   "repository": {
     "type": "git",
@@ -28,6 +29,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+    "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a0275d05/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
new file mode 100644
index 0000000..10680b7
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -0,0 +1,69 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const {defineSupportCode} = require('cucumber');
+const vm = require('vm');
+
+
+defineSupportCode(function({Given, When, Then}) {
+  Given(/^the (.+) graph$/, function (graphName) {
+    //TODO: Set context g
+  });
+  // Given('the graph initializer of');
+  Given('an unsupported test', () => {});
+
+  Given('the traversal of', function (traversalText) {
+    //TODO: make traversal
+  });
+
+  Given(/^$/, function (paramName, stringValue) {
+    //TODO: Add parameter
+  });
+
+  When('iterated to list', function () {
+    //TODO
+  });
+
+  When('iterated next', function () {
+    //TODO
+  });
+
+  Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+    //TODO
+    //console.log('--resultTable', resultTable.rows());
+    if (typeof resultTable === 'function'){
+      return resultTable();
+    }
+  });
+
+  Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
+
+  });
+
+  Then(/^the result should have a count of (\d+)$/, function (stringCount) {
+
+  });
+
+  Then('nothing should happen because', () => {});
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a0275d05/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
new file mode 100644
index 0000000..f1cd7a6
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const {defineSupportCode} = require('cucumber');
+
+defineSupportCode(function ({setWorldConstructor}) {
+  function TinkerPopWorld(){
+    this.g = null;
+    this.traversal = null;
+  }
+  setWorldConstructor(TinkerPopWorld);
+});
\ No newline at end of file


[08/47] tinkerpop git commit: Javascript GLV

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
new file mode 100644
index 0000000..e44ef90
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+  "use strict";
+
+  var helper = loadModule.call(this, './helper.js');
+  var assert = helper.assert;
+  var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+  var t = helper.loadLibModule.call(this, 'process/traversal.js');
+  var gs = helper.loadLibModule.call(this, 'structure/io/graph-serializer.js');
+  var GraphSONReader = gs.GraphSONReader;
+  var GraphSONWriter = gs.GraphSONWriter;
+  var P = t.P;
+
+  [
+    function testReadNumbers() {
+      var reader = new GraphSONReader();
+      [
+        [{
+          "@type": "g:Int32",
+          "@value": 31
+        }, 31],
+        [{
+          "@type": "g:Float",
+          "@value": 31.3
+        }, 31.3],
+        [{
+          "@type": "g:Double",
+          "@value": 31.2
+        }, 31.2]
+      ].forEach(function (item) {
+        var result = reader.read(item[0]);
+        assert.strictEqual(result, item[1]);
+        assert.strictEqual(typeof result, 'number');
+      });
+    },
+    function testReadGraph() {
+      var obj = {"@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":9}, "inV":{"@type":"g:Int32","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}],"knows":[{"id":{"@type":"g:Int32","@value":7},"inV":{"@type":"g:Int32","@value":2},"properties":{"weight":{"@type":"g:Double","@value":0.5}}},{"id":{"@type":"g:Int32","@value":8},"inV":{"@type":"g:Int32","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],"age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
+      var reader = new GraphSONReader(obj);
+      var result = reader.read(obj);
+      assert.ok(result instanceof graph.Vertex);
+      assert.strictEqual(result.label, 'person');
+      assert.strictEqual(typeof result.id, 'number');
+    },
+    function testReadPath() {
+      var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
+        {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},
+        {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},
+        "lop"]}};
+      var reader = new GraphSONReader(obj);
+      var result = reader.read(obj);
+      assert.ok(result);
+      assert.ok(result.objects);
+      assert.ok(result.labels);
+      assert.strictEqual(result.objects[2], 'lop');
+      assert.ok(result.objects[0] instanceof graph.Vertex);
+      assert.ok(result.objects[1] instanceof graph.Vertex);
+      assert.strictEqual(result.objects[0].label, 'person');
+      assert.strictEqual(result.objects[1].label, 'software');
+    },
+    function testWriteNumber() {
+      var writer = new GraphSONWriter();
+      assert.strictEqual(writer.write(2), '2');
+    },
+    function testWriteBoolean() {
+      var writer = new GraphSONWriter();
+      assert.strictEqual(writer.write(true), 'true');
+      assert.strictEqual(writer.write(false), 'false');
+    },
+    function testWriteNumber() {
+      var writer = new GraphSONWriter();
+      var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
+      assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
+    }
+  ].forEach(function (testCase) {
+    testCase.call(null);
+  });
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      return load(__DIR__ + moduleName);
+    }
+    throw new Error('No module loader was found');
+  }
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
new file mode 100644
index 0000000..477df91
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+  "use strict";
+
+  var helper = loadModule.call(this, './helper.js');
+  var assert = helper.assert;
+  var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+
+  [
+    function testBytecode() {
+      var g = new graph.Graph().traversal();
+      var bytecode = g.V().out('created').getBytecode();
+      assert.ok(bytecode);
+      assert.strictEqual(bytecode.sourceInstructions.length, 0);
+      assert.strictEqual(bytecode.stepInstructions.length, 2);
+      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+      assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
+      assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+    }
+  ].forEach(function (testCase) {
+    testCase.call(null);
+  });
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      return load(__DIR__ + moduleName);
+    }
+    throw new Error('No module loader was found');
+  }
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 075c89f..9603d76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,6 +120,7 @@ limitations under the License.
         <module>gremlin-groovy</module>
         <module>gremlin-groovy-test</module>
         <module>tinkergraph-gremlin</module>
+        <module>gremlin-javascript</module>
         <module>gremlin-python</module>
         <module>gremlin-dotnet</module>
         <module>hadoop-gremlin</module>


[46/47] tinkerpop git commit: install Maven 3.3.9 as part of the Docker build process

Posted by jo...@apache.org.
install Maven 3.3.9 as part of the Docker build process


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/343ddc2d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/343ddc2d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/343ddc2d

Branch: refs/heads/TINKERPOP-1489
Commit: 343ddc2d7a966efb7a2e318fedabd6c65faba25e
Parents: 4899a6b
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu Apr 6 14:40:05 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:23 2018 +0100

----------------------------------------------------------------------
 docker/build/Dockerfile.template | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/343ddc2d/docker/build/Dockerfile.template
----------------------------------------------------------------------
diff --git a/docker/build/Dockerfile.template b/docker/build/Dockerfile.template
index 84f551d..17084c9 100644
--- a/docker/build/Dockerfile.template
+++ b/docker/build/Dockerfile.template
@@ -20,3 +20,7 @@ FROM tinkerpop:hadoop-HADOOP_VERSION
 RUN mkdir -p /usr/src/tinkerpop
 WORKDIR /usr/src/tinkerpop
 COPY . /usr/src/tinkerpop
+RUN chmod 744 ./.travis.install-maven.sh
+ENV M2_HOME /root/mvn-home
+ENV PATH ${M2_HOME}/bin:${PATH}
+RUN ./.travis.install-maven.sh 3.3.9 ${M2_HOME}


[02/47] tinkerpop git commit: TINKERPOP-1860 Added tests for valueMap(true) variations

Posted by jo...@apache.org.
TINKERPOP-1860 Added tests for valueMap(true) variations

Note that with GraphSON 2.0 we get back string representations of T.id and T.label. That may change for GraphSON 3.0 on the 3.3.x line of code.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/caede9c8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/caede9c8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/caede9c8

Branch: refs/heads/TINKERPOP-1489
Commit: caede9c8ca5cad07b947a53b38a9cc145500f6bf
Parents: fbcb044
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Dec 29 08:02:55 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jan 8 09:21:40 2018 -0500

----------------------------------------------------------------------
 .../step/map/GroovyValueMapTest.groovy          | 10 +++
 .../src/main/jython/radish/feature_steps.py     |  8 +-
 gremlin-test/features/map/ValueMap.feature      | 32 +++++++
 .../traversal/step/map/ValueMapTest.java        | 95 ++++++++++++++++++++
 4 files changed, 144 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/caede9c8/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy
index c3c20fa..046f4ef 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy
@@ -34,11 +34,21 @@ public abstract class GroovyValueMapTest {
         }
 
         @Override
+        public Traversal<Vertex, Map<String, Object>> get_g_V_valueMapXtrueX() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.valueMap(true)")
+        }
+
+        @Override
         public Traversal<Vertex, Map<String, List>> get_g_V_valueMapXname_ageX() {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V.valueMap('name', 'age')")
         }
 
         @Override
+        public Traversal<Vertex, Map<String, Object>> get_g_V_valueMapXtrue_name_ageX() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.valueMap(true, 'name', 'age')")
+        }
+
+        @Override
         public Traversal<Vertex, Map<String, List<String>>> get_g_VX1X_outXcreatedX_valueMap(final Object v1Id) {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').valueMap", "v1Id", v1Id)
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/caede9c8/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 452eaa4..3de641e 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -33,6 +33,8 @@ regex_in = re.compile(r"([(.,\s])in\(")
 regex_is = re.compile(r"([(.,\s])is\(")
 regex_not = re.compile(r"([(.,\s])not\(")
 regex_or = re.compile(r"([(.,\s])or\(")
+regex_true = re.compile(r"(true)")
+regex_false = re.compile(r"(false)")
 
 
 ignores = [
@@ -157,6 +159,8 @@ def _convert(val, ctx):
         return Path([set([])], path_objects)
     elif isinstance(val, str) and re.match("^c\[.*\]$", val):         # parse lambda/closure
         return lambda: (val[2:-1], "gremlin-groovy")
+    elif isinstance(val, str) and re.match("^t\[.*\]$", val):         # parse instance of T enum
+        return T[val[2:-1]]
     else:
         return val
 
@@ -209,7 +213,9 @@ def _translate(traversal):
     replaced = regex_is.sub(r"\1is_(", replaced)
     replaced = regex_not.sub(r"\1not_(", replaced)
     replaced = regex_or.sub(r"\1or_(", replaced)
-    return regex_in.sub(r"\1in_(", replaced)
+    replaced = regex_in.sub(r"\1in_(", replaced)
+    replaced = regex_true.sub(r"True", replaced)
+    return regex_false.sub(r"False", replaced)
 
 
 def _make_traversal(g, traversal_string, params):

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/caede9c8/gremlin-test/features/map/ValueMap.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/ValueMap.feature b/gremlin-test/features/map/ValueMap.feature
index 2390512..0860b15 100644
--- a/gremlin-test/features/map/ValueMap.feature
+++ b/gremlin-test/features/map/ValueMap.feature
@@ -33,6 +33,22 @@ Feature: Step - valueMap()
       | m[{"name": ["lop"], "lang": ["java"]}] |
       | m[{"name": ["ripple"], "lang": ["java"]}] |
 
+  Scenario: g_V_valueMapXtrueX
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().valueMap(true)
+      """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | m[{"id": "v[marko].id", "label": "person", "name": ["marko"], "age": [29]}] |
+      | m[{"id": "v[josh].id", "label": "person", "name": ["josh"], "age": [32]}] |
+      | m[{"id": "v[peter].id", "label": "person", "name": ["peter"], "age": [35]}] |
+      | m[{"id": "v[vadas].id", "label": "person", "name": ["vadas"], "age": [27]}] |
+      | m[{"id": "v[lop].id", "label": "software", "name": ["lop"], "lang": ["java"]}] |
+      | m[{"id": "v[ripple].id", "label": "software", "name": ["ripple"], "lang": ["java"]}] |
+
   Scenario: g_V_valueMapXname_ageX
     Given the modern graph
     And the traversal of
@@ -49,6 +65,22 @@ Feature: Step - valueMap()
       | m[{"name": ["lop"]}] |
       | m[{"name": ["ripple"]}] |
 
+  Scenario: g_V_valueMapXtrue_name_ageX
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().valueMap(true, "name", "age")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | m[{"id": "v[marko].id", "label": "person", "name": ["marko"], "age": [29]}] |
+      | m[{"id": "v[josh].id", "label": "person", "name": ["josh"], "age": [32]}] |
+      | m[{"id": "v[peter].id", "label": "person", "name": ["peter"], "age": [35]}] |
+      | m[{"id": "v[vadas].id", "label": "person", "name": ["vadas"], "age": [27]}] |
+      | m[{"id": "v[lop].id", "label": "software", "name": ["lop"]}] |
+      | m[{"id": "v[ripple].id", "label": "software", "name": ["ripple"]}] |
+
   Scenario: g_VX1X_outXcreatedX_valueMap
     Given the modern graph
     And using the parameter v1Id defined as "v[marko].id"

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/caede9c8/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ValueMapTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ValueMapTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ValueMapTest.java
index 0935945..d1f08ce 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ValueMapTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ValueMapTest.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
+import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -31,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
+import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
 
 /**
@@ -42,8 +44,12 @@ public abstract class ValueMapTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Map<String, List>> get_g_V_valueMap();
 
+    public abstract Traversal<Vertex, Map<String, Object>> get_g_V_valueMapXtrueX();
+
     public abstract Traversal<Vertex, Map<String, List>> get_g_V_valueMapXname_ageX();
 
+    public abstract Traversal<Vertex, Map<String, Object>> get_g_V_valueMapXtrue_name_ageX();
+
     public abstract Traversal<Vertex, Map<String, List<String>>> get_g_VX1X_outXcreatedX_valueMap(final Object v1Id);
 
     @Test
@@ -78,6 +84,43 @@ public abstract class ValueMapTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
+    public void g_V_valueMapXtrueX() {
+        final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_valueMapXtrueX();
+        printTraversalForm(traversal);
+        int counter = 0;
+        while (traversal.hasNext()) {
+            counter++;
+            final Map<String, Object> values = traversal.next();
+            final String name = (String) ((List) values.get("name")).get(0);
+            assertEquals(4, values.size());
+            assertThat(values.containsKey(T.id), is(true));
+            if (name.equals("marko")) {
+                assertEquals(29, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("josh")) {
+                assertEquals(32, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("peter")) {
+                assertEquals(35, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("vadas")) {
+                assertEquals(27, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("lop")) {
+                assertEquals("java", ((List) values.get("lang")).get(0));
+                assertEquals("software", values.get(T.label));
+            } else if (name.equals("ripple")) {
+                assertEquals("java", ((List) values.get("lang")).get(0));
+                assertEquals("software", values.get(T.label));
+            } else {
+                throw new IllegalStateException("It is not possible to reach here: " + values);
+            }
+        }
+        assertEquals(6, counter);
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
     public void g_V_valueMapXname_ageX() {
         final Traversal<Vertex, Map<String, List>> traversal = get_g_V_valueMapXname_ageX();
         printTraversalForm(traversal);
@@ -113,6 +156,48 @@ public abstract class ValueMapTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
+    public void g_V_valueMapXtrue_name_ageX() {
+        final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_valueMapXtrue_name_ageX();
+        printTraversalForm(traversal);
+        int counter = 0;
+        while (traversal.hasNext()) {
+            counter++;
+            final Map<String, Object> values = traversal.next();
+            final String name = (String) ((List) values.get("name")).get(0);
+            assertThat(values.containsKey(T.id), is(true));
+            if (name.equals("marko")) {
+                assertEquals(4, values.size());
+                assertEquals(29, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("josh")) {
+                assertEquals(4, values.size());
+                assertEquals(32, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("peter")) {
+                assertEquals(4, values.size());
+                assertEquals(35, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("vadas")) {
+                assertEquals(4, values.size());
+                assertEquals(27, ((List) values.get("age")).get(0));
+                assertEquals("person", values.get(T.label));
+            } else if (name.equals("lop")) {
+                assertEquals(3, values.size());
+                assertNull(values.get("lang"));
+                assertEquals("software", values.get(T.label));
+            } else if (name.equals("ripple")) {
+                assertEquals(3, values.size());
+                assertNull(values.get("lang"));
+                assertEquals("software", values.get(T.label));
+            } else {
+                throw new IllegalStateException("It is not possible to reach here: " + values);
+            }
+        }
+        assertEquals(6, counter);
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
     public void g_VX1X_outXcreatedX_valueMap() {
         final Traversal<Vertex, Map<String, List<String>>> traversal = get_g_VX1X_outXcreatedX_valueMap(convertToVertexId("marko"));
         printTraversalForm(traversal);
@@ -132,11 +217,21 @@ public abstract class ValueMapTest extends AbstractGremlinProcessTest {
         }
 
         @Override
+        public Traversal<Vertex, Map<String, Object>> get_g_V_valueMapXtrueX() {
+            return g.V().valueMap(true);
+        }
+
+        @Override
         public Traversal<Vertex, Map<String, List>> get_g_V_valueMapXname_ageX() {
             return g.V().valueMap("name", "age");
         }
 
         @Override
+        public Traversal<Vertex, Map<String, Object>> get_g_V_valueMapXtrue_name_ageX() {
+            return g.V().valueMap(true, "name", "age");
+        }
+
+        @Override
         public Traversal<Vertex, Map<String, List<String>>> get_g_VX1X_outXcreatedX_valueMap(final Object v1Id) {
             return g.V(v1Id).out("created").valueMap();
         }


[05/47] tinkerpop git commit: Merge branch 'TINKERPOP-1860' into tp32

Posted by jo...@apache.org.
Merge branch 'TINKERPOP-1860' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/586e432b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/586e432b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/586e432b

Branch: refs/heads/TINKERPOP-1489
Commit: 586e432bbef36eb1e509e63031caa6f2aa44ef3d
Parents: a94baa0 caede9c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jan 16 08:11:28 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jan 16 08:11:28 2018 -0500

----------------------------------------------------------------------
 .../step/map/GroovyValueMapTest.groovy          | 10 +++
 .../src/main/jython/radish/feature_steps.py     |  8 +-
 gremlin-test/features/map/ValueMap.feature      | 32 +++++++
 .../traversal/step/map/ValueMapTest.java        | 95 ++++++++++++++++++++
 4 files changed, 144 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[17/47] tinkerpop git commit: TINKERPOP-1489 Added Nashorn ScriptEngine to gremlin-javascript

Posted by jo...@apache.org.
TINKERPOP-1489 Added Nashorn ScriptEngine to gremlin-javascript


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/129ab007
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/129ab007
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/129ab007

Branch: refs/heads/TINKERPOP-1489
Commit: 129ab00750d06fa4d6acaab736a71f4b64c6e474
Parents: 7d15e66
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 5 12:36:12 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:19 2018 +0100

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc                       | 2 +-
 .../src/main/javascript/gremlin-javascript/package.json            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/129ab007/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index 76952eb..4a2fe7a 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -447,7 +447,7 @@ very similar to that of Java, it should be very easy to switch between Gremlin-J
 [source,bash]
 npm install gremlin-javascript
 
-In Gremlin-JavaScript there exists `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes
+The Gremlin-JavaScript provides `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes
 in Gremlin-Java. The `GraphTraversalSource` requires a RemoteConnection implementation in order to communicate with
 <<gremlin-server,GremlinServer>>.
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/129ab007/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 514663b..1228dd4 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -1,6 +1,6 @@
 {
   "name": "gremlin-javascript",
-  "version": "3.2.6-alpha1",
+  "version": "3.2.7-alpha1",
   "description": "JavaScript Gremlin Language Variant",
   "author": "Apache TinkerPop team",
   "keywords": [


[44/47] tinkerpop git commit: Add toLong() method

Posted by jo...@apache.org.
Add toLong() method


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/54dee621
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/54dee621
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/54dee621

Branch: refs/heads/TINKERPOP-1489
Commit: 54dee62157cee188d6a46e90a32f9f7c1a0a3d33
Parents: 700cc68
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 29 11:37:24 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:22 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/PackageJson.template     |  2 +-
 .../main/javascript/gremlin-javascript/index.js |  4 +++-
 .../gremlin-javascript/lib/structure/graph.js   |  1 -
 .../lib/structure/io/graph-serializer.js        | 21 ++++++++++++++++++--
 .../javascript/gremlin-javascript/lib/utils.js  | 11 ++++++++++
 .../javascript/gremlin-javascript/package.json  |  2 +-
 .../test/cucumber/feature-steps.js              |  6 ++++--
 7 files changed, 39 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54dee621/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index 4f1ac05..1b54a87 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -49,7 +49,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
-    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54dee621/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index 600ac53..61ab274 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -29,6 +29,7 @@ var graph = require('./lib/structure/graph');
 var gs = require('./lib/structure/io/graph-serializer');
 var rc = require('./lib/driver/remote-connection');
 var Bytecode = require('./lib/process/bytecode');
+var utils = require('./lib/utils');
 
 module.exports = {
   driver: {
@@ -68,6 +69,7 @@ module.exports = {
     Path: graph.Path,
     Property: graph.Property,
     Vertex: graph.Vertex,
-    VertexProperty: graph.VertexProperty
+    VertexProperty: graph.VertexProperty,
+    toLong: utils.toLong
   }
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54dee621/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
index 95fd30f..cbb7e2c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -23,7 +23,6 @@
 'use strict';
 
 var gt = require('../process/graph-traversal');
-var t = require('../process/traversal');
 var TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
 var utils = require('../utils');
 var inherits = utils.inherits;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54dee621/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index ff3d72d..8e4ad5e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -24,7 +24,8 @@
 
 var t = require('../../process/traversal');
 var Bytecode = require('../../process/bytecode');
-var g = require('../graph.js');
+var g = require('../graph');
+var utils = require('../../utils');
 
 /**
  * A type serializer
@@ -67,7 +68,8 @@ var serializers = [
   LambdaSerializer,
   EnumSerializer,
   VertexSerializer,
-  EdgeSerializer
+  EdgeSerializer,
+  LongSerializer
 ];
 
 /**
@@ -210,6 +212,21 @@ NumberSerializer.prototype.canBeUsedFor = function (value) {
   return (typeof value === 'number');
 };
 
+function LongSerializer() {
+
+}
+
+NumberSerializer.prototype.serialize = function (item) {
+  return {
+    [typeKey]: 'g:Int64',
+    [valueKey]: item.value
+  };
+};
+
+NumberSerializer.prototype.canBeUsedFor = function (value) {
+  return (value instanceof utils.Long);
+};
+
 function BytecodeSerializer() {
 
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54dee621/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
index 7691dda..cbaa53e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -59,4 +59,15 @@ exports.resolvedPromise = function (promiseFactory) {
 var toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
   promiseFactory = promiseFactory || defaultPromiseFactory;
   return promiseFactory(handler);
+};
+
+exports.toLong = function toLong(value) {
+  return new Long(value);
+};
+
+var Long = exports.Long = function Long(value) {
+  if (typeof value !== 'string' && typeof value !== 'number') {
+    throw new TypeError('Ty')
+  }
+  this.value = value.toString();
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54dee621/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 7c4a3d6..aae9eb9 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -30,7 +30,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
-    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54dee621/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 06a3283..12bc835 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -29,6 +29,7 @@ const util = require('util');
 const graphModule = require('../../lib/structure/graph');
 const graphTraversalModule = require('../../lib/process/graph-traversal');
 const traversalModule = require('../../lib/process/traversal');
+const utils = require('../../lib/utils');
 const Graph = graphModule.Graph;
 const Path = graphModule.Path;
 const __ = graphTraversalModule.statics;
@@ -185,6 +186,7 @@ function getSandbox(g, parameters) {
     Scope: traversalModule.scope,
     Operator: traversalModule.operator,
     T: traversalModule.t,
+    toLong: utils.toLong
   };
   // Pass the parameter to the sandbox
   Object.keys(parameters).forEach(paramName => sandbox[paramName] = parameters[paramName]);
@@ -194,8 +196,8 @@ function getSandbox(g, parameters) {
 function translate(traversalText) {
   // Remove escaped chars
   traversalText = traversalText.replace(/\\"/g, '"');
-  // Remove long suffix
-  traversalText = traversalText.replace(/\b(\d+)l\b/gi, '$1');
+  // Replace long suffix with Long instance
+  traversalText = traversalText.replace(/\b(\d+)l\b/gi, 'toLong($1)');
   // Change according to naming convention
   traversalText = traversalText.replace(/\.in\(/g, '.in_(');
   traversalText = traversalText.replace(/\.from\(/g, '.from_(');


[37/47] tinkerpop git commit: Adjust pom.xml to be forward compatible

Posted by jo...@apache.org.
Adjust pom.xml to be forward compatible


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/adac3a64
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/adac3a64
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/adac3a64

Branch: refs/heads/TINKERPOP-1489
Commit: adac3a6460966c58aec4a31ff2e923586740e175
Parents: cdd114c
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 30 16:05:10 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:22 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/pom.xml | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/adac3a64/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 830052b..aa219ab 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -150,7 +150,8 @@ def binding = ["enums": CoreImports.getClassImports()
                                         findAll { GraphTraversalSource.class.equals(it.returnType) }.
                                         findAll {
                                             !it.name.equals("clone") &&
-                                                    !it.name.equals(TraversalSource.Symbols.withBindings) &&
+                                                    // Use hardcoded name to be for forward-compatibility
+                                                    !it.name.equals("withBindings") &&
                                                     !it.name.equals(TraversalSource.Symbols.withRemote) &&
                                                     !it.name.equals(TraversalSource.Symbols.withComputer)
                                         }.
@@ -223,6 +224,10 @@ packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
                                     <name>executionName</name>
                                     <value>${project.name}</value>
                                 </property>
+                                <property>
+                                    <name>projectBaseDir</name>
+                                    <value>${project.basedir}</value>
+                                </property>
                             </properties>
                             <scripts>
                                 <script>${gremlin.server.dir}/src/test/scripts/test-server-start.groovy</script>


[39/47] tinkerpop git commit: Include information of Js development env and release

Posted by jo...@apache.org.
Include information of Js development env and release


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a59dd1c2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a59dd1c2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a59dd1c2

Branch: refs/heads/TINKERPOP-1489
Commit: a59dd1c228f6ca23b667b0ef97fe5e393433be27
Parents: 4d169db
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Jan 8 12:13:36 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:22 2018 +0100

----------------------------------------------------------------------
 .../dev/developer/development-environment.asciidoc   | 15 +++++++++++++++
 gremlin-javascript/pom.xml                           | 10 ++++++++++
 2 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a59dd1c2/docs/src/dev/developer/development-environment.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc
index 52542f8..b3b7706 100644
--- a/docs/src/dev/developer/development-environment.asciidoc
+++ b/docs/src/dev/developer/development-environment.asciidoc
@@ -131,6 +131,17 @@ This should update `~/.config/NuGet/NuGet.Config` a file with an entry containin
 
 See release documentation for more information on configuration for release.
 
+
+[[nodejs-environment]]
+=== JavaScript Environment
+When building `gremlin-javascript`, mvn command will include a local copy of Node.js runtime and npm inside your project
+using `com.github.eirslett:frontend-maven-plugin` plugin. This copy of the Node.js runtime will not affect any
+other existing Node.js runtime instances in your machine.
+
+The release manager should have the authentication token set, for more information see the Release Environment
+section below.
+
+
 [[release-environment]]
 === Release Environment
 
@@ -166,6 +177,10 @@ password =
 The release manager shall use the project's pypi credentials, which are available in the PMC repository.
 The `password` should be left blank so the deployment process in Maven will prompt for it at deployment time.
 
+To deploy `gremlin-javascript` on the link:https://www.npmjs.com[npm registry], the release manager must set the
+authentication information on the ~/.npmrc file. The easiest way to do that is to use the `npm adduser` command. This
+must be done only once, as the auth token doesn't have an expiration date and it's stored on your file system.
+
 [[building-testing]]
 == Building and Testing
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a59dd1c2/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 0825ba6..e55bc1e 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -246,6 +246,16 @@ limitations under the License.
                     <nodeVersion>v4.8.3</nodeVersion>
                 </configuration>
             </plugin>
+            <!--
+            there is no point to deploying the jvm stuff - there is no java source really - just poms
+            -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <profiles>


[28/47] tinkerpop git commit: Add travis support

Posted by jo...@apache.org.
Add travis support


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/033c8af2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/033c8af2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/033c8af2

Branch: refs/heads/TINKERPOP-1489
Commit: 033c8af2ce7ce2e105864c96f922382546d4b621
Parents: 129ab00
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 22 15:46:14 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:20 2018 +0100

----------------------------------------------------------------------
 .travis.yml                | 3 ++-
 gremlin-javascript/pom.xml | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/033c8af2/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9b7029c..2c86de3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,4 +15,5 @@ before_install:
 jobs:
   include:
     - script: "mvn clean install -Dci"
-    - script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
\ No newline at end of file
+    - script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
+    - script: "mvn clean install -pl :gremlin-javascript -DskipIntegrationTests=false"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/033c8af2/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 919c87e..c08b59b 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -31,7 +31,6 @@ limitations under the License.
             <artifactId>gremlin-core</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <!-- TESTING -->
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
             <artifactId>tinkergraph-gremlin</artifactId>


[25/47] tinkerpop git commit: Parse traversal parameters and use empty graph

Posted by jo...@apache.org.
Parse traversal parameters and use empty graph


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1cfbf053
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1cfbf053
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1cfbf053

Branch: refs/heads/TINKERPOP-1489
Commit: 1cfbf0530195980f19ceb144cb4b56242d522b0a
Parents: f8231bf
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Fri Nov 24 15:04:41 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:20 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/PackageJson.template     |   5 +-
 .../gremlin-javascript/lib/structure/graph.js   |  31 ++++
 .../javascript/gremlin-javascript/package.json  |   5 +-
 .../test/cucumber/feature-steps.js              | 156 +++++++++++++++----
 .../gremlin-javascript/test/cucumber/world.js   |  33 +++-
 .../test/integration/remote-connection-tests.js |   2 +-
 .../test/integration/traversal-test.js          |   2 +-
 7 files changed, 195 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cfbf053/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index 52d2c1d..4f1ac05 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -37,7 +37,8 @@
   },
   "devDependencies": {
     "mocha": "~4.0.1",
-    "cucumber": "~3.1.0"
+    "cucumber": "~3.1.0",
+    "chai": "~4.1.2"
   },
   "repository": {
     "type": "git",
@@ -48,7 +49,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
-    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cfbf053/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
index 4ef3fd5..95fd30f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -128,6 +128,37 @@ function Path(labels, objects) {
   this.objects = objects;
 }
 
+Path.prototype.equals = function (other) {
+  if (!(other instanceof Path)) {
+    return false;
+  }
+  if (other === this) {
+    return true;
+  }
+  return areEqual(this.objects, other.objects) && areEqual(this.labels, other.labels);
+};
+
+function areEqual(obj1, obj2) {
+  if (obj1 === obj2) {
+    return true;
+  }
+  if (typeof obj1.equals === 'function') {
+    return obj1.equals(obj2);
+  }
+  if (Array.isArray(obj1) && Array.isArray(obj2)) {
+    if (obj1.length !== obj2.length) {
+      return false;
+    }
+    for (let i = 0; i < obj1.length; i++) {
+      if (!areEqual(obj1[i], obj2[i])){
+        return false;
+      }
+    }
+    return true;
+  }
+  return false;
+}
+
 module.exports = {
   Edge: Edge,
   Graph: Graph,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cfbf053/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 43cf35f..aae9eb9 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -18,7 +18,8 @@
   },
   "devDependencies": {
     "mocha": "~4.0.1",
-    "cucumber": "~3.1.0"
+    "cucumber": "~3.1.0",
+    "chai": "~4.1.2"
   },
   "repository": {
     "type": "git",
@@ -29,7 +30,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
-    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cfbf053/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 5270b39..6625f29 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -23,36 +23,60 @@
 'use strict';
 
 const defineSupportCode = require('cucumber').defineSupportCode;
-const assert = require('assert');
 const vm = require('vm');
+const expect = require('chai').expect;
 const graphModule = require('../../lib/structure/graph');
 const graphTraversalModule = require('../../lib/process/graph-traversal');
 const traversalModule = require('../../lib/process/traversal');
 const Graph = graphModule.Graph;
+const Path = graphModule.Path;
 const __ = graphTraversalModule.statics;
 
+const parsers = [
+  [ 'd\\[([\\d.]+)\\]\\.[ilfdm]', toNumeric ],
+  [ 'v\\[(.+)\\]', toVertex ],
+  [ 'v\\[(.+)\\]\\.id', toVertexId ],
+  [ 'v\\[(.+)\\]\\.sid', toVertexIdString ],
+  [ 'e\\[(.+)\\]', toEdge ],
+  [ 'e\\[(.+)\\]\\.id', toEdgeId ],
+  [ 'e\\[(.+)\\]\\.sid', toEdgeIdString ],
+  [ 'p\\[(.+)\\]', toPath ],
+  [ 'l\\[(.*)\\]', toArray ],
+  [ 's\\[(.*)\\]', toArray ],
+  [ 'm\\[(.+)\\]', toMap ],
+  [ 'c\\[(.+)\\]', toLambda ]
+].map(x => [ new RegExp('^' + x[0] + '$'), x[1] ]);
+
 defineSupportCode(function(methods) {
   methods.Given(/^the (.+) graph$/, function (graphName) {
+    this.graphName = graphName;
+    const data = this.getData();
+    this.g = new Graph().traversal().withRemote(data.connection);
     if (graphName === 'empty') {
-      //TODO
+      return this.cleanEmptyGraph();
     }
-    const data = this.getDataByGraphName(graphName);
-    this.graphName = graphName;
-    this.g = new Graph().traversal().withRemote(data.connection)
   });
 
-  methods.Given('the graph initializer of', function () {
-    //TODO
+  methods.Given('the graph initializer of', function (traversalText) {
+    const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
+    return traversal.toList();
   });
 
   methods.Given('an unsupported test', () => {});
 
   methods.Given('the traversal of', function (traversalText) {
-    this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g));
+    this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
   });
 
-  methods.Given(/^$/, function (paramName, stringValue) {
-    //TODO: Add parameter
+  methods.Given(/^using the parameter (.+) defined as "(.+)"$/, function (paramName, stringValue) {
+    let p = Promise.resolve();
+    if (this.graphName === 'empty') {
+      p = this.loadEmptyGraphData();
+    }
+    const self = this;
+    return p.then(() => {
+      self.parameters[paramName] = parseValue.call(self, stringValue);
+    });
   });
 
   methods.When('iterated to list', function () {
@@ -63,35 +87,44 @@ defineSupportCode(function(methods) {
     return this.traversal.next().then(it => this.result = it.value);
   });
 
-  methods.Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+  methods.Then(/^the result should be (\w+)$/, function assertResult(characterizedAs, resultTable) {
+    if (characterizedAs === 'empty') {
+      expect(this.result).to.be.empty;
+      if (typeof resultTable === 'function'){
+        return resultTable();
+      }
+      return;
+    }
+    const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
     switch (characterizedAs) {
-      case 'empty':
-        assert.strictEqual(0, result.length);
-        break;
       case 'ordered':
-        const expectedResult = resultTable.rows().map(parseRow);
         console.log('--- ordered', expectedResult);
+        expect(this.result).to.have.deep.ordered.members(expectedResult);
+        break;
+      case 'unordered':
+        console.log('--- unordered expected:', expectedResult);
+        console.log('--- obtained:', this.result);
+        expect(this.result).to.have.deep.members(expectedResult);
         break;
-    }
-    //TODO
-    if (typeof resultTable === 'function'){
-      return resultTable();
     }
   });
 
-  methods.Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
-
+  methods.Then(/^the graph should return (\d+) for count of "(.+)"$/, function (stringCount, traversalText) {
+    const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
+    return traversal.toList().then(list => {
+      expect(list).to.have.lengthOf(parseInt(stringCount, 10));
+    });
   });
 
   methods.Then(/^the result should have a count of (\d+)$/, function (stringCount) {
-
+    expect(this.result).to.have.lengthOf(parseInt(stringCount, 10));
   });
 
-  methods.Then('nothing should happen because', () => {});
+  methods.Then('nothing should happen because', _ => {});
 });
 
-function getSandbox(g) {
-  return {
+function getSandbox(g, parameters) {
+  const sandbox = {
     g: g,
     __: __,
     Cardinality: traversalModule.cardinality,
@@ -104,14 +137,79 @@ function getSandbox(g) {
     Operator: traversalModule.operator,
     T: traversalModule.t,
   };
+  // Pass the parameter to the sandbox
+  Object.keys(parameters).forEach(paramName => sandbox[paramName] = parameters[paramName]);
+  return sandbox;
 }
 
 function translate(traversalText) {
-  traversalText = traversalText.replace('.in(', '.in_(');
-  traversalText = traversalText.replace('.from(', '.from_(');
+  // Remove escaped chars
+  traversalText = traversalText.replace(/\\"/g, '"');
+  // Change according to naming convention
+  traversalText = traversalText.replace(/\.in\(/g, '.in_(');
+  traversalText = traversalText.replace(/\.from\(/g, '.from_(');
   return traversalText;
 }
 
 function parseRow(row) {
-  return row[0];
-}
\ No newline at end of file
+  return parseValue.call(this, row[0]);
+}
+
+function parseValue(stringValue) {
+  let extractedValue = null;
+  let parser = null;
+  for (let item of parsers) {
+    let re = item[0];
+    let match = re.exec(stringValue);
+    if (match && match.length > 1) {
+      parser = item[1];
+      extractedValue = match[1];
+      break;
+    }
+  }
+  return parser !== null ? parser.call(this, extractedValue) : stringValue;
+}
+
+function toNumeric(stringValue) {
+  return parseFloat(stringValue);
+}
+
+function toVertex(name) {
+  return this.getData().vertices[name];
+}
+
+function toVertexId(name) {
+  return toVertex.call(this, name).id;
+}
+
+function toVertexIdString(name) {
+  return toVertex.call(this, name).id.toString();
+}
+
+function toEdge(name) {
+  return this.getData().edges[name];
+}
+
+function toEdgeId(name) {
+  return toEdge.call(this, name).id;
+}
+
+function toEdgeIdString(name) {
+  return toEdge.call(this, name).id.toString();
+}
+
+function toPath(value) {
+  const parts = value.split(',');
+  return new Path(parts.map(_ => new Array(0)), parts.map(x => parseValue.call(this, x)));
+}
+
+function toArray(stringList) {
+  if (stringList === '') {
+    return new Array(0);
+  }
+  return stringList.split(',').map(x => parseValue.call(this, x));
+}
+
+function toMap() {}
+
+function toLambda() {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cfbf053/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 8f72c58..946d124 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -37,18 +37,43 @@ defineSupportCode(function (methods) {
     this.traversal = null;
     this.result = null;
     this.cache = null;
+    this.graphName = null;
+    this.parameters = {};
   }
 
-  TinkerPopWorld.prototype.getDataByGraphName = function (name) {
-    return this.cache[name];
+  TinkerPopWorld.prototype.getData = function () {
+    if (!this.graphName) {
+      throw new Error("Graph name is not set");
+    }
+    return this.cache[this.graphName];
+  };
+
+  TinkerPopWorld.prototype.cleanEmptyGraph = function () {
+    const connection = this.cache['empty'].connection;
+    const g = new Graph().traversal().withRemote(connection);
+    return g.V().drop().toList();
+  };
+
+  TinkerPopWorld.prototype.loadEmptyGraphData = function () {
+    const cacheData = this.cache['empty'];
+    const c = cacheData.connection;
+    return Promise.all([ getVertices(c), getEdges(c) ]).then(values => {
+      cacheData.vertices = values[0];
+      cacheData.edges = values[1];
+    });
   };
 
   methods.setWorldConstructor(TinkerPopWorld);
 
   methods.BeforeAll(function () {
     // load all traversals
-    const promises = ['modern', 'classic', 'crew', 'grateful'].map(graphName => {
-      const connection = helper.getConnection('g' + graphName);
+    const promises = ['modern', 'classic', 'crew', 'grateful', 'empty'].map(graphName => {
+      let connection = null;
+      if (graphName === 'empty') {
+        connection = helper.getConnection('ggraph');
+        return connection.open().then(() => cache['empty'] = { connection: connection });
+      }
+      connection = helper.getConnection('g' + graphName);
       return connection.open()
         .then(() => Promise.all([getVertices(connection), getEdges(connection)]))
         .then(values => {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cfbf053/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
index 268773c..e4895fe 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -39,7 +39,7 @@ describe('DriverRemoteConnection', function () {
   });
   describe('#submit()', function () {
     it('should send the request and parse the response', function () {
-      return connection.submit(new Bytecode().addStep('addV', [ 'person' ]).addStep('property', [ 'name', 'marko']))
+      return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
         .then(function (response) {
           assert.ok(response);
           assert.ok(response.traversers);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cfbf053/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index adb7d6c..7109427 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -44,7 +44,7 @@ describe('Traversal', function () {
       var g = new Graph().traversal().withRemote(connection);
       return g.V().toList().then(function (list) {
         assert.ok(list);
-        assert.strictEqual(list.length, 7);
+        assert.strictEqual(list.length, 6);
         list.forEach(v => assert.ok(v instanceof Vertex));
       });
     });


[10/47] tinkerpop git commit: Javascript GLV

Posted by jo...@apache.org.
Javascript GLV


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4e768a81
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4e768a81
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4e768a81

Branch: refs/heads/TINKERPOP-1489
Commit: 4e768a81f9109cca737151efbd1212086fd58749
Parents: 4eb80bd
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Oct 5 16:14:46 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:17 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/pom.xml                      |  132 ++
 .../GraphTraversalSourceGenerator.groovy        |  247 +++
 .../javascript/TraversalSourceGenerator.groovy  |  398 ++++
 .../javascript/GenerateGremlinJavascript.java   |   32 +
 .../gremlin/javascript/jsr223/SymbolHelper.java |   59 +
 .../driver/remote-connection.js                 |  107 +
 .../main/javascript/gremlin-javascript/index.js |   85 +
 .../process/graph-traversal.js                  | 2025 ++++++++++++++++++
 .../gremlin-javascript/process/traversal.js     |  395 ++++
 .../gremlin-javascript/structure/graph.js       |  146 ++
 .../structure/io/graph-serializer.js            |  406 ++++
 .../javascript/gremlin-javascript/helper.js     |   84 +
 .../gremlin-javascript/test-exports.js          |   78 +
 .../gremlin-javascript/test-graphson.js         |  108 +
 .../gremlin-javascript/test-traversal.js        |   54 +
 pom.xml                                         |    1 +
 16 files changed, 4357 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
new file mode 100644
index 0000000..387e628
--- /dev/null
+++ b/gremlin-javascript/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~  http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tinkerpop</groupId>
+        <artifactId>tinkerpop</artifactId>
+        <version>3.2.3-SNAPSHOT</version>
+    </parent>
+    <artifactId>gremlin-javascript</artifactId>
+    <name>Apache TinkerPop :: Gremlin Javascript</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>tinkergraph-gremlin</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-test</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-server</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${slf4j.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <properties>
+        <!-- provides a way to convert maven.test.skip value to skipTests for use in skipping python tests -->
+        <maven.test.skip>false</maven.test.skip>
+        <skipTests>${maven.test.skip}</skipTests>
+        <gremlin.server.dir>${project.parent.basedir}/gremlin-server</gremlin.server.dir>
+    </properties>
+    <build>
+        <directory>${basedir}/target</directory>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.2.1</version>
+                <executions>
+                    <execution>
+                        <id>generate-javascript</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>java</goal>
+                        </goals>
+                        <configuration>
+                            <mainClass>org.apache.tinkerpop.gremlin.javascript.GenerateGremlinJavascript</mainClass>
+                            <arguments>
+                                <argument>${basedir}/src/main/javascript/gremlin-javascript/process/traversal.js</argument>
+                                <argument>${basedir}/src/main/javascript/gremlin-javascript/process/graph-traversal.js</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>js-tests</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>jjs</executable>
+                            <arguments>
+                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-exports.js</argument>
+                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-graphson.js</argument>
+                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-traversal.js</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.gmavenplus</groupId>
+                <artifactId>gmavenplus-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>3.0.0</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>clean</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
new file mode 100644
index 0000000..81c38dc
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -0,0 +1,247 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+
+import java.lang.reflect.Modifier
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class GraphTraversalSourceGenerator {
+
+    public static void create(final String graphTraversalSourceFile) {
+
+        final StringBuilder moduleOutput = new StringBuilder()
+
+        moduleOutput.append("""/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ """)
+
+//////////////////////////
+// GraphTraversalSource //
+//////////////////////////
+        moduleOutput.append("""
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphTraversalModule() {
+  "use strict";
+
+  var t = loadModule.call(this, './traversal.js');
+  var remote = loadModule.call(this, '../driver/remote-connection.js');
+  var Bytecode = t.Bytecode;
+  var inherits = t.inherits;
+  var parseArgs = t.parseArgs;
+
+  /**
+   *
+   * @param {Graph} graph
+   * @param {TraversalStrategies} traversalStrategies
+   * @param {Bytecode} [bytecode]
+   * @constructor
+   */
+  function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode || new Bytecode();
+  }
+
+  /**
+   * @param remoteConnection
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+  };
+
+  /**
+   * Returns the string representation of the GraphTraversalSource.
+   * @returns {string}
+   */
+  GraphTraversalSource.prototype.toString = function () {
+    return 'graphtraversalsource[' + this._graph.toString() + ']';
+  };
+""")
+        GraphTraversalSource.getMethods(). // SOURCE STEPS
+                findAll { GraphTraversalSource.class.equals(it.returnType) }.
+                findAll {
+                    !it.name.equals("clone") &&
+                            !it.name.equals(TraversalSource.Symbols.withBindings) &&
+                            !it.name.equals(TraversalSource.Symbols.withRemote)
+                }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * ${method} GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.${method} = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+""")
+                }
+        GraphTraversalSource.getMethods(). // SPAWN STEPS
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * ${method} GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.${method} = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+""")
+                }
+////////////////////
+// GraphTraversal //
+////////////////////
+        moduleOutput.append(
+                """
+  /**
+   * Represents a graph traversal.
+   * @constructor
+   */
+  function GraphTraversal(graph, traversalStrategies, bytecode) {
+    t.Traversal.call(this, graph, traversalStrategies, bytecode);
+  }
+
+  inherits(GraphTraversal, t.Traversal);
+""")
+        GraphTraversal.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.${method} = function (args) {
+    this._bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+    return this;
+  };
+""")
+                };
+
+////////////////////////
+// AnonymousTraversal //
+////////////////////////
+        moduleOutput.append("""
+  /**
+   * Contains the static method definitions
+   * @type {Object}
+   */
+  var statics = {};
+""");
+        __.class.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    moduleOutput.append(
+                            """
+  /**
+   * ${method}() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.${method} = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.${method}.apply(g, arguments);
+  };
+""")
+                };
+
+        moduleOutput.append("""
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    GraphTraversal: GraphTraversal,
+    GraphTraversalSource: GraphTraversalSource,
+    statics: statics
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);""")
+
+        // save to file
+        final File file = new File(graphTraversalSourceFile);
+        file.delete()
+        moduleOutput.eachLine { file.append(it + "\n") }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
new file mode 100644
index 0000000..efcb826
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -0,0 +1,398 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.util.CoreImports
+import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+
+import java.lang.reflect.Modifier
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class TraversalSourceGenerator {
+
+    public static void create(final String traversalSourceFile) {
+
+        final StringBuilder moduleOutput = new StringBuilder()
+
+        moduleOutput.append("""/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+""")
+        moduleOutput.append("""
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTraversalModule() {
+  "use strict";
+
+  function Traversal(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode;
+    this.traversers = null;
+    this.sideEffects = null;
+  }
+
+  /** @returns {Bytecode} */
+  Traversal.prototype.getBytecode = function () {
+    return this._bytecode;
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.list = function (callback) {
+    var self = this;
+    this._traversalStrategies.applyStrategies(this, function (err) {
+      if (err) {
+        return callback(err);
+      }
+      callback(err, self.traversers);
+    });
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.one = function (callback) {
+    this.list(function (err, result) {
+      callback(err, result ? result[0] : null);
+    });
+  };
+
+  /**
+   * Returns the Bytecode JSON representation of the traversal
+   * @returns {String}
+   */
+  Traversal.prototype.toString = function () {
+    return this._bytecode.toString();
+  };
+  """);
+
+        moduleOutput.append("""
+  /**
+   * Represents an operation.
+   * @constructor
+   */
+  function P(operator, value, other) {
+    this.operator = operator;
+    this.value = value;
+    this.other = other;
+  }
+
+  /**
+   * Returns the string representation of the instance.
+   * @returns {string}
+   */
+  P.prototype.toString = function () {
+    if (this.other === undefined) {
+      return this.operator + '(' + this.value + ')';
+    }
+    return this.operator + '(' + this.value + ', ' + this.other + ')';
+  };
+
+  function createP(operator, args) {
+    args.unshift(null, operator);
+    return new (Function.prototype.bind.apply(P, args));
+  }
+""")
+        P.class.getMethods().
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { P.class.isAssignableFrom(it.returnType) }.
+                collect { SymbolHelper.toJs(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                each { method ->
+                    moduleOutput.append(
+                            """
+  /** @param {...Object} args */
+  P.${method} = function (args) {
+    return createP('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+  };
+""")
+                };
+        moduleOutput.append("""
+  P.prototype.and = function (arg) {
+    return new P('and', this, arg);
+  };
+
+  P.prototype.or = function (arg) {
+    return new P('or', this, arg);
+  };
+""")
+
+        moduleOutput.append("""
+  function Traverser(object, bulk) {
+    this.object = object;
+    this.bulk = bulk == undefined ? 1 : bulk;
+  }
+
+  function TraversalSideEffects() {
+
+  }
+
+  /**
+   * Creates a new instance of TraversalStrategies.
+   * @param {TraversalStrategies} [traversalStrategies]
+   * @constructor
+   */
+  function TraversalStrategies(traversalStrategies) {
+    /** @type {Array<TraversalStrategy>} */
+    this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
+  }
+
+  /** @param {TraversalStrategy} strategy */
+  TraversalStrategies.prototype.addStrategy = function (strategy) {
+    this.strategies.push(strategy);
+  };
+
+  /** @param {Traversal} traversal */
+  TraversalStrategies.prototype.applyStrategies = function (traversal) {
+    this.strategies.forEach(function eachStrategy(s) {
+      s.apply(traversal);
+    });
+  };
+
+  /**
+   * @abstract
+   * @constructor
+   */
+  function TraversalStrategy() {
+
+  }
+
+  /**
+   * @abstract
+   * @param {Traversal} traversal
+   */
+  TraversalStrategy.prototype.apply = function (traversal) {
+
+  };
+
+  /**
+   * Creates a new instance of Bytecode
+   * @param {Bytecode} [toClone]
+   * @constructor
+   */
+  function Bytecode(toClone) {
+    this._bindings = {};
+    if (!toClone) {
+      this.sourceInstructions = [];
+      this.stepInstructions = [];
+    }
+    else {
+      this.sourceInstructions = toClone.sourceInstructions.slice(0);
+      this.stepInstructions = toClone.sourceInstructions.slice(0);
+    }
+  }
+
+  /**
+   * Adds a new source instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addSource = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    this.sourceInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  /**
+   * Adds a new step instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addStep = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    this.stepInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  Bytecode.prototype._generateInstruction = function (name, values) {
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    return instruction;
+  };
+
+  /**
+   * Returns the JSON representation of the source and step instructions
+   * @returns {String}
+   */
+  Bytecode.prototype.toString = function () {
+    return (
+      (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+      (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
+    );
+  };
+
+  Bytecode.prototype._convertToArgument = function (value) {
+    return value;
+  };
+
+  function toEnum(typeName, keys) {
+    var result = {};
+    keys.split(' ').forEach(function (k) {
+      if (k === k.toUpperCase()) {
+        k = k.toLowerCase();
+      }
+      result[k] = new EnumValue(typeName, k);
+    });
+    return result;
+  }
+
+  function EnumValue(typeName, elementName) {
+    this.typeName = typeName;
+    this.elementName = elementName;
+  }
+
+  /**
+   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
+   */
+  var enums = {};\n""")
+
+        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
+                .findAll { Enum.class.isAssignableFrom(it) }
+                .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
+                .collect()) {
+            moduleOutput.append("  enums.${SymbolHelper.decapitalize(enumClass.getSimpleName())} = " +
+                    "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
+            enumClass.getEnumConstants()
+                    .sort { a, b -> a.name() <=> b.name() }
+                    .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
+            moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("');\n")
+        }
+
+        moduleOutput.append("""
+  // Utility functions
+  /** @returns {Array} */
+  function parseArgs() {
+    return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+  }
+
+  /**
+   * @param {Array} arr
+   * @param {Function} fn
+   * @param {Function} [callback]
+   */
+  function eachSeries(arr, fn, callback) {
+    if (!Array.isArray(arr)) {
+      throw new TypeError('First parameter is not an Array');
+    }
+    callback = callback || noop;
+    var length = arr.length;
+    if (length === 0) {
+      return callback();
+    }
+    var sync;
+    var index = 1;
+    fn(arr[0], next);
+    if (sync === undefined) {
+      sync = false;
+    }
+
+    function next(err) {
+      if (err) {
+        return callback(err);
+      }
+      if (index >= length) {
+        return callback();
+      }
+      if (sync === undefined) {
+        sync = true;
+      }
+      if (sync) {
+        return process.nextTick(function () {
+          fn(arr[index++], next);
+        });
+      }
+      fn(arr[index++], next);
+    }
+  }
+
+  function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor;
+    ctor.prototype = Object.create(superCtor.prototype, {
+      constructor: {
+        value: ctor,
+        enumerable: false,
+        writable: true,
+        configurable: true
+      }
+    });
+  }
+
+  var toExport = {
+    Bytecode: Bytecode,
+    EnumValue: EnumValue,
+    inherits: inherits,
+    P: P,
+    parseArgs: parseArgs,
+    Traversal: Traversal,
+    TraversalSideEffects: TraversalSideEffects,
+    TraversalStrategies: TraversalStrategies,
+    TraversalStrategy: TraversalStrategy,
+    Traverser: Traverser
+  };
+  Object.keys(enums).forEach(function (k) {
+    toExport[k] = enums[k];
+  });
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);""")
+
+        // save to a file
+        final File file = new File(traversalSourceFile);
+        file.delete()
+        moduleOutput.eachLine { file.append(it + "\n") }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
new file mode 100644
index 0000000..1656db4
--- /dev/null
+++ b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript;
+
+public class GenerateGremlinJavascript {
+
+    private GenerateGremlinJavascript() {
+        // just need the main method
+    }
+
+    public static void main(String[] args) {
+        TraversalSourceGenerator.create(args[0]);
+        GraphTraversalSourceGenerator.create(args[1]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
new file mode 100644
index 0000000..535de44
--- /dev/null
+++ b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript.jsr223;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Jorge Bay Gondra
+ */
+public final class SymbolHelper {
+
+    private final static Map<String, String> TO_JS_MAP = new HashMap<>();
+    private final static Map<String, String> FROM_JS_MAP = new HashMap<>();
+
+    static {
+        TO_JS_MAP.put("in", "in_");
+        TO_JS_MAP.put("from", "from_");
+        TO_JS_MAP.forEach((k, v) -> FROM_JS_MAP.put(v, k));
+    }
+
+    private SymbolHelper() {
+        // static methods only, do not instantiate
+    }
+
+    public static String toJs(final String symbol) {
+        return TO_JS_MAP.getOrDefault(symbol, symbol);
+    }
+
+    public static String toJava(final String symbol) {
+        return FROM_JS_MAP.getOrDefault(symbol, symbol);
+    }
+
+    public static String decapitalize(String string) {
+        if (string == null || string.length() == 0) {
+            return string;
+        }
+        char c[] = string.toCharArray();
+        c[0] = Character.toLowerCase(c[0]);
+        return new String(c);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
new file mode 100644
index 0000000..99b177f
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineRemoteConnectionModule() {
+  "use strict";
+
+  var t = loadModule.call(this, '../process/traversal.js');
+  var inherits = t.inherits;
+
+  function RemoteConnection(url, traversalSource) {
+    this.url = url;
+    this.traversalSource = traversalSource;
+  }
+
+  /**
+   * @abstract
+   * @param {Bytecode} bytecode
+   * @param {Function} callback
+   */
+  RemoteConnection.prototype.submit = function (bytecode, callback) {
+    throw new Error('submit() needs to be implemented');
+  };
+
+  /**
+   * @extends {Traversal}
+   * @constructor
+   */
+  function RemoteTraversal(traversers, sideEffects) {
+    t.Traversal.call(this, null, null, null);
+    this.traversers = traversers;
+    this.sideEffects = sideEffects;
+  }
+
+  inherits(RemoteTraversal, t.Traversal);
+
+  /**
+   *
+   * @param {RemoteConnection} connection
+   * @extends {TraversalStrategy}
+   * @constructor
+   */
+  function RemoteStrategy(connection) {
+    t.TraversalStrategy.call(this);
+    this.connection = connection;
+  }
+
+  inherits(RemoteStrategy, t.TraversalStrategy);
+
+  /** @override */
+  RemoteStrategy.prototype.apply = function (traversal, callback) {
+    if (traversal.traversers) {
+      return;
+    }
+    this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
+      if (err) {
+        return callback(err);
+      }
+      traversal.sideEffects = remoteTraversal.sideEffects;
+      traversal.traversers = remoteTraversal.traversers;
+      callback();
+    });
+  };
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    RemoteConnection: RemoteConnection,
+    RemoteStrategy: RemoteStrategy,
+    RemoteTraversal: RemoteTraversal
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
new file mode 100644
index 0000000..cda8200
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -0,0 +1,85 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function exportModule() {
+  "use strict";
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var t = loadModule.call(this, './process/traversal.js');
+  var gt = loadModule.call(this, './process/graph-traversal.js');
+  var graph = loadModule.call(this, './structure/graph.js');
+  var gs = loadModule.call(this, './structure/io/graph-serializer.js');
+  var rc = loadModule.call(this, './driver/remote-connection.js');
+  var toExport = {
+    driver: {
+      RemoteConnection: rc.RemoteConnection,
+      RemoteStrategy: rc.RemoteStrategy,
+      RemoteTraversal: rc.RemoteTraversal
+    },
+    process: {
+      Bytecode: t.Bytecode,
+      EnumValue: t.EnumValue,
+      inherits: t.inherits,
+      P: t.P,
+      parseArgs: t.parseArgs,
+      Traversal: t.Traversal,
+      TraversalSideEffects: t.TraversalSideEffects,
+      TraversalStrategies: t.TraversalStrategies,
+      TraversalStrategy: t.TraversalStrategy,
+      Traverser: t.Traverser,
+      GraphTraversal: gt.GraphTraversal,
+      GraphTraversalSource: gt.GraphTraversalSource,
+      statics: gt.statics
+    },
+    structure: {
+      io: {
+        GraphSONReader: gs.GraphSONReader,
+        GraphSONWriter: gs.GraphSONWriter
+      },
+      Edge: graph.Edge,
+      Graph: graph.Graph,
+      Path: graph.Path,
+      Property: graph.Property,
+      Vertex: graph.Vertex,
+      VertexProperty: graph.VertexProperty
+    }
+  };
+
+
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  return toExport;
+}).call(this);
\ No newline at end of file


[45/47] tinkerpop git commit: Make Travis use a newer version of Maven.

Posted by jo...@apache.org.
Make Travis use a newer version of Maven.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4899a6b4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4899a6b4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4899a6b4

Branch: refs/heads/TINKERPOP-1489
Commit: 4899a6b4b1b5bd00ba845119ebd7775bfeb4f264
Parents: a59dd1c
Author: Lukas Krejci <lk...@redhat.com>
Authored: Tue Nov 15 11:21:34 2016 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:23 2018 +0100

----------------------------------------------------------------------
 .travis.install-maven.sh | 19 +++++++++++++++++++
 .travis.yml              | 13 ++++++++++++-
 pom.xml                  |  1 +
 3 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4899a6b4/.travis.install-maven.sh
----------------------------------------------------------------------
diff --git a/.travis.install-maven.sh b/.travis.install-maven.sh
new file mode 100644
index 0000000..66affe6
--- /dev/null
+++ b/.travis.install-maven.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -xe
+
+MVN_VERSION="$1"
+MVN_INSTALL_DIR="$2"
+
+if [ ! -f "${MVN_INSTALL_DIR}/lib/maven-artifact-${MVN_VERSION}.jar" ]; then
+  rm -Rf "${MVN_INSTALL_DIR}"
+  mkdir -p "${MVN_INSTALL_DIR}"
+
+  APACHE_MIRROR="$(curl -sL https://www.apache.org/dyn/closer.cgi?asjson=1 | python -c 'import sys, json; print json.load(sys.stdin)["preferred"]')"
+  curl -o "${HOME}/apache-maven-$MVN_VERSION-bin.tar.gz" "$APACHE_MIRROR/maven/maven-3/$MVN_VERSION/binaries/apache-maven-$MVN_VERSION-bin.tar.gz"
+  cd "${MVN_INSTALL_DIR}"
+  tar -xzf "${HOME}/apache-maven-$MVN_VERSION-bin.tar.gz" --strip 1
+  chmod +x "${MVN_INSTALL_DIR}/bin/mvn"
+else
+  echo "Using cached Maven ${MVN_VERSION}"
+fi
+${MVN_INSTALL_DIR}/bin/mvn -version

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4899a6b4/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 2c86de3..442de5e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,17 @@ jdk:
   - oraclejdk8
 sudo: required
 dist: trusty
+cache:
+  directories:
+    - $HOME/mvn-home
+
+install:
+  # install maven 3.3.9 if it is not in cache already
+  - bash .travis.install-maven.sh "3.3.9" "${HOME}/mvn-home"
+  - export M2_HOME=${HOME}/mvn-home
+  - export PATH=${HOME}/mvn-home/bin:${PATH}
+  # visual check that we have the correct maven version installed
+  - mvn -version
 
 before_install:
   - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
@@ -16,4 +27,4 @@ jobs:
   include:
     - script: "mvn clean install -Dci"
     - script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
-    - script: "mvn clean install -pl :gremlin-javascript -DskipIntegrationTests=false"
\ No newline at end of file
+    - script: "mvn clean install -pl :gremlin-javascript -DskipIntegrationTests=false"

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4899a6b4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 157b9bf..259f16a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -287,6 +287,7 @@ limitations under the License.
                     <excludeSubProjects>false</excludeSubProjects>
                     <excludes>
                         <exclude>.travis.yml</exclude>
+                        <exclude>.travis.*.sh</exclude>
                         <exclude>.dockerignore</exclude>
                         <exclude>**/.classpath</exclude>
                         <exclude>**/.project</exclude>


[31/47] tinkerpop git commit: Path assertions and feature step fixes

Posted by jo...@apache.org.
Path assertions and feature step fixes


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4f432c6f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4f432c6f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4f432c6f

Branch: refs/heads/TINKERPOP-1489
Commit: 4f432c6f59b09f1e8f532afa9ded2b48646b1482
Parents: 0667716
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 12:51:59 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:21 2018 +0100

----------------------------------------------------------------------
 .../test/cucumber/feature-steps.js              | 48 ++++++++++++++++----
 1 file changed, 40 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4f432c6f/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 8ec2bdc..99e2ec8 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -80,9 +80,8 @@ defineSupportCode(function(methods) {
     if (this.graphName === 'empty') {
       p = this.loadEmptyGraphData();
     }
-    const self = this;
     return p.then(() => {
-      self.parameters[paramName] = parseValue.call(self, stringValue);
+      this.parameters[paramName] = parseValue.call(this, stringValue);
     }).catch(err => {
       if (err instanceof IgnoreError) {
         return 'skipped';
@@ -96,7 +95,13 @@ defineSupportCode(function(methods) {
   });
 
   methods.When('iterated next', function () {
-    return this.traversal.next().then(it => this.result = it.value);
+    return this.traversal.next().then(it => {
+      this.result = it.value;
+      if (this.result instanceof Path) {
+        // Compare using the objects array
+        this.result = this.result.objects;
+      }
+    });
   });
 
   methods.Then(/^the result should be (\w+)$/, function assertResult(characterizedAs, resultTable) {
@@ -110,13 +115,14 @@ defineSupportCode(function(methods) {
     const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
     switch (characterizedAs) {
       case 'ordered':
-        expect(this.result).to.have.deep.ordered.members(expectedResult);
+        expect(toCompare(this.result)).to.have.deep.ordered.members(expectedResult);
         break;
       case 'unordered':
-        expect(this.result).to.have.deep.members(expectedResult);
+        expect(toCompare(this.result)).to.have.deep.members(expectedResult);
         break;
       case 'of':
-        expect(this.result).to.include.deep.members(expectedResult);
+        // result is a subset of the expected
+        expect(expectedResult).to.include.deep.members(toCompare(this.result));
         break;
     }
   });
@@ -156,7 +162,11 @@ function getSandbox(g, parameters) {
     __: __,
     Cardinality: traversalModule.cardinality,
     Column: traversalModule.column,
-    Direction: traversalModule.direction,
+    Direction: {
+      BOTH: traversalModule.direction.both,
+      IN: traversalModule.direction.in,
+      OUT: traversalModule.direction.out
+    },
     Order: traversalModule.order,
     P: traversalModule.P,
     Pick: traversalModule.pick,
@@ -172,6 +182,8 @@ function getSandbox(g, parameters) {
 function translate(traversalText) {
   // Remove escaped chars
   traversalText = traversalText.replace(/\\"/g, '"');
+  // Remove long suffix
+  traversalText = traversalText.replace(/\b(\d+)l\b/gi, '$1');
   // Change according to naming convention
   traversalText = traversalText.replace(/\.in\(/g, '.in_(');
   traversalText = traversalText.replace(/\.from\(/g, '.from_(');
@@ -231,7 +243,7 @@ function toEdgeIdString(name) {
 
 function toPath(value) {
   const parts = value.split(',');
-  return new Path(parts.map(_ => new Array(0)), parts.map(x => parseValue.call(this, x)));
+  return new Path(new Array(0), parts.map(x => parseValue.call(this, x)));
 }
 
 function toArray(stringList) {
@@ -273,6 +285,26 @@ function toLambda() {
   throw new IgnoreError(IgnoreError.reason.lambdaNotSupported);
 }
 
+/**
+ * Adapts the object to be compared, removing labels property of the Path.
+ */
+function toCompare(obj) {
+  if (!obj) {
+    return obj;
+  }
+  if (typeof obj !== 'object') {
+    return obj;
+  }
+  if (Array.isArray(obj)) {
+    return obj.map(toCompare);
+  }
+  if (obj instanceof Path) {
+    // labels are ignored
+    obj.labels = new Array(0);
+  }
+  return obj;
+}
+
 function IgnoreError(reason) {
   Error.call(this, reason);
   Error.captureStackTrace(this, IgnoreError);


[43/47] tinkerpop git commit: Support multiple mime types

Posted by jo...@apache.org.
Support multiple mime types


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/615b530d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/615b530d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/615b530d

Branch: refs/heads/TINKERPOP-1489
Commit: 615b530dc666dd6116712d36bb65712cf2c0593e
Parents: 54dee62
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 29 12:02:50 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:22 2018 +0100

----------------------------------------------------------------------
 .../lib/driver/driver-remote-connection.js           | 15 +++++++++------
 .../lib/driver/remote-connection.js                  |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/615b530d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 31f27cd..51661c3 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -29,8 +29,7 @@ var RemoteConnection = require('./remote-connection').RemoteConnection;
 var utils = require('../utils');
 var serializer = require('../structure/io/graph-serializer');
 var inherits = utils.inherits;
-var mimeType = 'application/vnd.gremlin-v2.0+json';
-var header = String.fromCharCode(mimeType.length) + mimeType;
+var defaultMimeType = 'application/vnd.gremlin-v2.0+json';
 var responseStatusCode = {
   success: 200,
   noContent: 204,
@@ -41,16 +40,18 @@ var responseStatusCode = {
  * Creates a new instance of DriverRemoteConnection.
  * @param {String} url The resource uri.
  * @param {Object} [options] The connection options.
- * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
  * @param {Array} [options.ca] Trusted certificates.
  * @param {String|Array|Buffer} [options.cert] The certificate key.
+ * @param {String} [options.mimeType] The mime type to use.
  * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
- * @param {GraphSONReader} [options.reader] The GraphSON2 reader to use.
+ * @param {GraphSONReader} [options.reader] The reader to use.
  * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
- * @param {GraphSONWriter} [options.writer] The GraphSON2 writer to use.
+ * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
+ * @param {GraphSONWriter} [options.writer] The writer to use.
  * @constructor
  */
 function DriverRemoteConnection(url, options) {
+  RemoteConnection.call(this, url);
   options = options || {};
   this._ws = new WebSocket(url, {
     ca: options.ca,
@@ -75,6 +76,8 @@ function DriverRemoteConnection(url, options) {
   this._openPromise = null;
   this._openCallback = null;
   this._closePromise = null;
+  var mimeType = options.mimeType || defaultMimeType;
+  this._header = String.fromCharCode(mimeType.length) + mimeType;
   this.isOpen = false;
   this.traversalSource = options.traversalSource || 'g';
 }
@@ -114,7 +117,7 @@ DriverRemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
         callback: callback,
         result: null
       };
-      var message = bufferFromString(header + JSON.stringify(self._getRequest(requestId, bytecode)));
+      var message = bufferFromString(self._header + JSON.stringify(self._getRequest(requestId, bytecode)));
       self._ws.send(message);
     });
   });

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/615b530d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 8176c37..235375a 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -27,7 +27,7 @@ var TraversalStrategy = require('../process/traversal-strategy').TraversalStrate
 var utils = require('../utils');
 var inherits = utils.inherits;
 
-function RemoteConnection(url, traversalSource) {
+function RemoteConnection(url) {
   this.url = url;
 }
 


[32/47] tinkerpop git commit: Traversal iterate() method

Posted by jo...@apache.org.
Traversal iterate() method


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f6721d0a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f6721d0a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f6721d0a

Branch: refs/heads/TINKERPOP-1489
Commit: f6721d0accdfd09d5660637b1144044238af34de
Parents: 746356e
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Nov 27 12:22:08 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:21 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/TraversalSource.template | 12 +++++++++++
 .../gremlin-javascript/lib/process/traversal.js | 12 +++++++++++
 .../javascript/gremlin-javascript/package.json  |  2 +-
 .../test/unit/traversal-test.js                 | 21 ++++++++++++++++++--
 4 files changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f6721d0a/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index f75765f..0d45e90 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -58,6 +58,18 @@ Traversal.prototype.toList = function () {
 };
 
 /**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+Traversal.prototype.iterate = function () {
+  return this._applyStrategies().then(() => {
+    let it;
+    while ((it = this._getNext()) && !it.done) {
+    }
+  });
+};
+
+/**
  * Async iterator method implementation.
  * Returns a promise containing an iterator item.
  * @returns {Promise.<{value, done}>}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f6721d0a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index ebf8755..d887fe0 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -58,6 +58,18 @@ Traversal.prototype.toList = function () {
 };
 
 /**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+Traversal.prototype.iterate = function () {
+  return this._applyStrategies().then(() => {
+    let it;
+    while ((it = this._getNext()) && !it.done) {
+    }
+  });
+};
+
+/**
  * Async iterator method implementation.
  * Returns a promise containing an iterator item.
  * @returns {Promise.<{value, done}>}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f6721d0a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index aae9eb9..7c4a3d6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -30,7 +30,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
-    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f6721d0a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index 635c7e8..2be504b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -32,7 +32,6 @@ const TraversalStrategies = require('../../lib/process/traversal-strategy').Trav
 describe('Traversal', function () {
 
   describe('#getByteCode()', function () {
-
     it('should add steps for with a string parameter', function () {
       var g = new graph.Graph().traversal();
       var bytecode = g.V().out('created').getBytecode();
@@ -61,7 +60,6 @@ describe('Traversal', function () {
   });
 
   describe('#next()', function () {
-
     it('should apply the strategies and return a Promise with the iterator item', function () {
       var strategyMock = {
         apply: function (traversal) {
@@ -175,4 +173,23 @@ describe('Traversal', function () {
         });
     });
   });
+
+  describe('#iterate()', function () {
+    it('should apply the strategies and return a Promise', function () {
+      let applied = false;
+      const strategyMock = {
+        apply: function (traversal) {
+          applied = true;
+          traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
+          return utils.resolvedPromise();
+        }
+      };
+      const strategies = new TraversalStrategies();
+      strategies.addStrategy(strategyMock);
+      const traversal = new t.Traversal(null, strategies, null);
+      return traversal.iterate().then(() => {
+        assert.strictEqual(applied, true);
+      });
+    });
+  });
 });
\ No newline at end of file


[38/47] tinkerpop git commit: Move generation script to groovy file

Posted by jo...@apache.org.
Move generation script to groovy file


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4d169db1
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4d169db1
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4d169db1

Branch: refs/heads/TINKERPOP-1489
Commit: 4d169db1147b3bb86380cd7c6d6643262ecc2a9d
Parents: adac3a6
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Jan 8 11:27:03 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:22 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/generate.groovy          | 107 +++++++++++++++++++
 gremlin-javascript/pom.xml                      |  99 +++--------------
 .../javascript/gremlin-javascript/package.json  |   2 +-
 3 files changed, 120 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d169db1/gremlin-javascript/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/generate.groovy b/gremlin-javascript/glv/generate.groovy
new file mode 100644
index 0000000..8fd22e3
--- /dev/null
+++ b/gremlin-javascript/glv/generate.groovy
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import groovy.text.GStringTemplateEngine
+import org.apache.tinkerpop.gremlin.jsr223.CoreImports
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import java.lang.reflect.Modifier
+
+def toJsMap = ["in": "in_",
+               "from": "from_"]
+
+def toJs = { symbol -> toJsMap.getOrDefault(symbol, symbol) }
+
+def decapitalize = {
+    String string = it;
+    if (string == null || string.length() == 0) {
+        return string;
+    }
+    def c = string.toCharArray();
+    c[0] = Character.toLowerCase(c[0]);
+    return new String(c);
+}
+
+def determineVersion = {
+    def env = System.getenv()
+    def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("JS_RELEASE_VERSION") : project.version
+    return mavenVersion.replace("-SNAPSHOT", "-alpha1")
+}
+
+def binding = ["enums": CoreImports.getClassImports()
+        .findAll { Enum.class.isAssignableFrom(it) }
+        .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() },
+               "pmethods": P.class.getMethods().
+                       findAll { Modifier.isStatic(it.getModifiers()) }.
+                       findAll { P.class.isAssignableFrom(it.returnType) }.
+                       collect { it.name }.
+                       unique().
+                       sort { a, b -> a <=> b },
+               "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS
+                       findAll { GraphTraversalSource.class.equals(it.returnType) }.
+                       findAll {
+                           !it.name.equals("clone") &&
+                                   // Use hardcoded name to be for forward-compatibility
+                                   !it.name.equals("withBindings") &&
+                                   !it.name.equals(TraversalSource.Symbols.withRemote) &&
+                                   !it.name.equals(TraversalSource.Symbols.withComputer)
+                       }.
+                       collect { it.name }.
+                       unique().
+                       sort { a, b -> a <=> b },
+               "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS
+                       findAll { GraphTraversal.class.equals(it.returnType) }.
+                       collect { it.name }.
+                       unique().
+                       sort { a, b -> a <=> b },
+               "graphStepMethods": GraphTraversal.getMethods().
+                       findAll { GraphTraversal.class.equals(it.returnType) }.
+                       findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
+                       collect { it.name }.
+                       unique().
+                       sort { a, b -> a <=> b },
+               "anonStepMethods": __.class.getMethods().
+                       findAll { GraphTraversal.class.equals(it.returnType) }.
+                       findAll { Modifier.isStatic(it.getModifiers()) }.
+                       findAll { !it.name.equals("__") && !it.name.equals("start") }.
+                       collect { it.name }.
+                       unique().
+                       sort { a, b -> a <=> b },
+               "toJs": toJs,
+               "version": determineVersion(),
+               "decapitalize": decapitalize]
+
+def engine = new GStringTemplateEngine()
+def graphTraversalTemplate = engine.createTemplate(new File("${project.basedir}/glv/GraphTraversalSource.template"))
+        .make(binding)
+def graphTraversalFile =
+        new File("${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js")
+graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate }
+
+def traversalTemplate = engine.createTemplate(new File("${project.basedir}/glv/TraversalSource.template")).make(binding)
+def traversalFile = new File("${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/traversal.js")
+traversalFile.newWriter().withWriter{ it << traversalTemplate }
+
+def packageJsonTemplate = engine.createTemplate(new File("${project.basedir}/glv/PackageJson.template")).make(binding)
+def packageJsonFile = new File("${project.basedir}/src/main/javascript/gremlin-javascript/package.json")
+packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d169db1/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index aa219ab..0825ba6 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
     <parent>
         <groupId>org.apache.tinkerpop</groupId>
         <artifactId>tinkerpop</artifactId>
-        <version>3.2.7-SNAPSHOT</version>
+        <version>3.2.8-SNAPSHOT</version>
     </parent>
     <artifactId>gremlin-javascript</artifactId>
     <name>Apache TinkerPop :: Gremlin Javascript</name>
@@ -106,93 +106,18 @@ limitations under the License.
                             <goal>execute</goal>
                         </goals>
                         <configuration>
+                            <properties>
+                                <property>
+                                    <name>projectBaseDir</name>
+                                    <value>${project.basedir}</value>
+                                </property>
+                                <property>
+                                    <name>projectVersion</name>
+                                    <value>${project.version}</value>
+                                </property>
+                            </properties>
                             <scripts>
-                                <script><![CDATA[
-import org.apache.tinkerpop.gremlin.jsr223.CoreImports
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.P
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
-import java.lang.reflect.Modifier
-
-def toJsMap = ["in": "in_",
-               "from": "from_"]
-
-def toJs = { symbol -> toJsMap.getOrDefault(symbol, symbol) }
-
-def decapitalize = {
-    String string = it;
-    if (string == null || string.length() == 0) {
-        return string;
-    }
-    def c = string.toCharArray();
-    c[0] = Character.toLowerCase(c[0]);
-    return new String(c);
-}
-
-def determineVersion = {
-    def env = System.getenv()
-    def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("JS_RELEASE_VERSION") : '${project.version}'
-    return mavenVersion.replace("-SNAPSHOT", "-alpha1")
-}
-
-def binding = ["enums": CoreImports.getClassImports()
-                                 .findAll { Enum.class.isAssignableFrom(it) }
-                                 .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() },
-               "pmethods": P.class.getMethods().
-                                 findAll { Modifier.isStatic(it.getModifiers()) }.
-                                 findAll { P.class.isAssignableFrom(it.returnType) }.
-                                 collect { it.name }.
-                                 unique().
-                                 sort { a, b -> a <=> b },
-               "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS
-                                        findAll { GraphTraversalSource.class.equals(it.returnType) }.
-                                        findAll {
-                                            !it.name.equals("clone") &&
-                                                    // Use hardcoded name to be for forward-compatibility
-                                                    !it.name.equals("withBindings") &&
-                                                    !it.name.equals(TraversalSource.Symbols.withRemote) &&
-                                                    !it.name.equals(TraversalSource.Symbols.withComputer)
-                                        }.
-                                        collect { it.name }.
-                                        unique().
-                                        sort { a, b -> a <=> b },
-               "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS
-                                        findAll { GraphTraversal.class.equals(it.returnType) }.
-                                        collect { it.name }.
-                                        unique().
-                                        sort { a, b -> a <=> b },
-               "graphStepMethods": GraphTraversal.getMethods().
-                                        findAll { GraphTraversal.class.equals(it.returnType) }.
-                                        findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
-                                        collect { it.name }.
-                                        unique().
-                                        sort { a, b -> a <=> b },
-               "anonStepMethods": __.class.getMethods().
-                                        findAll { GraphTraversal.class.equals(it.returnType) }.
-                                        findAll { Modifier.isStatic(it.getModifiers()) }.
-                                        findAll { !it.name.equals("__") && !it.name.equals("start") }.
-                                        collect { it.name }.
-                                        unique().
-                                        sort { a, b -> a <=> b },
-               "toJs": toJs,
-               "version": determineVersion(),
-               "decapitalize": decapitalize]
-
-def engine = new groovy.text.GStringTemplateEngine()
-def graphTraversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/GraphTraversalSource.template')).make(binding)
-def graphTraversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js')
-graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate }
-
-def traversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/TraversalSource.template')).make(binding)
-def traversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/traversal.js')
-traversalFile.newWriter().withWriter{ it << traversalTemplate }
-
-def packageJsonTemplate = engine.createTemplate(new File('${project.basedir}/glv/PackageJson.template')).make(binding)
-def packageJsonFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/package.json')
-packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
-]]>                                     </script>
+                                <script>${project.basedir}/glv/generate.groovy</script>
                             </scripts>
                         </configuration>
                     </execution>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d169db1/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index aae9eb9..604354c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -1,6 +1,6 @@
 {
   "name": "gremlin-javascript",
-  "version": "3.2.7-alpha1",
+  "version": "3.2.8-alpha1",
   "description": "JavaScript Gremlin Language Variant",
   "author": "Apache TinkerPop team",
   "keywords": [


[34/47] tinkerpop git commit: Vertex and Edge serialization

Posted by jo...@apache.org.
Vertex and Edge serialization


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/06677162
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/06677162
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/06677162

Branch: refs/heads/TINKERPOP-1489
Commit: 066771623a85716f63f4c711cbbc1edad2720966
Parents: 7e3d4be
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 12:50:37 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:21 2018 +0100

----------------------------------------------------------------------
 .../lib/structure/io/graph-serializer.js        | 42 ++++++++++++++++++--
 1 file changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/06677162/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index 46d251e..ff3d72d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -65,7 +65,9 @@ var serializers = [
   TraverserSerializer,
   PSerializer,
   LambdaSerializer,
-  EnumSerializer
+  EnumSerializer,
+  VertexSerializer,
+  EdgeSerializer
 ];
 
 /**
@@ -237,7 +239,7 @@ BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
   }
   var result = new Array(instructions.length);
   result[0] = instructions[0];
-  for (var i = 1; i < instructions.length; i++) {
+  for (var i = 0; i < instructions.length; i++) {
     result[i] = this.writer.adaptObject(instructions[i]);
   }
   return result;
@@ -258,7 +260,7 @@ PSerializer.prototype.serialize = function (item) {
   var resultValue = result[valueKey] = {
     'predicate': item.operator
   };
-  if (item.other == undefined) {
+  if (item.other === undefined || item.other === null) {
     resultValue['value'] = this.writer.adaptObject(item.value);
   }
   else {
@@ -340,6 +342,21 @@ VertexSerializer.prototype.deserialize = function (obj) {
   return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
 };
 
+/** @param {Vertex} item */
+VertexSerializer.prototype.serialize = function (item) {
+  var result = {};
+  result[typeKey] = 'g:Vertex';
+  result[valueKey] = {
+    'id': this.writer.adaptObject(item.id),
+    'label': item.label
+  };
+  return result;
+};
+
+VertexSerializer.prototype.canBeUsedFor = function (value) {
+  return (value instanceof g.Vertex);
+};
+
 function VertexPropertySerializer() {
 
 }
@@ -380,6 +397,25 @@ EdgeSerializer.prototype.deserialize = function (obj) {
   );
 };
 
+/** @param {Edge} item */
+EdgeSerializer.prototype.serialize = function (item) {
+  var result = {};
+  result[typeKey] = 'g:Edge';
+  result[valueKey] = {
+    'id': this.writer.adaptObject(item.id),
+    'label': item.label,
+    'outV': this.writer.adaptObject(item.outV.id),
+    'outVLabel': item.outV.label,
+    'inV': this.writer.adaptObject(item.inV.id),
+    'inVLabel': item.inV.label
+  };
+  return result;
+};
+
+EdgeSerializer.prototype.canBeUsedFor = function (value) {
+  return (value instanceof g.Edge);
+};
+
 function PathSerializer() {
 
 }


[29/47] tinkerpop git commit: Use new server start groovy scripts

Posted by jo...@apache.org.
Use new server start groovy scripts

- Use new server start/stop groovy scripts
- Support different traversal sources at connection level
- Avoid destructuring syntax (not support on Node.js v4)


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/867c1b94
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/867c1b94
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/867c1b94

Branch: refs/heads/TINKERPOP-1489
Commit: 867c1b947f498728dbd99aea0fafdbb61716cfe7
Parents: a0275d0
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 23 10:20:19 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:20 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/PackageJson.template     |  4 +-
 gremlin-javascript/pom.xml                      | 67 +++++++++++---------
 .../lib/driver/driver-remote-connection.js      |  6 +-
 .../javascript/gremlin-javascript/package.json  |  4 +-
 .../test/cucumber/feature-steps.js              | 29 +++++----
 .../gremlin-javascript/test/cucumber/world.js   | 12 +++-
 .../gremlin-javascript/test/helper.js           | 29 +++++++++
 .../test/integration/remote-connection-tests.js | 18 ++----
 .../test/integration/traversal-test.js          | 16 ++---
 9 files changed, 111 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index 3ff17af..52d2c1d 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -47,8 +47,8 @@
     "url": "https://issues.apache.org/jira/browse/TINKERPOP"
   },
   "scripts": {
-    "test": "./node_modules/.bin/mocha test --recursive -t 5000",
-    "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
+    "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 871fd7a..830052b 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -202,26 +202,30 @@ packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
                             <goal>execute</goal>
                         </goals>
                         <configuration>
+                            <properties>
+                                <property>
+                                    <name>skipTests</name>
+                                    <value>${skipTests}</value>
+                                </property>
+                                <property>
+                                    <name>python</name>
+                                    <value>false</value>
+                                </property>
+                                <property>
+                                    <name>gremlinServerDir</name>
+                                    <value>${gremlin.server.dir}</value>
+                                </property>
+                                <property>
+                                    <name>settingsFile</name>
+                                    <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml</value>
+                                </property>
+                                <property>
+                                    <name>executionName</name>
+                                    <value>${project.name}</value>
+                                </property>
+                            </properties>
                             <scripts>
-                                <script>
-                                    <![CDATA[
-import org.apache.tinkerpop.gremlin.server.GremlinServer
-import org.apache.tinkerpop.gremlin.server.Settings
-import org.apache.tinkerpop.gremlin.server.Settings.ScriptEngineSettings
-import org.apache.tinkerpop.gremlin.server.op.session.Session
-
-if (${skipIntegrationTests}) return
-log.info("Starting Gremlin Server instances for native testing of gremlin-javascript")
-def settings = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern.yaml")
-settings.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties"
-settings.scriptEngines["gremlin-groovy"].scripts = ["${gremlin.server.dir}/scripts/generate-modern.groovy"]
-settings.port = 45950
-def server = new GremlinServer(settings)
-server.start().join()
-project.setContextValue("gremlin.javascript.server", server)
-log.info("Gremlin Server started on port 45950")
-]]>
-                                </script>
+                                <script>${gremlin.server.dir}/src/test/scripts/test-server-start.groovy</script>
                             </scripts>
                         </configuration>
                     </execution>
@@ -232,19 +236,18 @@ log.info("Gremlin Server started on port 45950")
                             <goal>execute</goal>
                         </goals>
                         <configuration>
+                            <properties>
+                                <property>
+                                    <name>skipTests</name>
+                                    <value>${skipTests}</value>
+                                </property>
+                                <property>
+                                    <name>executionName</name>
+                                    <value>${project.name}</value>
+                                </property>
+                            </properties>
                             <scripts>
-                                <script>
-                                    <![CDATA[
-import org.apache.tinkerpop.gremlin.server.GremlinServer
-import org.apache.tinkerpop.gremlin.server.op.session.Session
-
-if (${skipIntegrationTests}) return
-log.info("Tests for native gremlin-javascript complete")
-def server = project.getContextValue("gremlin.javascript.server")
-log.info("Shutting down $server")
-server.stop().join()
-]]>
-                                </script>
+                                <script>${gremlin.server.dir}/src/test/scripts/test-server-stop.groovy</script>
                             </scripts>
                         </configuration>
                     </execution>
@@ -292,6 +295,7 @@ server.stop().join()
                         </goals>
                         <configuration>
                             <arguments>test</arguments>
+                            <failOnError>true</failOnError>
                         </configuration>
                     </execution>
                     <execution>
@@ -302,6 +306,7 @@ server.stop().join()
                         </goals>
                         <configuration>
                             <arguments>run-script features</arguments>
+                            <failOnError>true</failOnError>
                         </configuration>
                     </execution>
                 </executions>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 0d6d507..18c551c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -41,6 +41,7 @@ var responseStatusCode = {
  * Creates a new instance of DriverRemoteConnection.
  * @param {String} url The resource uri.
  * @param {Object} [options] The connection options.
+ * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
  * @param {Array} [options.ca] Trusted certificates.
  * @param {String|Array|Buffer} [options.cert] The certificate key.
  * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
@@ -71,6 +72,7 @@ function DriverRemoteConnection(url, options) {
   this._responseHandlers = {};
   this._reader = options.reader || new serializer.GraphSONReader();
   this._writer = options.writer || new serializer.GraphSONWriter();
+  this._traversalSource = options.traversalSource || 'g';
   this._openPromise = null;
   this._openCallback = null;
   this._closePromise = null;
@@ -125,7 +127,7 @@ DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
     'processor': 'traversal',
     'args': {
       'gremlin': this._writer.adaptObject(bytecode),
-      'aliases': { 'g': 'g'}
+      'aliases': { 'g': this._traversalSource }
     }
   });
 };
@@ -193,7 +195,7 @@ function getUuid() {
     hex.substr(20, 12));
 }
 
-var bufferFromString = Buffer.from || function newBuffer(text) {
+const bufferFromString = (Int8Array.from !== Buffer.from && Buffer.from) || function newBuffer(text) {
   return new Buffer(text, 'utf8');
 };
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index dfbaff2..43cf35f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -28,8 +28,8 @@
     "url": "https://issues.apache.org/jira/browse/TINKERPOP"
   },
   "scripts": {
-    "test": "./node_modules/.bin/mocha test --recursive -t 5000",
-    "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
+    "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 10680b7..bea7321 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -22,34 +22,37 @@
  */
 'use strict';
 
-const {defineSupportCode} = require('cucumber');
+const defineSupportCode = require('cucumber').defineSupportCode;
 const vm = require('vm');
 
 
-defineSupportCode(function({Given, When, Then}) {
-  Given(/^the (.+) graph$/, function (graphName) {
+defineSupportCode(function(methods) {
+  methods.Given(/^the (.+) graph$/, function (graphName) {
     //TODO: Set context g
   });
-  // Given('the graph initializer of');
-  Given('an unsupported test', () => {});
+  methods.Given('the graph initializer of', function () {
+    //TODO
+  });
+
+  methods.Given('an unsupported test', () => {});
 
-  Given('the traversal of', function (traversalText) {
+  methods.Given('the traversal of', function (traversalText) {
     //TODO: make traversal
   });
 
-  Given(/^$/, function (paramName, stringValue) {
+  methods.Given(/^$/, function (paramName, stringValue) {
     //TODO: Add parameter
   });
 
-  When('iterated to list', function () {
+  methods.When('iterated to list', function () {
     //TODO
   });
 
-  When('iterated next', function () {
+  methods.When('iterated next', function () {
     //TODO
   });
 
-  Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+  methods.Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
     //TODO
     //console.log('--resultTable', resultTable.rows());
     if (typeof resultTable === 'function'){
@@ -57,13 +60,13 @@ defineSupportCode(function({Given, When, Then}) {
     }
   });
 
-  Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
+  methods.Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
 
   });
 
-  Then(/^the result should have a count of (\d+)$/, function (stringCount) {
+  methods.Then(/^the result should have a count of (\d+)$/, function (stringCount) {
 
   });
 
-  Then('nothing should happen because', () => {});
+  methods.Then('nothing should happen because', () => {});
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index f1cd7a6..2e4f6e1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -22,12 +22,18 @@
  */
 'use strict';
 
-const {defineSupportCode} = require('cucumber');
+const defineSupportCode = require('cucumber').defineSupportCode;
 
-defineSupportCode(function ({setWorldConstructor}) {
+defineSupportCode(function (methods) {
   function TinkerPopWorld(){
     this.g = null;
     this.traversal = null;
   }
-  setWorldConstructor(TinkerPopWorld);
+  methods.setWorldConstructor(TinkerPopWorld);
+  methods.BeforeAll(function () {
+    // load all traversals
+  });
+  methods.Before(function () {
+
+  });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
new file mode 100644
index 0000000..546840e
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -0,0 +1,29 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const DriverRemoteConnection = require('../lib/driver/driver-remote-connection');
+
+exports.getConnection = function getConnection(traversalSource) {
+  return new DriverRemoteConnection('ws://localhost:45940/gremlin', { traversalSource: traversalSource });
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
index df813ad..268773c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -22,16 +22,16 @@
  */
 'use strict';
 
-var assert = require('assert');
-var Bytecode = require('../../lib/process/bytecode');
-var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
-var graphModule = require('../../lib/structure/graph');
+const assert = require('assert');
+const Bytecode = require('../../lib/process/bytecode');
+const graphModule = require('../../lib/structure/graph');
+const helper = require('../helper');
 
 var connection;
 
 describe('DriverRemoteConnection', function () {
   before(function () {
-    connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+    connection = helper.getConnection();
     return connection.open();
   });
   after(function () {
@@ -55,10 +55,4 @@ describe('DriverRemoteConnection', function () {
         });
     });
   });
-});
-
-function delay(ms) {
-  return new Promise(function (resolve) {
-    setTimeout(resolve, ms);
-  });
-}
\ No newline at end of file
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/867c1b94/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index 90afced..96de7c7 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -22,20 +22,18 @@
  */
 'use strict';
 
-var assert = require('assert');
-var graphModule = require('../../lib/structure/graph');
-var Graph = graphModule.Graph;
-var Vertex = graphModule.Vertex;
-var utils = require('../../lib/utils');
-var t = require('../../lib/process/traversal');
-var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
-var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
+const assert = require('assert');
+const graphModule = require('../../lib/structure/graph');
+const Graph = graphModule.Graph;
+const Vertex = graphModule.Vertex;
+const utils = require('../../lib/utils');
+const helper = require('../helper');
 
 var connection;
 
 describe('Traversal', function () {
   before(function () {
-    connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+    connection = helper.getConnection();
     return connection.open();
   });
   after(function () {


[04/47] tinkerpop git commit: Removed a hardcoded expectation in test suite around metrics serialization CTR

Posted by jo...@apache.org.
Removed a hardcoded expectation in test suite around metrics serialization CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a94baa0e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a94baa0e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a94baa0e

Branch: refs/heads/TINKERPOP-1489
Commit: a94baa0e017ff40f45642b1b1286e5e1cfc7c391
Parents: c4b0f9d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 11 09:57:27 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jan 11 09:57:27 2018 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                             | 1 +
 .../apache/tinkerpop/gremlin/structure/SerializationTest.java  | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a94baa0e/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ed32f05..c388425 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -24,6 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 === TinkerPop 3.2.8 (Release Date: NOT OFFICIALLY RELEASED YET)
 
 * Delayed setting of the request identifier until `RequestMessage` construction by the builder.
+* Removed hardcoded expectation in metrics serialization test suite as different providers may have different outputs.
 
 [[release-3-2-7]]
 === TinkerPop 3.2.7 (Release Date: December 17, 2017)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a94baa0e/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
index 4dacf48..1de30de 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
@@ -213,7 +213,7 @@ public class SerializationTest {
             final GryoWriter gryoWriter = gryoIo.writer().create();
             final GryoReader gryoReader = gryoIo.reader().create();
 
-            final TraversalMetrics before = (TraversalMetrics) g.V().both().profile().next();
+            final TraversalMetrics before = g.V().both().profile().next();
             final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
             gryoWriter.writeObject(outputStream, before);
 
@@ -355,7 +355,7 @@ public class SerializationTest {
         @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
         public void shouldSerializeTraversalMetrics() throws Exception {
             final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
-            final TraversalMetrics tm = (TraversalMetrics) g.V().both().profile().next();
+            final TraversalMetrics tm = g.V().both().profile().next();
             final String json = mapper.writeValueAsString(tm);
             final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
 
@@ -363,7 +363,7 @@ public class SerializationTest {
             assertTrue(m.containsKey(GraphSONTokens.METRICS));
 
             final List<Map<String, Object>> metrics = (List<Map<String, Object>>) m.get(GraphSONTokens.METRICS);
-            assertEquals(2, metrics.size());
+            assertEquals(tm.getMetrics().size(), metrics.size());
 
             final Map<String, Object> metrics0 = metrics.get(0);
             assertTrue(metrics0.containsKey(GraphSONTokens.ID));


[30/47] tinkerpop git commit: Setup world and basic steps

Posted by jo...@apache.org.
Setup world and basic steps


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f8231bf1
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f8231bf1
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f8231bf1

Branch: refs/heads/TINKERPOP-1489
Commit: f8231bf104dcbbac01ee461739de2df8c64495c9
Parents: 867c1b9
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 23 15:06:17 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:20 2018 +0100

----------------------------------------------------------------------
 .../lib/driver/driver-remote-connection.js      |  4 +-
 .../test/cucumber/feature-steps.js              | 59 +++++++++++++++---
 .../gremlin-javascript/test/cucumber/world.js   | 64 +++++++++++++++++++-
 .../test/integration/traversal-test.js          |  6 +-
 4 files changed, 119 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f8231bf1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 18c551c..31f27cd 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -72,11 +72,11 @@ function DriverRemoteConnection(url, options) {
   this._responseHandlers = {};
   this._reader = options.reader || new serializer.GraphSONReader();
   this._writer = options.writer || new serializer.GraphSONWriter();
-  this._traversalSource = options.traversalSource || 'g';
   this._openPromise = null;
   this._openCallback = null;
   this._closePromise = null;
   this.isOpen = false;
+  this.traversalSource = options.traversalSource || 'g';
 }
 
 inherits(DriverRemoteConnection, RemoteConnection);
@@ -127,7 +127,7 @@ DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
     'processor': 'traversal',
     'args': {
       'gremlin': this._writer.adaptObject(bytecode),
-      'aliases': { 'g': this._traversalSource }
+      'aliases': { 'g': this.traversalSource }
     }
   });
 };

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f8231bf1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index bea7321..5270b39 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -23,13 +23,24 @@
 'use strict';
 
 const defineSupportCode = require('cucumber').defineSupportCode;
+const assert = require('assert');
 const vm = require('vm');
-
+const graphModule = require('../../lib/structure/graph');
+const graphTraversalModule = require('../../lib/process/graph-traversal');
+const traversalModule = require('../../lib/process/traversal');
+const Graph = graphModule.Graph;
+const __ = graphTraversalModule.statics;
 
 defineSupportCode(function(methods) {
   methods.Given(/^the (.+) graph$/, function (graphName) {
-    //TODO: Set context g
+    if (graphName === 'empty') {
+      //TODO
+    }
+    const data = this.getDataByGraphName(graphName);
+    this.graphName = graphName;
+    this.g = new Graph().traversal().withRemote(data.connection)
   });
+
   methods.Given('the graph initializer of', function () {
     //TODO
   });
@@ -37,7 +48,7 @@ defineSupportCode(function(methods) {
   methods.Given('an unsupported test', () => {});
 
   methods.Given('the traversal of', function (traversalText) {
-    //TODO: make traversal
+    this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g));
   });
 
   methods.Given(/^$/, function (paramName, stringValue) {
@@ -45,16 +56,24 @@ defineSupportCode(function(methods) {
   });
 
   methods.When('iterated to list', function () {
-    //TODO
+    return this.traversal.toList().then(list => this.result = list);
   });
 
   methods.When('iterated next', function () {
-    //TODO
+    return this.traversal.next().then(it => this.result = it.value);
   });
 
   methods.Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+    switch (characterizedAs) {
+      case 'empty':
+        assert.strictEqual(0, result.length);
+        break;
+      case 'ordered':
+        const expectedResult = resultTable.rows().map(parseRow);
+        console.log('--- ordered', expectedResult);
+        break;
+    }
     //TODO
-    //console.log('--resultTable', resultTable.rows());
     if (typeof resultTable === 'function'){
       return resultTable();
     }
@@ -69,4 +88,30 @@ defineSupportCode(function(methods) {
   });
 
   methods.Then('nothing should happen because', () => {});
-});
\ No newline at end of file
+});
+
+function getSandbox(g) {
+  return {
+    g: g,
+    __: __,
+    Cardinality: traversalModule.cardinality,
+    Column: traversalModule.column,
+    Direction: traversalModule.direction,
+    Order: traversalModule.order,
+    P: traversalModule.P,
+    Pick: traversalModule.pick,
+    Scope: traversalModule.scope,
+    Operator: traversalModule.operator,
+    T: traversalModule.t,
+  };
+}
+
+function translate(traversalText) {
+  traversalText = traversalText.replace('.in(', '.in_(');
+  traversalText = traversalText.replace('.from(', '.from_(');
+  return traversalText;
+}
+
+function parseRow(row) {
+  return row[0];
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f8231bf1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 2e4f6e1..8f72c58 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -23,17 +23,77 @@
 'use strict';
 
 const defineSupportCode = require('cucumber').defineSupportCode;
+const helper = require('../helper');
+const graphModule = require('../../lib/structure/graph');
+const graphTraversalModule = require('../../lib/process/graph-traversal');
+const Graph = graphModule.Graph;
+const __ = graphTraversalModule.statics;
 
 defineSupportCode(function (methods) {
+  const cache = {};
+
   function TinkerPopWorld(){
     this.g = null;
     this.traversal = null;
+    this.result = null;
+    this.cache = null;
   }
+
+  TinkerPopWorld.prototype.getDataByGraphName = function (name) {
+    return this.cache[name];
+  };
+
   methods.setWorldConstructor(TinkerPopWorld);
+
   methods.BeforeAll(function () {
     // load all traversals
+    const promises = ['modern', 'classic', 'crew', 'grateful'].map(graphName => {
+      const connection = helper.getConnection('g' + graphName);
+      return connection.open()
+        .then(() => Promise.all([getVertices(connection), getEdges(connection)]))
+        .then(values => {
+          cache[graphName] = {
+            connection: connection,
+            vertices: values[0],
+            edges: values[1]
+          };
+        });
+    });
+    return Promise.all(promises);
   });
-  methods.Before(function () {
 
+  methods.AfterAll(function () {
+    return Promise.all(Object.keys(cache).map(graphName => cache[graphName].connection.close()));
   });
-});
\ No newline at end of file
+
+  methods.Before(function () {
+    this.cache = cache;
+  });
+});
+
+function getVertices(connection) {
+  const g = new Graph().traversal().withRemote(connection);
+  return g.V().group().by('name').by(__.tail()).next().then(it => it.value);
+}
+
+function getEdges(connection) {
+  const g = new Graph().traversal().withRemote(connection);
+  return g.E().group()
+    .by(__.project("o", "l", "i").by(__.outV().values("name")).by(__.inV().values("name")))
+    .by(__.tail())
+    .next()
+    .then(it => {
+      const edges = {};
+      Object.keys(it.value).map(key => {
+        edges[getEdgeKey(key)] = it.value[key];
+      });
+      return edges;
+    });
+}
+
+function getEdgeKey(key) {
+  const o = /o=(.+?)[,}]/.exec(key)[1];
+  const l = /l=(.+?)[,}]/.exec(key)[1];
+  const i = /i=(.+?)[,}]/.exec(key)[1];
+  return o + "-" + l + "->" + i;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f8231bf1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index 96de7c7..adb7d6c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -42,10 +42,10 @@ describe('Traversal', function () {
   describe('#toList()', function () {
     it('should submit the traversal and return a list', function () {
       var g = new Graph().traversal().withRemote(connection);
-      return g.addV('user').toList().then(function (list) {
+      return g.V().toList().then(function (list) {
         assert.ok(list);
-        assert.strictEqual(list.length, 1);
-        assert.ok(list[0] instanceof Vertex);
+        assert.strictEqual(list.length, 7);
+        list.forEach(v => assert.ok(v instanceof Vertex));
       });
     });
   });


[19/47] tinkerpop git commit: Bump to 3.2.6 in gremlin-javascript

Posted by jo...@apache.org.
Bump to 3.2.6 in gremlin-javascript


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2ff9c972
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2ff9c972
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2ff9c972

Branch: refs/heads/TINKERPOP-1489
Commit: 2ff9c972b6c50b4a3293f453c2814721a2e68493
Parents: 1973675
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Aug 17 13:35:47 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:19 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/pom.xml                                         | 2 +-
 .../src/main/javascript/gremlin-javascript/package.json            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2ff9c972/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 1c9ffcc..452e183 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
     <parent>
         <groupId>org.apache.tinkerpop</groupId>
         <artifactId>tinkerpop</artifactId>
-        <version>3.2.5-SNAPSHOT</version>
+        <version>3.2.6-SNAPSHOT</version>
     </parent>
     <artifactId>gremlin-javascript</artifactId>
     <name>Apache TinkerPop :: Gremlin Javascript</name>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2ff9c972/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 0976f31..db6d3fe 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -1,6 +1,6 @@
 {
   "name": "gremlin-javascript",
-  "version": "3.2.5-alpha1",
+  "version": "3.2.6-alpha1",
   "description": "JavaScript Gremlin Language Variant",
   "author": "Apache TinkerPop team",
   "keywords": [


[14/47] tinkerpop git commit: Filter out __() static method

Posted by jo...@apache.org.
Filter out __() static method


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0ec39935
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0ec39935
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0ec39935

Branch: refs/heads/TINKERPOP-1489
Commit: 0ec39935bd7a8ba86b7939aaa112a7d1516405d7
Parents: e1097e9
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Oct 19 16:03:45 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:18 2018 +0100

----------------------------------------------------------------------
 .../javascript/GraphTraversalSourceGenerator.groovy       |  1 +
 .../gremlin-javascript/process/graph-traversal.js         | 10 ----------
 2 files changed, 1 insertion(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0ec39935/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index a8217e2..0ae6079 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -195,6 +195,7 @@ class GraphTraversalSourceGenerator {
         __.class.getMethods().
                 findAll { GraphTraversal.class.equals(it.returnType) }.
                 findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { !it.name.equals("__") }.
                 collect { SymbolHelper.toJs(it.name) }.
                 unique().
                 sort { a, b -> a <=> b }.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0ec39935/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index 663a24d..7f36e59 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -1080,16 +1080,6 @@
   };
 
   /**
-   * __() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.__ = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.__.apply(g, arguments);
-  };
-
-  /**
    * addE() static method
    * @param {...Object} args
    * @returns {GraphTraversal}


[03/47] tinkerpop git commit: Update changelog and minor tweak to if statement null check CTR

Posted by jo...@apache.org.
Update changelog and minor tweak to if statement null check CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c4b0f9de
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c4b0f9de
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c4b0f9de

Branch: refs/heads/TINKERPOP-1489
Commit: c4b0f9de04fda08db5b6b03a91ba58f3def0217a
Parents: 7e80bcc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 8 12:43:38 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jan 8 12:43:38 2018 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                                 | 1 +
 .../apache/tinkerpop/gremlin/driver/message/RequestMessage.java    | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4b0f9de/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 06261fd..ed32f05 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 [[release-3-2-8]]
 === TinkerPop 3.2.8 (Release Date: NOT OFFICIALLY RELEASED YET)
 
+* Delayed setting of the request identifier until `RequestMessage` construction by the builder.
 
 [[release-3-2-7]]
 === TinkerPop 3.2.7 (Release Date: December 17, 2017)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4b0f9de/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
index e836568..dc10baf 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/message/RequestMessage.java
@@ -155,7 +155,7 @@ public final class RequestMessage {
          * Create the request message given the settings provided to the {@link Builder}.
          */
         public RequestMessage create() {
-            return new RequestMessage(requestId == null ? UUID.randomUUID() : requestId, op, processor, args);
+            return new RequestMessage(null == requestId ? UUID.randomUUID() : requestId, op, processor, args);
         }
     }
 


[21/47] tinkerpop git commit: Update Javascript GLV

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
deleted file mode 100644
index 7f36e59..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ /dev/null
@@ -1,2016 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
- 
-/**
- * @author Jorge Bay Gondra
- */
-(function defineGraphTraversalModule() {
-  "use strict";
-
-  var t = loadModule.call(this, './traversal.js');
-  var remote = loadModule.call(this, '../driver/remote-connection.js');
-  var Bytecode = t.Bytecode;
-  var inherits = t.inherits;
-  var parseArgs = t.parseArgs;
-
-  /**
-   *
-   * @param {Graph} graph
-   * @param {TraversalStrategies} traversalStrategies
-   * @param {Bytecode} [bytecode]
-   * @constructor
-   */
-  function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-    this.graph = graph;
-    this.traversalStrategies = traversalStrategies;
-    this.bytecode = bytecode || new Bytecode();
-  }
-
-  /**
-   * @param remoteConnection
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-    var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
-    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-  };
-
-  /**
-   * Returns the string representation of the GraphTraversalSource.
-   * @returns {string}
-   */
-  GraphTraversalSource.prototype.toString = function () {
-    return 'graphtraversalsource[' + this.graph.toString() + ']';
-  };
-
-  /**
-   * withBulk GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withBulk = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * withComputer GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withComputer = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * withPath GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withPath = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * withSack GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withSack = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * withSideEffect GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withSideEffect = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * withStrategies GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withStrategies = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * withoutStrategies GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withoutStrategies = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * E GraphTraversalSource step method.
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversalSource.prototype.E = function (args) {
-    var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * V GraphTraversalSource step method.
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversalSource.prototype.V = function (args) {
-    var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * addV GraphTraversalSource step method.
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversalSource.prototype.addV = function (args) {
-    var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * inject GraphTraversalSource step method.
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversalSource.prototype.inject = function (args) {
-    var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
-
-  /**
-   * Represents a graph traversal.
-   * @extends Traversal
-   * @constructor
-   */
-  function GraphTraversal(graph, traversalStrategies, bytecode) {
-    t.Traversal.call(this, graph, traversalStrategies, bytecode);
-  }
-
-  inherits(GraphTraversal, t.Traversal);
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.V = function (args) {
-    this.bytecode.addStep('V', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.addE = function (args) {
-    this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.addInE = function (args) {
-    this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.addOutE = function (args) {
-    this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.addV = function (args) {
-    this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.aggregate = function (args) {
-    this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.and = function (args) {
-    this.bytecode.addStep('and', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.as = function (args) {
-    this.bytecode.addStep('as', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.barrier = function (args) {
-    this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.both = function (args) {
-    this.bytecode.addStep('both', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.bothE = function (args) {
-    this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.bothV = function (args) {
-    this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.branch = function (args) {
-    this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.by = function (args) {
-    this.bytecode.addStep('by', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.cap = function (args) {
-    this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.choose = function (args) {
-    this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.coalesce = function (args) {
-    this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.coin = function (args) {
-    this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.constant = function (args) {
-    this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.count = function (args) {
-    this.bytecode.addStep('count', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.cyclicPath = function (args) {
-    this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.dedup = function (args) {
-    this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.drop = function (args) {
-    this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.emit = function (args) {
-    this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.filter = function (args) {
-    this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.flatMap = function (args) {
-    this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.fold = function (args) {
-    this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.from_ = function (args) {
-    this.bytecode.addStep('from', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.group = function (args) {
-    this.bytecode.addStep('group', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.groupCount = function (args) {
-    this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.groupV3d0 = function (args) {
-    this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.has = function (args) {
-    this.bytecode.addStep('has', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.hasId = function (args) {
-    this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.hasKey = function (args) {
-    this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.hasLabel = function (args) {
-    this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.hasNot = function (args) {
-    this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.hasValue = function (args) {
-    this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.id = function (args) {
-    this.bytecode.addStep('id', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.identity = function (args) {
-    this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.inE = function (args) {
-    this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.inV = function (args) {
-    this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.in_ = function (args) {
-    this.bytecode.addStep('in', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.inject = function (args) {
-    this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.is = function (args) {
-    this.bytecode.addStep('is', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.key = function (args) {
-    this.bytecode.addStep('key', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.label = function (args) {
-    this.bytecode.addStep('label', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.limit = function (args) {
-    this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.local = function (args) {
-    this.bytecode.addStep('local', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.loops = function (args) {
-    this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.map = function (args) {
-    this.bytecode.addStep('map', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.mapKeys = function (args) {
-    this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.mapValues = function (args) {
-    this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.match = function (args) {
-    this.bytecode.addStep('match', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.max = function (args) {
-    this.bytecode.addStep('max', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.mean = function (args) {
-    this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.min = function (args) {
-    this.bytecode.addStep('min', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.not = function (args) {
-    this.bytecode.addStep('not', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.option = function (args) {
-    this.bytecode.addStep('option', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.optional = function (args) {
-    this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.or = function (args) {
-    this.bytecode.addStep('or', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.order = function (args) {
-    this.bytecode.addStep('order', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.otherV = function (args) {
-    this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.out = function (args) {
-    this.bytecode.addStep('out', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.outE = function (args) {
-    this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.outV = function (args) {
-    this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.pageRank = function (args) {
-    this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.path = function (args) {
-    this.bytecode.addStep('path', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.peerPressure = function (args) {
-    this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.profile = function (args) {
-    this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.program = function (args) {
-    this.bytecode.addStep('program', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.project = function (args) {
-    this.bytecode.addStep('project', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.properties = function (args) {
-    this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.property = function (args) {
-    this.bytecode.addStep('property', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.propertyMap = function (args) {
-    this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.range = function (args) {
-    this.bytecode.addStep('range', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.repeat = function (args) {
-    this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.sack = function (args) {
-    this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.sample = function (args) {
-    this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.select = function (args) {
-    this.bytecode.addStep('select', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.sideEffect = function (args) {
-    this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.simplePath = function (args) {
-    this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.store = function (args) {
-    this.bytecode.addStep('store', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.subgraph = function (args) {
-    this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.sum = function (args) {
-    this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.tail = function (args) {
-    this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.timeLimit = function (args) {
-    this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.times = function (args) {
-    this.bytecode.addStep('times', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.to = function (args) {
-    this.bytecode.addStep('to', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.toE = function (args) {
-    this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.toV = function (args) {
-    this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.tree = function (args) {
-    this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.unfold = function (args) {
-    this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.union = function (args) {
-    this.bytecode.addStep('union', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.until = function (args) {
-    this.bytecode.addStep('until', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.value = function (args) {
-    this.bytecode.addStep('value', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.valueMap = function (args) {
-    this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.values = function (args) {
-    this.bytecode.addStep('values', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.where = function (args) {
-    this.bytecode.addStep('where', parseArgs.apply(null, arguments));
-    return this;
-  };
-
-  /**
-   * Contains the static method definitions
-   * @type {Object}
-   */
-  var statics = {};
-
-  /**
-   * V() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.V = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.V.apply(g, arguments);
-  };
-
-  /**
-   * addE() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.addE = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.addE.apply(g, arguments);
-  };
-
-  /**
-   * addInE() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.addInE = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.addInE.apply(g, arguments);
-  };
-
-  /**
-   * addOutE() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.addOutE = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.addOutE.apply(g, arguments);
-  };
-
-  /**
-   * addV() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.addV = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.addV.apply(g, arguments);
-  };
-
-  /**
-   * aggregate() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.aggregate = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.aggregate.apply(g, arguments);
-  };
-
-  /**
-   * and() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.and = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.and.apply(g, arguments);
-  };
-
-  /**
-   * as() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.as = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.as.apply(g, arguments);
-  };
-
-  /**
-   * barrier() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.barrier = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.barrier.apply(g, arguments);
-  };
-
-  /**
-   * both() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.both = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.both.apply(g, arguments);
-  };
-
-  /**
-   * bothE() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.bothE = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.bothE.apply(g, arguments);
-  };
-
-  /**
-   * bothV() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.bothV = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.bothV.apply(g, arguments);
-  };
-
-  /**
-   * branch() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.branch = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.branch.apply(g, arguments);
-  };
-
-  /**
-   * cap() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.cap = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.cap.apply(g, arguments);
-  };
-
-  /**
-   * choose() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.choose = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.choose.apply(g, arguments);
-  };
-
-  /**
-   * coalesce() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.coalesce = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.coalesce.apply(g, arguments);
-  };
-
-  /**
-   * coin() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.coin = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.coin.apply(g, arguments);
-  };
-
-  /**
-   * constant() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.constant = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.constant.apply(g, arguments);
-  };
-
-  /**
-   * count() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.count = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.count.apply(g, arguments);
-  };
-
-  /**
-   * cyclicPath() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.cyclicPath = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.cyclicPath.apply(g, arguments);
-  };
-
-  /**
-   * dedup() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.dedup = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.dedup.apply(g, arguments);
-  };
-
-  /**
-   * drop() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.drop = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.drop.apply(g, arguments);
-  };
-
-  /**
-   * emit() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.emit = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.emit.apply(g, arguments);
-  };
-
-  /**
-   * filter() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.filter = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.filter.apply(g, arguments);
-  };
-
-  /**
-   * flatMap() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.flatMap = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.flatMap.apply(g, arguments);
-  };
-
-  /**
-   * fold() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.fold = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.fold.apply(g, arguments);
-  };
-
-  /**
-   * group() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.group = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.group.apply(g, arguments);
-  };
-
-  /**
-   * groupCount() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.groupCount = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.groupCount.apply(g, arguments);
-  };
-
-  /**
-   * groupV3d0() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.groupV3d0 = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.groupV3d0.apply(g, arguments);
-  };
-
-  /**
-   * has() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.has = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.has.apply(g, arguments);
-  };
-
-  /**
-   * hasId() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.hasId = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.hasId.apply(g, arguments);
-  };
-
-  /**
-   * hasKey() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.hasKey = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.hasKey.apply(g, arguments);
-  };
-
-  /**
-   * hasLabel() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.hasLabel = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.hasLabel.apply(g, arguments);
-  };
-
-  /**
-   * hasNot() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.hasNot = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.hasNot.apply(g, arguments);
-  };
-
-  /**
-   * hasValue() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.hasValue = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.hasValue.apply(g, arguments);
-  };
-
-  /**
-   * id() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.id = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.id.apply(g, arguments);
-  };
-
-  /**
-   * identity() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.identity = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.identity.apply(g, arguments);
-  };
-
-  /**
-   * inE() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.inE = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.inE.apply(g, arguments);
-  };
-
-  /**
-   * inV() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.inV = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.inV.apply(g, arguments);
-  };
-
-  /**
-   * in_() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.in_ = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.in_.apply(g, arguments);
-  };
-
-  /**
-   * inject() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.inject = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.inject.apply(g, arguments);
-  };
-
-  /**
-   * is() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.is = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.is.apply(g, arguments);
-  };
-
-  /**
-   * key() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.key = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.key.apply(g, arguments);
-  };
-
-  /**
-   * label() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.label = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.label.apply(g, arguments);
-  };
-
-  /**
-   * limit() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.limit = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.limit.apply(g, arguments);
-  };
-
-  /**
-   * local() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.local = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.local.apply(g, arguments);
-  };
-
-  /**
-   * loops() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.loops = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.loops.apply(g, arguments);
-  };
-
-  /**
-   * map() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.map = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.map.apply(g, arguments);
-  };
-
-  /**
-   * mapKeys() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.mapKeys = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.mapKeys.apply(g, arguments);
-  };
-
-  /**
-   * mapValues() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.mapValues = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.mapValues.apply(g, arguments);
-  };
-
-  /**
-   * match() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.match = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.match.apply(g, arguments);
-  };
-
-  /**
-   * max() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.max = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.max.apply(g, arguments);
-  };
-
-  /**
-   * mean() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.mean = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.mean.apply(g, arguments);
-  };
-
-  /**
-   * min() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.min = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.min.apply(g, arguments);
-  };
-
-  /**
-   * not() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.not = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.not.apply(g, arguments);
-  };
-
-  /**
-   * optional() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.optional = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.optional.apply(g, arguments);
-  };
-
-  /**
-   * or() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.or = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.or.apply(g, arguments);
-  };
-
-  /**
-   * order() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.order = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.order.apply(g, arguments);
-  };
-
-  /**
-   * otherV() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.otherV = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.otherV.apply(g, arguments);
-  };
-
-  /**
-   * out() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.out = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.out.apply(g, arguments);
-  };
-
-  /**
-   * outE() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.outE = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.outE.apply(g, arguments);
-  };
-
-  /**
-   * outV() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.outV = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.outV.apply(g, arguments);
-  };
-
-  /**
-   * path() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.path = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.path.apply(g, arguments);
-  };
-
-  /**
-   * project() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.project = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.project.apply(g, arguments);
-  };
-
-  /**
-   * properties() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.properties = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.properties.apply(g, arguments);
-  };
-
-  /**
-   * property() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.property = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.property.apply(g, arguments);
-  };
-
-  /**
-   * propertyMap() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.propertyMap = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.propertyMap.apply(g, arguments);
-  };
-
-  /**
-   * range() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.range = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.range.apply(g, arguments);
-  };
-
-  /**
-   * repeat() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.repeat = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.repeat.apply(g, arguments);
-  };
-
-  /**
-   * sack() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.sack = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.sack.apply(g, arguments);
-  };
-
-  /**
-   * sample() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.sample = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.sample.apply(g, arguments);
-  };
-
-  /**
-   * select() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.select = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.select.apply(g, arguments);
-  };
-
-  /**
-   * sideEffect() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.sideEffect = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.sideEffect.apply(g, arguments);
-  };
-
-  /**
-   * simplePath() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.simplePath = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.simplePath.apply(g, arguments);
-  };
-
-  /**
-   * start() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.start = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.start.apply(g, arguments);
-  };
-
-  /**
-   * store() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.store = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.store.apply(g, arguments);
-  };
-
-  /**
-   * subgraph() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.subgraph = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.subgraph.apply(g, arguments);
-  };
-
-  /**
-   * sum() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.sum = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.sum.apply(g, arguments);
-  };
-
-  /**
-   * tail() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.tail = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.tail.apply(g, arguments);
-  };
-
-  /**
-   * timeLimit() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.timeLimit = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.timeLimit.apply(g, arguments);
-  };
-
-  /**
-   * times() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.times = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.times.apply(g, arguments);
-  };
-
-  /**
-   * to() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.to = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.to.apply(g, arguments);
-  };
-
-  /**
-   * toE() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.toE = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.toE.apply(g, arguments);
-  };
-
-  /**
-   * toV() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.toV = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.toV.apply(g, arguments);
-  };
-
-  /**
-   * tree() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.tree = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.tree.apply(g, arguments);
-  };
-
-  /**
-   * unfold() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.unfold = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.unfold.apply(g, arguments);
-  };
-
-  /**
-   * union() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.union = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.union.apply(g, arguments);
-  };
-
-  /**
-   * until() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.until = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.until.apply(g, arguments);
-  };
-
-  /**
-   * value() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.value = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.value.apply(g, arguments);
-  };
-
-  /**
-   * valueMap() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.valueMap = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.valueMap.apply(g, arguments);
-  };
-
-  /**
-   * values() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.values = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.values.apply(g, arguments);
-  };
-
-  /**
-   * where() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.where = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.where.apply(g, arguments);
-  };
-
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
-      this.__dependencies = this.__dependencies || {};
-      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
-    }
-    throw new Error('No module loader was found');
-  }
-
-  var toExport = {
-    GraphTraversal: GraphTraversal,
-    GraphTraversalSource: GraphTraversalSource,
-    statics: statics
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  // Nashorn and rest
-  return toExport;
-}).call(this);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
deleted file mode 100644
index 9709a4f..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTraversalModule() {
-  "use strict";
-
-  function Traversal(graph, traversalStrategies, bytecode) {
-    this.graph = graph;
-    this.traversalStrategies = traversalStrategies;
-    this.bytecode = bytecode;
-    this.traversers = null;
-    this.sideEffects = null;
-  }
-
-  /** @returns {Bytecode} */
-  Traversal.prototype.getBytecode = function () {
-    return this.bytecode;
-  };
-
-  /** @param {Function} callback */
-  Traversal.prototype.list = function (callback) {
-    var self = this;
-    this.traversalStrategies.applyStrategies(this, function (err) {
-      if (err) {
-        return callback(err);
-      }
-      callback(err, self.traversers);
-    });
-  };
-
-  /** @param {Function} callback */
-  Traversal.prototype.one = function (callback) {
-    this.list(function (err, result) {
-      callback(err, result && result.length > 0 ? result[0] : null);
-    });
-  };
-
-  /**
-   * Returns the Bytecode JSON representation of the traversal
-   * @returns {String}
-   */
-  Traversal.prototype.toString = function () {
-    return this.bytecode.toString();
-  };
-  
-  /**
-   * Represents an operation.
-   * @constructor
-   */
-  function P(operator, value, other) {
-    this.operator = operator;
-    this.value = value;
-    this.other = other;
-  }
-
-  /**
-   * Returns the string representation of the instance.
-   * @returns {string}
-   */
-  P.prototype.toString = function () {
-    if (this.other === undefined) {
-      return this.operator + '(' + this.value + ')';
-    }
-    return this.operator + '(' + this.value + ', ' + this.other + ')';
-  };
-
-  function createP(operator, args) {
-    args.unshift(null, operator);
-    return new (Function.prototype.bind.apply(P, args));
-  }
-
-  /** @param {...Object} args */
-  P.between = function (args) {
-    return createP('between', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.eq = function (args) {
-    return createP('eq', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.gt = function (args) {
-    return createP('gt', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.gte = function (args) {
-    return createP('gte', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.inside = function (args) {
-    return createP('inside', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.lt = function (args) {
-    return createP('lt', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.lte = function (args) {
-    return createP('lte', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.neq = function (args) {
-    return createP('neq', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.not = function (args) {
-    return createP('not', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.outside = function (args) {
-    return createP('outside', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.test = function (args) {
-    return createP('test', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.within = function (args) {
-    return createP('within', parseArgs.apply(null, arguments));
-  };
-
-  /** @param {...Object} args */
-  P.without = function (args) {
-    return createP('without', parseArgs.apply(null, arguments));
-  };
-
-  P.prototype.and = function (arg) {
-    return new P('and', this, arg);
-  };
-
-  P.prototype.or = function (arg) {
-    return new P('or', this, arg);
-  };
-
-  function Traverser(object, bulk) {
-    this.object = object;
-    this.bulk = bulk == undefined ? 1 : bulk;
-  }
-
-  function TraversalSideEffects() {
-
-  }
-
-  /**
-   * Creates a new instance of TraversalStrategies.
-   * @param {TraversalStrategies} [traversalStrategies]
-   * @constructor
-   */
-  function TraversalStrategies(traversalStrategies) {
-    /** @type {Array<TraversalStrategy>} */
-    this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
-  }
-
-  /** @param {TraversalStrategy} strategy */
-  TraversalStrategies.prototype.addStrategy = function (strategy) {
-    this.strategies.push(strategy);
-  };
-
-  /**
-   * @param {Traversal} traversal
-   * @param {Function} callback
-   */
-  TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
-    eachSeries(this.strategies, function eachStrategy(s, next) {
-      s.apply(traversal, next);
-    }, callback);
-  };
-
-  /**
-   * @abstract
-   * @constructor
-   */
-  function TraversalStrategy() {
-
-  }
-
-  /**
-   * @abstract
-   * @param {Traversal} traversal
-   * @param {Function} callback
-   */
-  TraversalStrategy.prototype.apply = function (traversal, callback) {
-
-  };
-
-  /**
-   * Creates a new instance of Bytecode
-   * @param {Bytecode} [toClone]
-   * @constructor
-   */
-  function Bytecode(toClone) {
-    this._bindings = {};
-    if (!toClone) {
-      this.sourceInstructions = [];
-      this.stepInstructions = [];
-    }
-    else {
-      this.sourceInstructions = toClone.sourceInstructions.slice(0);
-      this.stepInstructions = toClone.sourceInstructions.slice(0);
-    }
-  }
-
-  /**
-   * Adds a new source instructions
-   * @param {String} name
-   * @param {Array} values
-   * @returns {Bytecode}
-   */
-  Bytecode.prototype.addSource = function (name, values) {
-    if (name === undefined) {
-      throw new Error('Name is not defined');
-    }
-    var instruction = new Array(values.length + 1);
-    instruction[0] = name;
-    for (var i = 0; i < values.length; ++i) {
-      instruction[i + 1] = this._convertToArgument(values[i]);
-    }
-    this.sourceInstructions.push(this._generateInstruction(name, values));
-    return this;
-  };
-
-  /**
-   * Adds a new step instructions
-   * @param {String} name
-   * @param {Array} values
-   * @returns {Bytecode}
-   */
-  Bytecode.prototype.addStep = function (name, values) {
-    if (name === undefined) {
-      throw new Error('Name is not defined');
-    }
-    this.stepInstructions.push(this._generateInstruction(name, values));
-    return this;
-  };
-
-  Bytecode.prototype._generateInstruction = function (name, values) {
-    var instruction = new Array(values.length + 1);
-    instruction[0] = name;
-    for (var i = 0; i < values.length; ++i) {
-      instruction[i + 1] = this._convertToArgument(values[i]);
-    }
-    return instruction;
-  };
-
-  /**
-   * Returns the JSON representation of the source and step instructions
-   * @returns {String}
-   */
-  Bytecode.prototype.toString = function () {
-    return (
-      (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
-      (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
-    );
-  };
-
-  Bytecode.prototype._convertToArgument = function (value) {
-    return value;
-  };
-
-  function toEnum(typeName, keys) {
-    var result = {};
-    keys.split(' ').forEach(function (k) {
-      if (k === k.toUpperCase()) {
-        k = k.toLowerCase();
-      }
-      result[k] = new EnumValue(typeName, k);
-    });
-    return result;
-  }
-
-  function EnumValue(typeName, elementName) {
-    this.typeName = typeName;
-    this.elementName = elementName;
-  }
-
-  // Utility functions
-  /** @returns {Array} */
-  function parseArgs() {
-    return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
-  }
-
-  /**
-   * @param {Array} arr
-   * @param {Function} fn
-   * @param {Function} [callback]
-   */
-  function eachSeries(arr, fn, callback) {
-    if (!Array.isArray(arr)) {
-      throw new TypeError('First parameter is not an Array');
-    }
-    callback = callback || noop;
-    var length = arr.length;
-    if (length === 0) {
-      return callback();
-    }
-    var sync;
-    var index = 1;
-    fn(arr[0], next);
-    if (sync === undefined) {
-      sync = false;
-    }
-
-    function next(err) {
-      if (err) {
-        return callback(err);
-      }
-      if (index >= length) {
-        return callback();
-      }
-      if (sync === undefined) {
-        sync = true;
-      }
-      if (sync) {
-        return process.nextTick(function () {
-          fn(arr[index++], next);
-        });
-      }
-      fn(arr[index++], next);
-    }
-  }
-
-  function inherits(ctor, superCtor) {
-    ctor.super_ = superCtor;
-    ctor.prototype = Object.create(superCtor.prototype, {
-      constructor: {
-        value: ctor,
-        enumerable: false,
-        writable: true,
-        configurable: true
-      }
-    });
-  }
-
-  var toExport = {
-    Bytecode: Bytecode,
-    EnumValue: EnumValue,
-    inherits: inherits,
-    P: P,
-    parseArgs: parseArgs,
-    Traversal: Traversal,
-    TraversalSideEffects: TraversalSideEffects,
-    TraversalStrategies: TraversalStrategies,
-    TraversalStrategy: TraversalStrategy,
-    Traverser: Traverser,
-    barrier: toEnum('Barrier', 'normSack'),
-    cardinality: toEnum('Cardinality', 'list set single'),
-    column: toEnum('Column', 'keys values'),
-    direction: toEnum('Direction', 'BOTH IN OUT'),
-    operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
-    order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
-    pick: toEnum('Pick', 'any none'),
-    pop: toEnum('Pop', 'all first last'),
-    scope: toEnum('Scope', 'global local'),
-    t: toEnum('T', 'id key label value')
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  // Nashorn and rest
-  return toExport;
-}).call(this);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
deleted file mode 100644
index cd408ae..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineGraphModule() {
-  "use strict";
-
-  var gt = loadModule.call(this, '../process/graph-traversal.js');
-  var t = loadModule.call(this, '../process/traversal.js');
-  var inherits = t.inherits;
-
-  function Graph() {
-
-  }
-
-  /**
-   * Returns the graph traversal source.
-   * @returns {GraphTraversalSource}
-   */
-  Graph.prototype.traversal = function () {
-    return new gt.GraphTraversalSource(this, new t.TraversalStrategies());
-  };
-
-  Graph.prototype.toString = function () {
-    return 'graph[empty]';
-  };
-
-  function Element(id, label) {
-    this.id = id;
-    this.label = label;
-  }
-
-  /**
-   * Compares this instance to another and determines if they can be considered as equal.
-   * @param {Element} other
-   * @returns {boolean}
-   */
-  Element.prototype.equals = function (other) {
-    return (other instanceof Element) && this.id === other.id;
-  };
-
-  function Vertex(id, label, properties) {
-    Element.call(this, id, label);
-    this.properties = properties;
-  }
-
-  Vertex.prototype.toString = function () {
-    return 'v[' + this.id + ']';
-  };
-
-  inherits(Vertex, Element);
-
-  function Edge(id, outV, label, inV, properties) {
-    Element.call(this, id, label);
-    this.outV = outV;
-    this.inV = inV;
-    this.properties = {};
-    (function adaptProperties(self) {
-      if (properties) {
-        var keys = Object.keys(properties);
-        for (var i = 0; i < keys.length; i++) {
-          var k = keys[i];
-          self.properties[k] = properties[k].value;
-        }
-      }
-    })(this);
-  }
-
-  inherits(Edge, Element);
-
-  Edge.prototype.toString = function () {
-    return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
-  };
-
-  function VertexProperty(id, label, value, properties) {
-    Element.call(this, id, label);
-    this.value = value;
-    this.key = this.label;
-    this.properties = properties;
-  }
-
-  inherits(VertexProperty, Element);
-
-  VertexProperty.prototype.toString = function () {
-    return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
-  };
-
-  function Property(key, value) {
-    this.key = key;
-    this.value = value;
-  }
-
-  Property.prototype.toString = function () {
-    return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
-  };
-
-  Property.prototype.equals = function (other) {
-    return (other instanceof Property) && this.key === other.key && this.value === other.value;
-  };
-
-  /**
-   * Represents a walk through a graph as defined by a traversal.
-   * @param {Array} labels
-   * @param {Array} objects
-   * @constructor
-   */
-  function Path(labels, objects) {
-    this.labels = labels;
-    this.objects = objects;
-  }
-
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
-      this.__dependencies = this.__dependencies || {};
-      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
-    }
-    throw new Error('No module loader was found');
-  }
-
-  var toExport = {
-    Edge: Edge,
-    Graph: Graph,
-    Path: Path,
-    Property: Property,
-    Vertex: Vertex,
-    VertexProperty: VertexProperty
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  // Nashorn and rest
-  return toExport;
-}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
deleted file mode 100644
index 31652da..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function graphSerializerModule() {
-  "use strict";
-
-  var t = loadModule.call(this, '../../process/traversal.js');
-  var g = loadModule.call(this, '../graph.js');
-
-  /**
-   * A type serializer
-   * @typedef {Object} Serializer
-   * @property {Function} serialize
-   * @property {Function} deserialize
-   * @property {Function} [canBeUsedFor]
-   */
-
-  /**
-   * @const
-   * @private
-   */
-  var valueKey = '@value';
-
-  /**
-   * @const
-   * @private
-   */
-  var typeKey = '@type';
-
-  var deserializers = {
-    'g:Traverser': TraverserSerializer,
-    'g:Int32':  NumberSerializer,
-    'g:Int64':  NumberSerializer,
-    'g:Float':  NumberSerializer,
-    'g:Double': NumberSerializer,
-    'g:Vertex': VertexSerializer,
-    'g:Edge': EdgeSerializer,
-    'g:VertexProperty': VertexPropertySerializer,
-    'g:Property': PropertySerializer,
-    'g:Path': PathSerializer
-  };
-
-  var serializers = [
-    NumberSerializer,
-    BytecodeSerializer,
-    TraverserSerializer,
-    PSerializer,
-    LambdaSerializer,
-    EnumSerializer
-  ];
-
-  /**
-   * GraphSON Writer
-   * @param {Object} [options]
-   * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
-   * serializer instances as values, ie: { 'g:Int64': longSerializer }.
-   * @constructor
-   */
-  function GraphSONWriter(options) {
-    this._options = options || {};
-    // Create instance of the default serializers
-    this._serializers = serializers.map(function (serializerConstructor) {
-      var s = new serializerConstructor();
-      s.writer = this;
-      return s;
-    }, this);
-    var customSerializers = this._options.serializers || {};
-    Object.keys(customSerializers).forEach(function (key) {
-      var s = customSerializers[key];
-      if (!s.serialize) {
-        return;
-      }
-      s.writer = this;
-      // Insert custom serializers first
-      this._serializers.unshift(s);
-    }, this);
-  }
-
-  GraphSONWriter.prototype.adaptObject = function (value) {
-    var s;
-    if (Array.isArray(value)) {
-      return value.map(function (item) {
-        return this.adaptObject(item);
-      }, this);
-    }
-    for (var i = 0; i < this._serializers.length; i++) {
-      var currentSerializer = this._serializers[i];
-      if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
-        s = currentSerializer;
-        break;
-      }
-    }
-    if (s) {
-      return s.serialize(value);
-    }
-    // Default (strings / objects / ...)
-    return value;
-  };
-
-  /**
-   * Returns the GraphSON representation of the provided object instance.
-   * @param {Object} obj
-   * @returns {String}
-   */
-  GraphSONWriter.prototype.write = function (obj) {
-    return JSON.stringify(this.adaptObject(obj));
-  };
-
-  /**
-   * GraphSON Reader
-   * @param {Object} [options]
-   * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
-   * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
-   * @constructor
-   */
-  function GraphSONReader(options) {
-    this._options = options || {};
-    this._deserializers = {};
-    Object.keys(deserializers).forEach(function (typeName) {
-      var serializerConstructor = deserializers[typeName];
-      var s = new serializerConstructor();
-      s.reader = this;
-      this._deserializers[typeName] = s;
-    }, this);
-    if (this._options.serializers) {
-      var customSerializers = this._options.serializers || {};
-      Object.keys(customSerializers).forEach(function (key) {
-        var s = customSerializers[key];
-        if (!s.deserialize) {
-          return;
-        }
-        s.reader = this;
-        this._deserializers[key] = s;
-      }, this);
-    }
-  }
-
-  GraphSONReader.prototype.read = function (obj) {
-    if (obj === undefined) {
-      return undefined;
-    }
-    if (Array.isArray(obj)) {
-      return obj.map(function mapEach(item) {
-        return this.read(item);
-      }, this);
-    }
-    var type = obj[typeKey];
-    if (type) {
-      var d = this._deserializers[type];
-      if (d) {
-        // Use type serializer
-        return d.deserialize(obj);
-      }
-      return obj[valueKey];
-    }
-    if (obj && typeof obj === 'object' && obj.constructor === Object) {
-      return this._deserializeObject(obj);
-    }
-    // Default (for boolean, number and other scalars)
-    return obj;
-  };
-
-  GraphSONReader.prototype._deserializeObject = function (obj) {
-    var keys = Object.keys(obj);
-    var result = {};
-    for (var i = 0; i < keys.length; i++) {
-      result[keys[i]] = this.read(obj[keys[i]]);
-    }
-    return result;
-  };
-
-  function NumberSerializer() {
-
-  }
-
-  NumberSerializer.prototype.serialize = function (item) {
-    return item;
-  };
-
-  NumberSerializer.prototype.deserialize = function (obj) {
-    var value = obj[valueKey];
-    return parseFloat(value);
-  };
-
-  NumberSerializer.prototype.canBeUsedFor = function (value) {
-    return (typeof value === 'number');
-  };
-
-  function BytecodeSerializer() {
-
-  }
-
-  BytecodeSerializer.prototype.serialize = function (item) {
-    var bytecode = item;
-    if (item instanceof t.Traversal) {
-      bytecode = item.getBytecode();
-    }
-    var result = {};
-    result[typeKey] = 'g:Bytecode';
-    var resultValue = result[valueKey] = {};
-    var sources = this._serializeInstructions(bytecode.sourceInstructions);
-    if (sources) {
-      resultValue['source'] = sources;
-    }
-    var steps = this._serializeInstructions(bytecode.stepInstructions);
-    if (steps) {
-      resultValue['step'] = steps;
-    }
-    return result;
-  };
-
-  BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
-    if (instructions.length === 0) {
-      return null;
-    }
-    var result = new Array(instructions.length);
-    result[0] = instructions[0];
-    for (var i = 1; i < instructions.length; i++) {
-      result[i] = this.writer.adaptObject(instructions[i]);
-    }
-    return result;
-  };
-
-  BytecodeSerializer.prototype.canBeUsedFor = function (value) {
-    return (value instanceof t.Bytecode) || (value instanceof t.Traversal);
-  };
-
-  function PSerializer() {
-
-  }
-
-  /** @param {P} item */
-  PSerializer.prototype.serialize = function (item) {
-    var result = {};
-    result[typeKey] = 'g:P';
-    var resultValue = result[valueKey] = {
-      'predicate': item.operator
-    };
-    if (item.other == undefined) {
-      resultValue['value'] = this.writer.adaptObject(item.value);
-    }
-    else {
-      resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
-    }
-    return result;
-  };
-
-  PSerializer.prototype.canBeUsedFor = function (value) {
-    return (value instanceof t.P);
-  };
-
-  function LambdaSerializer() {
-
-  }
-
-  /** @param {Function} item */
-  LambdaSerializer.prototype.serialize = function (item) {
-    var result = {};
-    result[typeKey] = 'g:Lambda';
-    result[valueKey] = {
-      'arguments': item.length,
-      'language': 'gremlin-javascript',
-      'script': item.toString()
-    };
-    return result;
-  };
-
-  LambdaSerializer.prototype.canBeUsedFor = function (value) {
-    return (typeof value === 'function');
-  };
-
-  function EnumSerializer() {
-
-  }
-
-  /** @param {EnumValue} item */
-  EnumSerializer.prototype.serialize = function (item) {
-    var result = {};
-    result[typeKey] = 'g:' + item.typeName;
-    result[valueKey] = item.elementName;
-    return result;
-  };
-
-  EnumSerializer.prototype.canBeUsedFor = function (value) {
-    return value && value.typeName && value instanceof t.EnumValue;
-  };
-
-  function TraverserSerializer() {
-
-  }
-
-  /** @param {Traverser} item */
-  TraverserSerializer.prototype.serialize = function (item) {
-    var result = {};
-    result[typeKey] = 'g:Traverser';
-    result[valueKey] = {
-      'value': this.writer.adaptObject(item.object),
-      'bulk': this.writer.adaptObject(item.bulk)
-    };
-    return result;
-  };
-
-  TraverserSerializer.prototype.deserialize = function (obj) {
-    var value = obj[valueKey];
-    return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
-  };
-
-  TraverserSerializer.prototype.canBeUsedFor = function (value) {
-    return (value instanceof t.Traverser);
-  };
-
-  function VertexSerializer() {
-
-  }
-
-  VertexSerializer.prototype.deserialize = function (obj) {
-    var value = obj[valueKey];
-    return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
-  };
-
-  function VertexPropertySerializer() {
-
-  }
-
-  VertexPropertySerializer.prototype.deserialize = function (obj) {
-    var value = obj[valueKey];
-    return new g.VertexProperty(
-      this.reader.read(value['id']),
-      value['label'],
-      this.reader.read(value['value']),
-      this.reader.read(value['properties'])
-    );
-  };
-
-  function PropertySerializer() {
-
-  }
-
-  PropertySerializer.prototype.deserialize = function (obj) {
-    var value = obj[valueKey];
-    return new g.Property(
-      value['key'],
-      this.reader.read(value['value']));
-  };
-
-  function EdgeSerializer() {
-
-  }
-
-  EdgeSerializer.prototype.deserialize = function (obj) {
-    var value = obj[valueKey];
-    return new g.Edge(
-      this.reader.read(value['id']),
-      this.reader.read(value['outV']),
-      value['label'],
-      this.reader.read(value['inV']),
-      this.reader.read(value['properties'])
-    );
-  };
-
-  function PathSerializer() {
-
-  }
-
-  PathSerializer.prototype.deserialize = function (obj) {
-    var value = obj[valueKey];
-    var objects = value['objects'].map(function objectMapItem(o) {
-      return this.reader.read(o);
-    }, this);
-    return new g.Path(this.reader.read(value['labels']), objects);
-  };
-
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
-      this.__dependencies = this.__dependencies || {};
-      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
-    }
-    throw new Error('No module loader was found');
-  }
-
-  var toExport = {
-    GraphSONWriter: GraphSONWriter,
-    GraphSONReader: GraphSONReader
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  // Nashorn and rest
-  return toExport;
-}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
new file mode 100644
index 0000000..df813ad
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -0,0 +1,64 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var Bytecode = require('../../lib/process/bytecode');
+var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
+var graphModule = require('../../lib/structure/graph');
+
+var connection;
+
+describe('DriverRemoteConnection', function () {
+  before(function () {
+    connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+    return connection.open();
+  });
+  after(function () {
+    return connection.close();
+  });
+  describe('#submit()', function () {
+    it('should send the request and parse the response', function () {
+      return connection.submit(new Bytecode().addStep('addV', [ 'person' ]).addStep('property', [ 'name', 'marko']))
+        .then(function (response) {
+          assert.ok(response);
+          assert.ok(response.traversers);
+          assert.strictEqual(response.traversers.length, 1);
+          assert.ok(response.traversers[0].object instanceof graphModule.Vertex);
+        });
+    });
+    it('should send the request with syntax error and parse the response error', function () {
+      return connection.submit(new Bytecode().addStep('SYNTAX_ERROR'))
+        .catch(function (err) {
+          assert.ok(err);
+          assert.ok(err.message.indexOf('599') > 0);
+        });
+    });
+  });
+});
+
+function delay(ms) {
+  return new Promise(function (resolve) {
+    setTimeout(resolve, ms);
+  });
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
new file mode 100644
index 0000000..90afced
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -0,0 +1,71 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var graphModule = require('../../lib/structure/graph');
+var Graph = graphModule.Graph;
+var Vertex = graphModule.Vertex;
+var utils = require('../../lib/utils');
+var t = require('../../lib/process/traversal');
+var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
+var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
+
+var connection;
+
+describe('Traversal', function () {
+  before(function () {
+    connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+    return connection.open();
+  });
+  after(function () {
+    return connection.close();
+  });
+  describe('#toList()', function () {
+    it('should submit the traversal and return a list', function () {
+      var g = new Graph().traversal().withRemote(connection);
+      return g.addV('user').toList().then(function (list) {
+        assert.ok(list);
+        assert.strictEqual(list.length, 1);
+        assert.ok(list[0] instanceof Vertex);
+      });
+    });
+  });
+  describe('#next()', function () {
+    it('should submit the traversal and return an iterator', function () {
+      var g = new Graph().traversal().withRemote(connection);
+      var traversal = g.V().count();
+      return traversal.next()
+        .then(function (item) {
+          assert.ok(item);
+          assert.strictEqual(item.done, false);
+          assert.strictEqual(typeof item.value, 'number');
+          return traversal.next();
+        }).then(function (item) {
+          assert.ok(item);
+          assert.strictEqual(item.done, true);
+          assert.strictEqual(item.value, null);
+        });
+    });
+  });
+});
\ No newline at end of file


[15/47] tinkerpop git commit: TINKERPOP-1489 Regenerated traversal.js

Posted by jo...@apache.org.
TINKERPOP-1489 Regenerated traversal.js

which added Pick.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/23cbad39
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/23cbad39
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/23cbad39

Branch: refs/heads/TINKERPOP-1489
Commit: 23cbad3956722edd73f6bc0fecc46832bb0ecd71
Parents: b0da2fe
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 18 12:48:27 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:18 2018 +0100

----------------------------------------------------------------------
 .../src/main/javascript/gremlin-javascript/process/traversal.js     | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/23cbad39/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index f585161..9709a4f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -377,6 +377,7 @@
     direction: toEnum('Direction', 'BOTH IN OUT'),
     operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
     order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+    pick: toEnum('Pick', 'any none'),
     pop: toEnum('Pop', 'all first last'),
     scope: toEnum('Scope', 'global local'),
     t: toEnum('T', 'id key label value')


[20/47] tinkerpop git commit: Update Javascript GLV

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
new file mode 100644
index 0000000..3864a4a
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var glvModule = require('../../');
+
+describe('API', function () {
+  it('should export fields under process', function () {
+    assert.ok(glvModule);
+    assert.ok(glvModule.process);
+    assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
+    assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
+    assert.strictEqual(typeof glvModule.process.P, 'function');
+    assert.strictEqual(typeof glvModule.process.Traversal, 'function');
+    assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
+    assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
+    assert.strictEqual(typeof glvModule.process.TraversalStrategy, 'function');
+    assert.strictEqual(typeof glvModule.process.Traverser, 'function');
+    assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
+    assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+    assert.strictEqual(typeof glvModule.process.barrier, 'object');
+    assert.strictEqual(typeof glvModule.process.cardinality, 'object');
+    assert.strictEqual(typeof glvModule.process.column, 'object');
+    assert.strictEqual(typeof glvModule.process.direction, 'object');
+    assert.strictEqual(typeof glvModule.process.direction.both, 'object');
+    assert.strictEqual(glvModule.process.direction.both.elementName, 'BOTH');
+    assert.strictEqual(typeof glvModule.process.operator, 'object');
+    assert.strictEqual(typeof glvModule.process.order, 'object');
+    assert.strictEqual(typeof glvModule.process.pop, 'object');
+    assert.strictEqual(typeof glvModule.process.scope, 'object');
+    assert.strictEqual(typeof glvModule.process.t, 'object');
+    assert.ok(glvModule.process.statics);
+  });
+  it('should expose fields under structure', function () {
+    assert.ok(glvModule.structure);
+    assert.ok(glvModule.structure.io);
+    assert.strictEqual(typeof glvModule.structure.io.GraphSONReader, 'function');
+    assert.strictEqual(typeof glvModule.structure.io.GraphSONWriter, 'function');
+    assert.strictEqual(typeof glvModule.structure.Edge, 'function');
+    assert.strictEqual(typeof glvModule.structure.Graph, 'function');
+    assert.strictEqual(typeof glvModule.structure.Path, 'function');
+    assert.strictEqual(typeof glvModule.structure.Property, 'function');
+    assert.strictEqual(typeof glvModule.structure.Vertex, 'function');
+    assert.strictEqual(typeof glvModule.structure.VertexProperty, 'function');
+  });
+  it('should expose fields under driver', function () {
+    assert.ok(glvModule.driver);
+    assert.strictEqual(typeof glvModule.driver.RemoteConnection, 'function');
+    assert.strictEqual(typeof glvModule.driver.RemoteStrategy, 'function');
+    assert.strictEqual(typeof glvModule.driver.RemoteTraversal, 'function');
+  });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
new file mode 100644
index 0000000..ed5beb3
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
@@ -0,0 +1,112 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var graph = require('../../lib/structure/graph');
+var t = require('../../lib/process/traversal.js');
+var gs = require('../../lib/structure/io/graph-serializer.js');
+var GraphSONReader = gs.GraphSONReader;
+var GraphSONWriter = gs.GraphSONWriter;
+var P = t.P;
+
+describe('GraphSONReader', function () {
+  it('should parse GraphSON int32, float and double to Number from GraphSON', function () {
+    var reader = new GraphSONReader();
+    [
+      [ 'g:Int32', 31 ],
+      [ 'g:Float', 31.3],
+      [ 'g:Double', 31.2]
+    ].forEach(function (item) {
+      var result = reader.read({
+        "@type": item[0],
+        "@value": item[1]
+      });
+      assert.strictEqual(typeof result, 'number');
+      assert.strictEqual(result, item[1]);
+    });
+  });
+  it('should parse vertices from GraphSON', function () {
+    var obj = {
+      "@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
+        "properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],
+          "age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
+    var reader = new GraphSONReader(obj);
+    var result = reader.read(obj);
+    assert.ok(result instanceof graph.Vertex);
+    assert.strictEqual(result.label, 'person');
+    assert.strictEqual(typeof result.id, 'number');
+    assert.ok(result.properties);
+    assert.ok(result.properties['name']);
+    assert.strictEqual(result.properties['name'].length, 1);
+    assert.strictEqual(result.properties['name'][0].value, 'marko');
+    assert.ok(result.properties['age']);
+    assert.strictEqual(result.properties['age'].length, 1);
+    assert.strictEqual(result.properties['age'][0].value, 29);
+  });
+  it('should parse paths from GraphSON', function () {
+    var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
+      {
+        "@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
+        "properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},
+          "value":"marko","label":"name"}}],"age":[{
+              "@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},
+              "value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},
+      {
+        "@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software",
+        "properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},
+          "value":"lop","label":"name"}}],
+          "lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},
+            "value":"java","label":"lang"}}]}}},
+      "lop"]}};
+    var reader = new GraphSONReader(obj);
+    var result = reader.read(obj);
+    assert.ok(result);
+    assert.ok(result.objects);
+    assert.ok(result.labels);
+    assert.strictEqual(result.objects[2], 'lop');
+    assert.ok(result.objects[0] instanceof graph.Vertex);
+    assert.ok(result.objects[1] instanceof graph.Vertex);
+    assert.strictEqual(result.objects[0].label, 'person');
+    assert.strictEqual(result.objects[1].label, 'software');
+  });
+});
+describe('GraphSONWriter', function () {
+  it('should write numbers', function () {
+    var writer = new GraphSONWriter();
+    assert.strictEqual(writer.write(2), '2');
+  });
+  it('should write boolean values', function () {
+    var writer = new GraphSONWriter();
+    assert.strictEqual(writer.write(true), 'true');
+    assert.strictEqual(writer.write(false), 'false');
+  });
+  it('should write P', function () {
+    var writer = new GraphSONWriter();
+    var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[
+      {"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},
+        {"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},
+      {"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
+    assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
+  });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
new file mode 100644
index 0000000..c5271c9
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -0,0 +1,119 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var graph = require('../../lib/structure/graph');
+var utils = require('../../lib/utils');
+var t = require('../../lib/process/traversal');
+var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
+
+describe('Traversal', function () {
+  describe('#getByteCode()', function () {
+    it('should add steps for with a string parameter', function () {
+      var g = new graph.Graph().traversal();
+      var bytecode = g.V().out('created').getBytecode();
+      assert.ok(bytecode);
+      assert.strictEqual(bytecode.sourceInstructions.length, 0);
+      assert.strictEqual(bytecode.stepInstructions.length, 2);
+      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+      assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
+      assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+    });
+    it('should add steps with an enum value', function () {
+      var g = new graph.Graph().traversal();
+      var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
+      assert.ok(bytecode);
+      assert.strictEqual(bytecode.sourceInstructions.length, 0);
+      assert.strictEqual(bytecode.stepInstructions.length, 3);
+      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+      assert.strictEqual(bytecode.stepInstructions[1][0], 'order');
+      assert.strictEqual(bytecode.stepInstructions[2][0], 'by');
+      assert.strictEqual(bytecode.stepInstructions[2][1], 'age');
+      assert.strictEqual(typeof bytecode.stepInstructions[2][2], 'object');
+      assert.strictEqual(bytecode.stepInstructions[2][2].typeName, 'Order');
+      assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
+    });
+  });
+  describe('#next()', function () {
+    it('should apply the strategies and return a Promise with the iterator item', function () {
+      var strategyMock = {
+        apply: function (traversal) {
+          traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 1) ];
+          return utils.resolvedPromise();
+        }
+      };
+      var strategies = new TraversalStrategies();
+      strategies.addStrategy(strategyMock);
+      var traversal = new t.Traversal(null, strategies, null);
+      return traversal.next()
+        .then(function (item) {
+          assert.strictEqual(item.value, 1);
+          assert.strictEqual(item.done, false);
+          return traversal.next();
+        })
+        .then(function (item) {
+          assert.strictEqual(item.value, 2);
+          assert.strictEqual(item.done, false);
+          return traversal.next();
+        })
+        .then(function (item) {
+          assert.strictEqual(item.value, null);
+          assert.strictEqual(item.done, true);
+          return traversal.next();
+        });
+    });
+  });
+  describe('#toList()', function () {
+    it('should apply the strategies and return a Promise with an array', function () {
+      var strategyMock = {
+        apply: function (traversal) {
+          traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
+          return utils.resolvedPromise();
+        }
+      };
+      var strategies = new TraversalStrategies();
+      strategies.addStrategy(strategyMock);
+      var traversal = new t.Traversal(null, strategies, null);
+      return traversal.toList().then(function (list) {
+        assert.ok(list);
+        assert.deepEqual(list, [ 'a', 'b' ]);
+      });
+    });
+    it('should return an empty array when traversers is empty', function () {
+      var strategyMock = {
+        apply: function (traversal) {
+          traversal.traversers = [];
+          return utils.resolvedPromise();
+        }
+      };
+      var strategies = new TraversalStrategies();
+      strategies.addStrategy(strategyMock);
+      var traversal = new t.Traversal(null, strategies, null);
+      return traversal.toList().then(function (list) {
+        assert.ok(Array.isArray(list));
+        assert.strictEqual(list.length, 0);
+      });
+    })
+  });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
deleted file mode 100644
index 858ed06..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineHelperModule() {
-  "use strict";
-
-  var assert = {
-    ok: function (condition, message) {
-      if (!condition) {
-        throw new AssertError(message || (condition + ' == true'));
-      }
-    },
-    strictEqual: function (val1, val2, message) {
-      if (val1 !== val2) {
-        throw new AssertError(message || (val1 + ' === ' + val2));
-      }
-    }
-  };
-
-  function loadLibModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      moduleName = '../lib/' + moduleName;
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined' && typeof java !== 'undefined') {
-      moduleName = __DIR__ + '../../../main/javascript/gremlin-javascript/' + moduleName;
-      var path = new java.io.File(moduleName).getCanonicalPath();
-      this.__dependencies = this.__dependencies || {};
-      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
-    }
-    throw new Error('No module loader was found');
-  }
-
-  function AssertError(message) {
-    Error.call(this, message);
-    this.stack = (new Error(message)).stack;
-    if (typeof print !== 'undefined') {
-      print(this.stack);
-    }
-  }
-
-  inherits(AssertError, Error);
-
-  function inherits(ctor, superCtor) {
-    ctor.super_ = superCtor;
-    ctor.prototype = Object.create(superCtor.prototype, {
-      constructor: {
-        value: ctor,
-        enumerable: false,
-        writable: true,
-        configurable: true
-      }
-    });
-  }
-  var toExport = {
-    assert: assert,
-    loadLibModule: loadLibModule
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  return toExport;
-}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
deleted file mode 100644
index b9265c7..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTestCases() {
-  "use strict";
-
-  var helper = loadModule.call(this, './helper.js');
-  var assert = helper.assert;
-  var glvModule = helper.loadLibModule.call(this, './index.js');
-
-  [
-    function testExports() {
-      assert.ok(glvModule);
-
-      assert.ok(glvModule.process);
-      assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
-      assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
-      assert.strictEqual(typeof glvModule.process.P, 'function');
-      assert.strictEqual(typeof glvModule.process.Traversal, 'function');
-      assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
-      assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
-      assert.strictEqual(typeof glvModule.process.TraversalStrategy, 'function');
-      assert.strictEqual(typeof glvModule.process.Traverser, 'function');
-      assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
-      assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
-      assert.strictEqual(typeof glvModule.process.barrier, 'object');
-      assert.strictEqual(typeof glvModule.process.cardinality, 'object');
-      assert.strictEqual(typeof glvModule.process.column, 'object');
-      assert.strictEqual(typeof glvModule.process.direction, 'object');
-      assert.strictEqual(typeof glvModule.process.operator, 'object');
-      assert.strictEqual(typeof glvModule.process.order, 'object');
-      assert.strictEqual(typeof glvModule.process.pop, 'object');
-      assert.strictEqual(typeof glvModule.process.scope, 'object');
-      assert.strictEqual(typeof glvModule.process.t, 'object');
-
-
-      assert.ok(glvModule.process.statics);
-
-      assert.ok(glvModule.structure);
-      assert.ok(glvModule.structure.io);
-      assert.strictEqual(typeof glvModule.structure.io.GraphSONReader, 'function');
-      assert.strictEqual(typeof glvModule.structure.io.GraphSONWriter, 'function');
-      assert.strictEqual(typeof glvModule.structure.Edge, 'function');
-      assert.strictEqual(typeof glvModule.structure.Graph, 'function');
-      assert.strictEqual(typeof glvModule.structure.Path, 'function');
-      assert.strictEqual(typeof glvModule.structure.Property, 'function');
-      assert.strictEqual(typeof glvModule.structure.Vertex, 'function');
-      assert.strictEqual(typeof glvModule.structure.VertexProperty, 'function');
-
-      assert.ok(glvModule.driver);
-      assert.strictEqual(typeof glvModule.driver.RemoteConnection, 'function');
-      assert.strictEqual(typeof glvModule.driver.RemoteStrategy, 'function');
-      assert.strictEqual(typeof glvModule.driver.RemoteTraversal, 'function');
-    }
-  ].forEach(function (testCase) {
-    testCase.call(null);
-  });
-
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      return load(__DIR__ + moduleName);
-    }
-    throw new Error('No module loader was found');
-  }
-}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
deleted file mode 100644
index 418a9dd..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTestCases() {
-  "use strict";
-
-  var helper = loadModule.call(this, './helper.js');
-  var assert = helper.assert;
-  var graph = helper.loadLibModule.call(this, 'structure/graph.js');
-  var t = helper.loadLibModule.call(this, 'process/traversal.js');
-  var gs = helper.loadLibModule.call(this, 'structure/io/graph-serializer.js');
-  var GraphSONReader = gs.GraphSONReader;
-  var GraphSONWriter = gs.GraphSONWriter;
-  var P = t.P;
-
-  [
-    function testReadNumbers() {
-      var reader = new GraphSONReader();
-      [
-        [{
-          "@type": "g:Int32",
-          "@value": 31
-        }, 31],
-        [{
-          "@type": "g:Float",
-          "@value": 31.3
-        }, 31.3],
-        [{
-          "@type": "g:Double",
-          "@value": 31.2
-        }, 31.2]
-      ].forEach(function (item) {
-        var result = reader.read(item[0]);
-        assert.strictEqual(result, item[1]);
-        assert.strictEqual(typeof result, 'number');
-      });
-    },
-    function testReadGraph() {
-      var obj = {"@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":9}, "inV":{"@type":"g:Int32","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}],"knows":[{"id":{"@type":"g:Int32","@value":7},"inV":{"@type":"g:Int32","@value":2},"properties":{"weight":{"@type":"g:Double","@value":0.5}}},{"id":{"@type":"g:Int32","@value":8},"inV":{"@type":"g:Int32","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],"age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
-      var reader = new GraphSONReader(obj);
-      var result = reader.read(obj);
-      assert.ok(result instanceof graph.Vertex);
-      assert.strictEqual(result.label, 'person');
-      assert.strictEqual(typeof result.id, 'number');
-    },
-    function testReadPath() {
-      var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
-        {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},
-        {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},
-        "lop"]}};
-      var reader = new GraphSONReader(obj);
-      var result = reader.read(obj);
-      assert.ok(result);
-      assert.ok(result.objects);
-      assert.ok(result.labels);
-      assert.strictEqual(result.objects[2], 'lop');
-      assert.ok(result.objects[0] instanceof graph.Vertex);
-      assert.ok(result.objects[1] instanceof graph.Vertex);
-      assert.strictEqual(result.objects[0].label, 'person');
-      assert.strictEqual(result.objects[1].label, 'software');
-    },
-    function testWriteNumber() {
-      var writer = new GraphSONWriter();
-      assert.strictEqual(writer.write(2), '2');
-    },
-    function testWriteBoolean() {
-      var writer = new GraphSONWriter();
-      assert.strictEqual(writer.write(true), 'true');
-      assert.strictEqual(writer.write(false), 'false');
-    },
-    function testWriteP() {
-      var writer = new GraphSONWriter();
-      var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
-      assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
-    }
-  ].forEach(function (testCase) {
-    testCase.call(null);
-  });
-
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      return load(__DIR__ + moduleName);
-    }
-    throw new Error('No module loader was found');
-  }
-}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
deleted file mode 100644
index 1ec4253..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTestCases() {
-  "use strict";
-
-  var helper = loadModule.call(this, './helper.js');
-  var assert = helper.assert;
-  var graph = helper.loadLibModule.call(this, 'structure/graph.js');
-  var t = helper.loadLibModule.call(this, 'process/traversal.js');
-
-  [
-    function testBytecode1() {
-      var g = new graph.Graph().traversal();
-      var bytecode = g.V().out('created').getBytecode();
-      assert.ok(bytecode);
-      assert.strictEqual(bytecode.sourceInstructions.length, 0);
-      assert.strictEqual(bytecode.stepInstructions.length, 2);
-      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
-      assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
-      assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
-    },
-    function testBytecode2() {
-      var g = new graph.Graph().traversal();
-      var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
-      assert.ok(bytecode);
-      assert.strictEqual(bytecode.sourceInstructions.length, 0);
-      assert.strictEqual(bytecode.stepInstructions.length, 3);
-      assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
-      assert.strictEqual(bytecode.stepInstructions[1][0], 'order');
-      assert.strictEqual(bytecode.stepInstructions[2][0], 'by');
-      assert.strictEqual(bytecode.stepInstructions[2][1], 'age');
-      assert.strictEqual(typeof bytecode.stepInstructions[2][2], 'object');
-      assert.strictEqual(bytecode.stepInstructions[2][2].typeName, 'Order');
-      assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
-    }
-  ].forEach(function (testCase) {
-    testCase.call(null);
-  });
-
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      return load(__DIR__ + moduleName);
-    }
-    throw new Error('No module loader was found');
-  }
-}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9603d76..157b9bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -322,6 +322,10 @@ limitations under the License.
                         <exclude>**/*.csproj</exclude>
                         <exclude>**/.vs/**</exclude>
                         <exclude>**/NuGet.Config</exclude>
+                        <exclude>**/gremlin-javascript/node_modules/**</exclude>
+                        <exclude>**/node/node_modules/**</exclude>
+                        <exclude>**/node/node</exclude>
+                        <exclude>**/npm-debug.log</exclude>
                     </excludes>
                     <licenses>
                         <license implementation="org.apache.rat.analysis.license.ApacheSoftwareLicense20"/>


[23/47] tinkerpop git commit: Update Javascript GLV

Posted by jo...@apache.org.
Update Javascript GLV

Address feedback and provide maven integration:
- Reorganize gremlin-javascript into node.js project
- Simplify javascript code generators
- Generate package.json to match project version
- Introduce Promise factory for third-party promise library integration (ie: bluebird)
- Use toList() and next() traversal methods
- Include Remote connection implementation
- Fix enum casing
- Use Maven nodejs plugin
- .gitignore and .npmignore at gremlin-javascript level
- Run integration tests using a gremlin-server instance
- Add gremlin-javascript doc in gremlin-variants.asciidoc


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/19736751
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/19736751
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/19736751

Branch: refs/heads/TINKERPOP-1489
Commit: 1973675171f0243074794addd9fb0ceb5bc03994
Parents: 23cbad3
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Jun 6 15:05:14 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:19 2018 +0100

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc    |   75 +-
 gremlin-javascript/pom.xml                      |  171 +-
 .../javascript/GenerateGremlinJavascript.groovy |   36 +
 .../GraphTraversalSourceGenerator.groovy        |  226 +-
 .../javascript/PackageJsonGenerator.groovy      |   72 +
 .../gremlin/javascript/SymbolHelper.groovy      |   50 +
 .../javascript/TraversalSourceGenerator.groovy  |  437 ++--
 .../javascript/GenerateGremlinJavascript.java   |   32 -
 .../gremlin/javascript/jsr223/SymbolHelper.java |   59 -
 .../javascript/gremlin-javascript/.gitignore    |    5 +
 .../javascript/gremlin-javascript/.npmignore    |   26 +
 .../javascript/gremlin-javascript/README.md     |   39 +
 .../driver/remote-connection.js                 |  107 -
 .../main/javascript/gremlin-javascript/index.js |  113 +-
 .../lib/driver/driver-remote-connection.js      |  200 ++
 .../lib/driver/remote-connection.js             |   84 +
 .../gremlin-javascript/lib/process/bytecode.js  |   99 +
 .../lib/process/graph-traversal.js              | 2095 ++++++++++++++++++
 .../lib/process/traversal-strategy.js           |   88 +
 .../gremlin-javascript/lib/process/traversal.js |  236 ++
 .../gremlin-javascript/lib/structure/graph.js   |  138 ++
 .../lib/structure/io/graph-serializer.js        |  398 ++++
 .../javascript/gremlin-javascript/lib/utils.js  |   62 +
 .../javascript/gremlin-javascript/package.json  |   36 +
 .../process/graph-traversal.js                  | 2016 -----------------
 .../gremlin-javascript/process/traversal.js     |  392 ----
 .../gremlin-javascript/structure/graph.js       |  157 --
 .../structure/io/graph-serializer.js            |  415 ----
 .../test/integration/remote-connection-tests.js |   64 +
 .../test/integration/traversal-test.js          |   71 +
 .../test/unit/exports-test.js                   |   73 +
 .../test/unit/graphson-test.js                  |  112 +
 .../test/unit/traversal-test.js                 |  119 +
 .../javascript/gremlin-javascript/helper.js     |   84 -
 .../gremlin-javascript/test-exports.js          |   87 -
 .../gremlin-javascript/test-graphson.js         |  108 -
 .../gremlin-javascript/test-traversal.js        |   69 -
 pom.xml                                         |    4 +
 38 files changed, 4624 insertions(+), 4031 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index 0c48c97..76952eb 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -392,8 +392,8 @@ g.V().Repeat(Out()).Times(2).Values("name").Fold().ToList()
 
 === Bindings
 
-When a traversal bytecode is sent over a `IRemoteConnection` (e.g. Gremlin Server), it will be translated, compiled, 
-and then executed. If the same traversal is sent again, translation and compilation can be skipped as the previously 
+When a traversal bytecode is sent over a `IRemoteConnection` (e.g. Gremlin Server), it will be translated, compiled,
+and then executed. If the same traversal is sent again, translation and compilation can be skipped as the previously
 compiled version should be cached. Many traversals are unique up to some parameterization. For instance,
 `g.V(1).Out("created").Values("name")` is considered different from `g.V(4).Out("created").Values("Name")`
 as they have different script "string" representations. However, `g.V(x).Out("created").Values("name")` with bindings of 
@@ -422,7 +422,7 @@ g = g.WithoutStrategies(typeof(SubgraphStrategy));
 names = g.V().Values("name").ToList(); // names: [marko, vadas, lop, josh, ripple, peter]
 
 var edgeValueMaps = g.V().OutE().ValueMap(true).ToList();
-// edgeValueMaps: [[label:created, id:9, weight:0.4], [label:knows, id:7, weight:0.5], [label:knows, id:8, weight:1.0], 
+// edgeValueMaps: [[label:created, id:9, weight:0.4], [label:knows, id:7, weight:0.5], [label:knows, id:8, weight:1.0],
 //     [label:created, id:10, weight:1.0], [label:created, id:11, weight:0.4], [label:created, id:12, weight:0.2]]
 
 g = g.WithComputer(workers: 2, vertices: Has("name", "marko"));
@@ -435,3 +435,72 @@ edgeValueMaps = g.V().OutE().ValueMap(true).ToList();
 NOTE: Many of the TraversalStrategy classes in Gremlin.Net are proxies to the respective strategy on Apache TinkerPop’s
 JVM-based Gremlin traversal machine. As such, their `Apply(ITraversal)` method does nothing. However, the strategy is
 encoded in the Gremlin.Net bytecode and transmitted to the Gremlin traversal machine for re-construction machine-side.
+
+[[gremlin-javascript]]
+== Gremlin-JavaScript
+
+
+Apache TinkerPop's Gremlin-JavaScript implements Gremlin within the JavaScript language. It targets Node.js runtime
+and can be used on different operating systems on any Node.js 4 or above. Since the JavaScript naming conventions are
+very similar to that of Java, it should be very easy to switch between Gremlin-Java and Gremlin-JavaScript.
+
+[source,bash]
+npm install gremlin-javascript
+
+In Gremlin-JavaScript there exists `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes
+in Gremlin-Java. The `GraphTraversalSource` requires a RemoteConnection implementation in order to communicate with
+<<gremlin-server,GremlinServer>>.
+
+A traversal source can be spawned with `RemoteStrategy` from an empty `Graph`.
+
+[source,javascript]
+----
+const graph = new Graph();
+const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
+----
+
+When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via
+the registered `RemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote
+traversal source.
+
+Since Gremlin-JavaScript currently doesn't support lambda expressions, all traversals can be translated to
+Gremlin-Java on the remote location (e.g. Gremlin Server).
+
+IMPORTANT: Gremlin-JavaScript’s `Traversal` base class supports the standard Gremlin methods such as `next()` and
+`toList()` Such "terminal" methods trigger the evaluation of the traversal.
+
+=== RemoteConnection Submission
+
+Very similar to Gremlin-Python and Gremlin-Java, there are various ways to submit a traversal to a
+`RemoteConnection` using terminal/action methods off of `Traversal`.
+
+* `Traversal.next()`
+* `Traversal.toList()`
+
+=== Static Enums and Methods
+
+Gremlin has various tokens (e.g. `t`, `P`, `order`, `direction`, etc.) that are represented in Gremlin-JavaScript as
+objects.
+
+These can be used analogously to how they are used in Gremlin-Java.
+
+[source,javascript]
+g.V().hasLabel("person").has("age",P.gt(30)).Order().By("age", order.decr).toList()
+
+These objects must be required manually from the `process` namespace:
+
+[source,javascript]
+----
+const gremlin = require('gremlin-javascript');
+const P = gremlin.process.P;
+----
+
+Finally, using static `__` anonymous traversals like `__.out()` can be expressed as below:
+
+[source,javascript]
+----
+const gremlin = require('gremlin-javascript');
+const __ = gremlin.process.statics;
+
+g.V().repeat(__.out()).times(2).values("name").fold().toList();
+----

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index b9b78cc..1c9ffcc 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -37,6 +37,7 @@ limitations under the License.
             <version>${groovy.version}</version>
             <classifier>indy</classifier>
         </dependency>
+        <!-- TESTING -->
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
             <artifactId>tinkergraph-gremlin</artifactId>
@@ -58,12 +59,10 @@ limitations under the License.
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
-            <version>${slf4j.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
     <properties>
-        <!-- provides a way to convert maven.test.skip value to skipTests for use in skipping python tests -->
         <maven.test.skip>false</maven.test.skip>
         <skipTests>${maven.test.skip}</skipTests>
         <gremlin.server.dir>${project.parent.basedir}/gremlin-server</gremlin.server.dir>
@@ -86,33 +85,92 @@ limitations under the License.
                         <configuration>
                             <mainClass>org.apache.tinkerpop.gremlin.javascript.GenerateGremlinJavascript</mainClass>
                             <arguments>
-                                <argument>${basedir}/src/main/javascript/gremlin-javascript/process/traversal.js</argument>
-                                <argument>${basedir}/src/main/javascript/gremlin-javascript/process/graph-traversal.js</argument>
+                                <argument>${project.version}</argument>
+                                <argument>${basedir}</argument>
                             </arguments>
                         </configuration>
                     </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.gmavenplus</groupId>
+                <artifactId>gmavenplus-plugin</artifactId>
+                <dependencies>
+                    <dependency>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                        <version>1.2.17</version>
+                        <scope>runtime</scope>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.tinkerpop</groupId>
+                        <artifactId>gremlin-server</artifactId>
+                        <version>${project.version}</version>
+                        <scope>runtime</scope>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.codehaus.groovy</groupId>
+                        <artifactId>groovy-ant</artifactId>
+                        <version>${groovy.version}</version>
+                    </dependency>
+                </dependencies>
+                <executions>
                     <execution>
-                        <id>js-tests</id>
-                        <phase>test</phase>
+                        <id>gremlin-server-start</id>
+                        <phase>pre-integration-test</phase>
                         <goals>
-                            <goal>exec</goal>
+                            <goal>execute</goal>
                         </goals>
                         <configuration>
-                            <executable>jjs</executable>
-                            <arguments>
-                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-exports.js</argument>
-                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-graphson.js</argument>
-                                <argument>${basedir}/src/test/javascript/gremlin-javascript/test-traversal.js</argument>
-                            </arguments>
+                            <scripts>
+                                <script>
+                                    <![CDATA[
+import org.apache.tinkerpop.gremlin.server.GremlinServer
+import org.apache.tinkerpop.gremlin.server.Settings
+import org.apache.tinkerpop.gremlin.server.Settings.ScriptEngineSettings
+import org.apache.tinkerpop.gremlin.server.op.session.Session
+
+if (${skipIntegrationTests}) return
+log.info("Starting Gremlin Server instances for native testing of gremlin-javascript")
+def settings = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern.yaml")
+settings.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties"
+settings.scriptEngines["gremlin-groovy"].scripts = ["${gremlin.server.dir}/scripts/generate-modern.groovy"]
+settings.port = 45950
+def server = new GremlinServer(settings)
+server.start().join()
+project.setContextValue("gremlin.javascript.server", server)
+log.info("Gremlin Server started on port 45950")
+]]>
+                                </script>
+                            </scripts>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>gremlin-server-stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                            <scripts>
+                                <script>
+                                    <![CDATA[
+import org.apache.tinkerpop.gremlin.server.GremlinServer
+import org.apache.tinkerpop.gremlin.server.op.session.Session
+
+if (${skipIntegrationTests}) return
+log.info("Tests for native gremlin-javascript complete")
+def server = project.getContextValue("gremlin.javascript.server")
+log.info("Shutting down $server")
+server.stop().join()
+]]>
+                                </script>
+                            </scripts>
                         </configuration>
                     </execution>
                 </executions>
             </plugin>
             <plugin>
-                <groupId>org.codehaus.gmavenplus</groupId>
-                <artifactId>gmavenplus-plugin</artifactId>
-            </plugin>
-            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-clean-plugin</artifactId>
                 <version>3.0.0</version>
@@ -124,6 +182,85 @@ limitations under the License.
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>com.github.eirslett</groupId>
+                <artifactId>frontend-maven-plugin</artifactId>
+                <version>1.4</version>
+                <executions>
+                    <execution>
+                        <id>install node and npm</id>
+                        <goals>
+                            <goal>install-node-and-npm</goal>
+                        </goals>
+                        <phase>generate-test-resources</phase>
+                    </execution>
+                    <execution>
+                        <id>npm install</id>
+                        <goals>
+                            <goal>npm</goal>
+                        </goals>
+                        <phase>generate-test-resources</phase>
+                        <configuration>
+                            <arguments>install</arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>npm test</id>
+                        <goals>
+                            <goal>npm</goal>
+                        </goals>
+                        <phase>integration-test</phase>
+                        <configuration>
+                            <arguments>test</arguments>
+                        </configuration>
+                    </execution>
+                </executions>
+                <configuration>
+                    <skip>${skipIntegrationTests}</skip>
+                    <workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
+                    <nodeVersion>v4.8.3</nodeVersion>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
+    <profiles>
+        <!--
+        Provides a way to deploy the gremlin-javascript GLV to npm. This cannot be part of the standard maven execution
+        because npm does not have a staging environment like sonatype for releases. As soon as the release is
+        published it is public. In our release workflow, deploy occurs prior to vote on the release and we can't
+        make this stuff public until the vote is over.
+        -->
+        <profile>
+            <id>glv-javascript-deploy</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>com.github.eirslett</groupId>
+                        <artifactId>frontend-maven-plugin</artifactId>
+                        <version>1.4</version>
+                        <executions>
+                            <execution>
+                                <id>npm publish</id>
+                                <phase>deploy</phase>
+                                <goals>
+                                    <goal>npm</goal>
+                                </goals>
+                                <configuration>
+                                    <arguments>publish</arguments>
+                                </configuration>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <skip>${skipIntegrationTests}</skip>
+                            <workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
+                            <nodeVersion>v4.8.3</nodeVersion>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
new file mode 100644
index 0000000..ab9eaf1
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+public class GenerateGremlinJavascript {
+    public static void main(String[] args) {
+        String projectVersion = args[0];
+        final String baseDir = args[1];
+        final String jsModuleDir = "${baseDir}/src/main/javascript/gremlin-javascript";
+        Integer versionSnapshotIndex = projectVersion.indexOf("-SNAPSHOT");
+        if (versionSnapshotIndex > 0) {
+            // Use a alpha version x.y.z-alpha1
+            projectVersion = projectVersion.substring(0, versionSnapshotIndex) + "-alpha1";
+        }
+        TraversalSourceGenerator.create("$jsModuleDir/lib/process/traversal.js");
+        GraphTraversalSourceGenerator.create("$jsModuleDir/lib/process/graph-traversal.js");
+        PackageJsonGenerator.create("$jsModuleDir/package.json", projectVersion);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index 0ae6079..3227f2c 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
-import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+import org.apache.tinkerpop.gremlin.javascript.SymbolHelper
 
 import java.lang.reflect.Modifier
 
@@ -63,45 +63,46 @@ class GraphTraversalSourceGenerator {
 /**
  * @author Jorge Bay Gondra
  */
-(function defineGraphTraversalModule() {
-  "use strict";
-
-  var t = loadModule.call(this, './traversal.js');
-  var remote = loadModule.call(this, '../driver/remote-connection.js');
-  var Bytecode = t.Bytecode;
-  var inherits = t.inherits;
-  var parseArgs = t.parseArgs;
-
-  /**
-   *
-   * @param {Graph} graph
-   * @param {TraversalStrategies} traversalStrategies
-   * @param {Bytecode} [bytecode]
-   * @constructor
-   */
-  function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-    this.graph = graph;
-    this.traversalStrategies = traversalStrategies;
-    this.bytecode = bytecode || new Bytecode();
-  }
-
-  /**
-   * @param remoteConnection
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-    var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
-    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-  };
-
-  /**
-   * Returns the string representation of the GraphTraversalSource.
-   * @returns {string}
-   */
-  GraphTraversalSource.prototype.toString = function () {
-    return 'graphtraversalsource[' + this.graph.toString() + ']';
-  };
+'use strict';
+
+var t = require('./traversal.js');
+var remote = require('../driver/remote-connection');
+var utils = require('../utils');
+var Bytecode = require('./bytecode');
+var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+var inherits = utils.inherits;
+var parseArgs = utils.parseArgs;
+
+/**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+  this.graph = graph;
+  this.traversalStrategies = traversalStrategies;
+  this.bytecode = bytecode || new Bytecode();
+}
+
+/**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+  var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+  traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+  return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+};
+
+/**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+GraphTraversalSource.prototype.toString = function () {
+  return 'graphtraversalsource[' + this.graph.toString() + ']';
+};
 """)
         GraphTraversalSource.getMethods(). // SOURCE STEPS
                 findAll { GraphTraversalSource.class.equals(it.returnType) }.
@@ -110,40 +111,40 @@ class GraphTraversalSourceGenerator {
                             !it.name.equals(TraversalSource.Symbols.withBindings) &&
                             !it.name.equals(TraversalSource.Symbols.withRemote)
                 }.
-                collect { SymbolHelper.toJs(it.name) }.
+                collect { it.name }.
                 unique().
                 sort { a, b -> a <=> b }.
-                forEach { method ->
+                forEach { methodName ->
                     moduleOutput.append(
                             """
-  /**
-   * ${method} GraphTraversalSource method.
-   * @param {...Object} args
-   * @returns {GraphTraversalSource}
-   */
-  GraphTraversalSource.prototype.${method} = function (args) {
-    var b = new Bytecode(this.bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-    return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
+/**
+ * Graph Traversal Source ${methodName} method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('$methodName', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
 """)
                 }
-        GraphTraversalSource.getMethods(). // SPAWN STEPS
+        GraphTraversalSource.getMethods().
                 findAll { GraphTraversal.class.equals(it.returnType) }.
-                collect { SymbolHelper.toJs(it.name) }.
+                collect { it.name }.
                 unique().
                 sort { a, b -> a <=> b }.
-                forEach { method ->
+                forEach { methodName ->
                     moduleOutput.append(
                             """
-  /**
-   * ${method} GraphTraversalSource step method.
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversalSource.prototype.${method} = function (args) {
-    var b = new Bytecode(this.bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-    return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
-  };
+/**
+ * $methodName GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
+  var b = new Bytecode(this.bytecode).addStep('$methodName', parseArgs.apply(null, arguments));
+  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
 """)
                 }
 ////////////////////
@@ -151,34 +152,35 @@ class GraphTraversalSourceGenerator {
 ////////////////////
         moduleOutput.append(
                 """
-  /**
-   * Represents a graph traversal.
-   * @extends Traversal
-   * @constructor
-   */
-  function GraphTraversal(graph, traversalStrategies, bytecode) {
-    t.Traversal.call(this, graph, traversalStrategies, bytecode);
-  }
-
-  inherits(GraphTraversal, t.Traversal);
+/**
+ * Represents a graph traversal.
+ * @extends Traversal
+ * @constructor
+ */
+function GraphTraversal(graph, traversalStrategies, bytecode) {
+  t.Traversal.call(this, graph, traversalStrategies, bytecode);
+}
+
+inherits(GraphTraversal, t.Traversal);
 """)
         GraphTraversal.getMethods().
                 findAll { GraphTraversal.class.equals(it.returnType) }.
                 findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
-                collect { SymbolHelper.toJs(it.name) }.
+                collect { it.name }.
                 unique().
                 sort { a, b -> a <=> b }.
-                forEach { method ->
+                forEach { methodName ->
                     moduleOutput.append(
                             """
-  /**
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  GraphTraversal.prototype.${method} = function (args) {
-    this.bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-    return this;
-  };
+/**
+ * Graph traversal $methodName method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
+  this.bytecode.addStep('$methodName', parseArgs.apply(null, arguments));
+  return this;
+};
 """)
                 };
 
@@ -186,11 +188,11 @@ class GraphTraversalSourceGenerator {
 // AnonymousTraversal //
 ////////////////////////
         moduleOutput.append("""
-  /**
-   * Contains the static method definitions
-   * @type {Object}
-   */
-  var statics = {};
+/**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+var statics = {};
 """);
         __.class.getMethods().
                 findAll { GraphTraversal.class.equals(it.returnType) }.
@@ -202,44 +204,24 @@ class GraphTraversalSourceGenerator {
                 forEach { method ->
                     moduleOutput.append(
                             """
-  /**
-   * ${method}() static method
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  statics.${method} = function (args) {
-    var g = new GraphTraversal(null, null, new Bytecode());
-    return g.${method}.apply(g, arguments);
-  };
+/**
+ * ${method}() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.${method} = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.${method}.apply(g, arguments);
+};
 """)
                 };
 
         moduleOutput.append("""
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
-      this.__dependencies = this.__dependencies || {};
-      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
-    }
-    throw new Error('No module loader was found');
-  }
-
-  var toExport = {
-    GraphTraversal: GraphTraversal,
-    GraphTraversalSource: GraphTraversalSource,
-    statics: statics
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  // Nashorn and rest
-  return toExport;
-}).call(this);""")
+module.exports = {
+  GraphTraversal: GraphTraversal,
+  GraphTraversalSource: GraphTraversalSource,
+  statics: statics
+};""");
 
         // save to file
         final File file = new File(graphTraversalSourceFile);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
new file mode 100644
index 0000000..4b4d012
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class PackageJsonGenerator {
+
+    public static void create(final String traversalSourceFile, final String version) {
+
+        final StringBuilder moduleOutput = new StringBuilder();
+        moduleOutput.append("""{
+  "name": "gremlin-javascript",
+  "version": "${version}",
+  "description": "JavaScript Gremlin Language Variant",
+  "author": "Apache TinkerPop team",
+  "keywords": [
+    "graph",
+    "gremlin",
+    "tinkerpop",
+    "connection",
+    "glv",
+    "driver",
+    "graphdb"
+  ],
+  "license": "Apache-2.0",
+  "dependencies": {
+    "ws": "^3.0.0"
+  },
+  "devDependencies": {
+    "mocha": ">= 1.14.0"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/tinkerpop.git"
+  },
+  "bugs": {
+    "url": "https://issues.apache.org/jira/browse/TINKERPOP"
+  },
+  "scripts": {
+    "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+    "unit-test": "./node_modules/.bin/mocha test/unit"
+  },
+  "engines": {
+    "node": ">=4"
+  }
+}"""    );
+
+        // save to a file
+        final File file = new File(traversalSourceFile);
+        file.delete()
+        moduleOutput.eachLine { file.append(it + "\n") }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
new file mode 100644
index 0000000..ed45cdb
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+/**
+ * @author Jorge Bay Gondra
+ */
+public final class SymbolHelper {
+
+    private final static Map<String, String> TO_JS_MAP = new HashMap<>();
+
+    static {
+        TO_JS_MAP.put("in", "in_");
+        TO_JS_MAP.put("from", "from_");
+    }
+
+    private SymbolHelper() {
+        // static methods only, do not instantiate
+    }
+
+    public static String toJs(final String symbol) {
+        return TO_JS_MAP.getOrDefault(symbol, symbol);
+    }
+
+    public static String decapitalize(String string) {
+        if (string == null || string.length() == 0) {
+            return string;
+        }
+        def c = string.toCharArray();
+        c[0] = Character.toLowerCase(c[0]);
+        return new String(c);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index d5899f0..f3405c3 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.javascript
 
 import org.apache.tinkerpop.gremlin.process.traversal.P
 import org.apache.tinkerpop.gremlin.util.CoreImports
-import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
 
 import java.lang.reflect.Modifier
 
@@ -57,334 +56,178 @@ class TraversalSourceGenerator {
 /**
  * @author Jorge Bay Gondra
  */
-(function defineTraversalModule() {
-  "use strict";
-
-  function Traversal(graph, traversalStrategies, bytecode) {
-    this.graph = graph;
-    this.traversalStrategies = traversalStrategies;
-    this.bytecode = bytecode;
-    this.traversers = null;
-    this.sideEffects = null;
-  }
+'use strict';
+
+var utils = require('../utils');
+var parseArgs = utils.parseArgs;
+var itemDone = Object.freeze({ value: null, done: true });
+var emptyArray = Object.freeze([]);
+
+function Traversal(graph, traversalStrategies, bytecode) {
+  this.graph = graph;
+  this.traversalStrategies = traversalStrategies;
+  this.bytecode = bytecode;
+  this.traversers = null;
+  this.sideEffects = null;
+  this._traversalStrategiesPromise = null;
+  this._traversersIteratorIndex = 0;
+}
 
-  /** @returns {Bytecode} */
-  Traversal.prototype.getBytecode = function () {
-    return this.bytecode;
-  };
+/** @returns {Bytecode} */
+Traversal.prototype.getBytecode = function () {
+  return this.bytecode;
+};
 
-  /** @param {Function} callback */
-  Traversal.prototype.list = function (callback) {
-    var self = this;
-    this.traversalStrategies.applyStrategies(this, function (err) {
-      if (err) {
-        return callback(err);
-      }
-      callback(err, self.traversers);
-    });
-  };
+/**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+Traversal.prototype.toList = function () {
+  var self = this;
+  return this._applyStrategies().then(function () {
+    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+      return emptyArray;
+    }
+    var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
+    for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
+      arr[i] = self.traversers[i].object;
+    }
+    self._traversersIteratorIndex = self.traversers.length;
+    return arr;
+  });
+};
 
-  /** @param {Function} callback */
-  Traversal.prototype.one = function (callback) {
-    this.list(function (err, result) {
-      callback(err, result && result.length > 0 ? result[0] : null);
-    });
-  };
+/**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+Traversal.prototype.next = function () {
+  var self = this;
+  return this._applyStrategies().then(function () {
+    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+      return itemDone;
+    }
+    return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
+  });
+};
+
+Traversal.prototype._applyStrategies = function () {
+  if (this._traversalStrategiesPromise) {
+    // Apply strategies only once
+    return this._traversalStrategiesPromise;
+  }
+  return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+};
 
-  /**
-   * Returns the Bytecode JSON representation of the traversal
-   * @returns {String}
-   */
-  Traversal.prototype.toString = function () {
-    return this.bytecode.toString();
-  };
+/**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+Traversal.prototype.toString = function () {
+  return this.bytecode.toString();
+};
   """);
 
         moduleOutput.append("""
-  /**
-   * Represents an operation.
-   * @constructor
-   */
-  function P(operator, value, other) {
-    this.operator = operator;
-    this.value = value;
-    this.other = other;
-  }
-
-  /**
-   * Returns the string representation of the instance.
-   * @returns {string}
-   */
-  P.prototype.toString = function () {
-    if (this.other === undefined) {
-      return this.operator + '(' + this.value + ')';
-    }
-    return this.operator + '(' + this.value + ', ' + this.other + ')';
-  };
+/**
+ * Represents an operation.
+ * @constructor
+ */
+function P(operator, value, other) {
+  this.operator = operator;
+  this.value = value;
+  this.other = other;
+}
 
-  function createP(operator, args) {
-    args.unshift(null, operator);
-    return new (Function.prototype.bind.apply(P, args));
+/**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+P.prototype.toString = function () {
+  if (this.other === undefined) {
+    return this.operator + '(' + this.value + ')';
   }
+  return this.operator + '(' + this.value + ', ' + this.other + ')';
+};
+
+function createP(operator, args) {
+  args.unshift(null, operator);
+  return new (Function.prototype.bind.apply(P, args));
+}
 """)
         P.class.getMethods().
                 findAll { Modifier.isStatic(it.getModifiers()) }.
                 findAll { P.class.isAssignableFrom(it.returnType) }.
-                collect { SymbolHelper.toJs(it.name) }.
+                collect { it.name }.
                 unique().
                 sort { a, b -> a <=> b }.
-                each { method ->
+                each { methodName ->
                     moduleOutput.append(
                             """
-  /** @param {...Object} args */
-  P.${method} = function (args) {
-    return createP('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
-  };
+/** @param {...Object} args */
+P.${SymbolHelper.toJs(methodName)} = function (args) {
+  return createP('$methodName', parseArgs.apply(null, arguments));
+};
 """)
                 };
         moduleOutput.append("""
-  P.prototype.and = function (arg) {
-    return new P('and', this, arg);
-  };
+P.prototype.and = function (arg) {
+  return new P('and', this, arg);
+};
 
-  P.prototype.or = function (arg) {
-    return new P('or', this, arg);
-  };
+P.prototype.or = function (arg) {
+  return new P('or', this, arg);
+};
 """)
 
         moduleOutput.append("""
-  function Traverser(object, bulk) {
-    this.object = object;
-    this.bulk = bulk == undefined ? 1 : bulk;
-  }
-
-  function TraversalSideEffects() {
-
-  }
-
-  /**
-   * Creates a new instance of TraversalStrategies.
-   * @param {TraversalStrategies} [traversalStrategies]
-   * @constructor
-   */
-  function TraversalStrategies(traversalStrategies) {
-    /** @type {Array<TraversalStrategy>} */
-    this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
-  }
-
-  /** @param {TraversalStrategy} strategy */
-  TraversalStrategies.prototype.addStrategy = function (strategy) {
-    this.strategies.push(strategy);
-  };
-
-  /**
-   * @param {Traversal} traversal
-   * @param {Function} callback
-   */
-  TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
-    eachSeries(this.strategies, function eachStrategy(s, next) {
-      s.apply(traversal, next);
-    }, callback);
-  };
-
-  /**
-   * @abstract
-   * @constructor
-   */
-  function TraversalStrategy() {
-
-  }
-
-  /**
-   * @abstract
-   * @param {Traversal} traversal
-   * @param {Function} callback
-   */
-  TraversalStrategy.prototype.apply = function (traversal, callback) {
-
-  };
-
-  /**
-   * Creates a new instance of Bytecode
-   * @param {Bytecode} [toClone]
-   * @constructor
-   */
-  function Bytecode(toClone) {
-    this._bindings = {};
-    if (!toClone) {
-      this.sourceInstructions = [];
-      this.stepInstructions = [];
-    }
-    else {
-      this.sourceInstructions = toClone.sourceInstructions.slice(0);
-      this.stepInstructions = toClone.sourceInstructions.slice(0);
-    }
-  }
-
-  /**
-   * Adds a new source instructions
-   * @param {String} name
-   * @param {Array} values
-   * @returns {Bytecode}
-   */
-  Bytecode.prototype.addSource = function (name, values) {
-    if (name === undefined) {
-      throw new Error('Name is not defined');
-    }
-    var instruction = new Array(values.length + 1);
-    instruction[0] = name;
-    for (var i = 0; i < values.length; ++i) {
-      instruction[i + 1] = this._convertToArgument(values[i]);
-    }
-    this.sourceInstructions.push(this._generateInstruction(name, values));
-    return this;
-  };
-
-  /**
-   * Adds a new step instructions
-   * @param {String} name
-   * @param {Array} values
-   * @returns {Bytecode}
-   */
-  Bytecode.prototype.addStep = function (name, values) {
-    if (name === undefined) {
-      throw new Error('Name is not defined');
-    }
-    this.stepInstructions.push(this._generateInstruction(name, values));
-    return this;
-  };
-
-  Bytecode.prototype._generateInstruction = function (name, values) {
-    var instruction = new Array(values.length + 1);
-    instruction[0] = name;
-    for (var i = 0; i < values.length; ++i) {
-      instruction[i + 1] = this._convertToArgument(values[i]);
-    }
-    return instruction;
-  };
-
-  /**
-   * Returns the JSON representation of the source and step instructions
-   * @returns {String}
-   */
-  Bytecode.prototype.toString = function () {
-    return (
-      (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
-      (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
-    );
-  };
-
-  Bytecode.prototype._convertToArgument = function (value) {
-    return value;
-  };
-
-  function toEnum(typeName, keys) {
-    var result = {};
-    keys.split(' ').forEach(function (k) {
-      if (k === k.toUpperCase()) {
-        k = k.toLowerCase();
-      }
-      result[k] = new EnumValue(typeName, k);
-    });
-    return result;
-  }
-
-  function EnumValue(typeName, elementName) {
-    this.typeName = typeName;
-    this.elementName = elementName;
-  }
+function Traverser(object, bulk) {
+  this.object = object;
+  this.bulk = bulk == undefined ? 1 : bulk;
+}
 
-  // Utility functions
-  /** @returns {Array} */
-  function parseArgs() {
-    return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
-  }
+function TraversalSideEffects() {
 
-  /**
-   * @param {Array} arr
-   * @param {Function} fn
-   * @param {Function} [callback]
-   */
-  function eachSeries(arr, fn, callback) {
-    if (!Array.isArray(arr)) {
-      throw new TypeError('First parameter is not an Array');
-    }
-    callback = callback || noop;
-    var length = arr.length;
-    if (length === 0) {
-      return callback();
-    }
-    var sync;
-    var index = 1;
-    fn(arr[0], next);
-    if (sync === undefined) {
-      sync = false;
-    }
+}
 
-    function next(err) {
-      if (err) {
-        return callback(err);
-      }
-      if (index >= length) {
-        return callback();
-      }
-      if (sync === undefined) {
-        sync = true;
-      }
-      if (sync) {
-        return process.nextTick(function () {
-          fn(arr[index++], next);
-        });
-      }
-      fn(arr[index++], next);
+function toEnum(typeName, keys) {
+  var result = {};
+  keys.split(' ').forEach(function (k) {
+    var jsKey = k;
+    if (jsKey === jsKey.toUpperCase()) {
+      jsKey = jsKey.toLowerCase();
     }
-  }
+    result[jsKey] = new EnumValue(typeName, k);
+  });
+  return result;
+}
 
-  function inherits(ctor, superCtor) {
-    ctor.super_ = superCtor;
-    ctor.prototype = Object.create(superCtor.prototype, {
-      constructor: {
-        value: ctor,
-        enumerable: false,
-        writable: true,
-        configurable: true
-      }
-    });
-  }
+function EnumValue(typeName, elementName) {
+  this.typeName = typeName;
+  this.elementName = elementName;
+}
 
-  var toExport = {
-    Bytecode: Bytecode,
-    EnumValue: EnumValue,
-    inherits: inherits,
-    P: P,
-    parseArgs: parseArgs,
-    Traversal: Traversal,
-    TraversalSideEffects: TraversalSideEffects,
-    TraversalStrategies: TraversalStrategies,
-    TraversalStrategy: TraversalStrategy,
-    Traverser: Traverser""")
-        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
-                .findAll { Enum.class.isAssignableFrom(it) }
-                .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
-                .collect()) {
-            moduleOutput.append(",\n    ${SymbolHelper.decapitalize(enumClass.getSimpleName())}: " +
-                    "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
-            enumClass.getEnumConstants()
-                    .sort { a, b -> a.name() <=> b.name() }
-                    .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
-            moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("')")
+module.exports = {
+  EnumValue: EnumValue,
+  P: P,
+  Traversal: Traversal,
+  TraversalSideEffects: TraversalSideEffects,
+  Traverser: Traverser""")
+        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports().
+                findAll { Enum.class.isAssignableFrom(it) }.
+                sort { a, b -> a.simpleName <=> b.simpleName }) {
+            moduleOutput.append(",\n  ${SymbolHelper.decapitalize(enumClass.simpleName)}: " +
+                    "toEnum('${SymbolHelper.toJs(enumClass.simpleName)}', '");
+            moduleOutput.append(
+                enumClass.getEnumConstants().
+                        sort { a, b -> a.name() <=> b.name() }.
+                        collect { SymbolHelper.toJs(it.name()) }.
+                        join(' '));
+            moduleOutput.append("\')");
         }
 
-        moduleOutput.append("""
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  // Nashorn and rest
-  return toExport;
-}).call(this);""")
+        moduleOutput.append("""\n};""");
 
         // save to a file
         final File file = new File(traversalSourceFile);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
deleted file mode 100644
index 1656db4..0000000
--- a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript;
-
-public class GenerateGremlinJavascript {
-
-    private GenerateGremlinJavascript() {
-        // just need the main method
-    }
-
-    public static void main(String[] args) {
-        TraversalSourceGenerator.create(args[0]);
-        GraphTraversalSourceGenerator.create(args[1]);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
deleted file mode 100644
index 535de44..0000000
--- a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript.jsr223;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Jorge Bay Gondra
- */
-public final class SymbolHelper {
-
-    private final static Map<String, String> TO_JS_MAP = new HashMap<>();
-    private final static Map<String, String> FROM_JS_MAP = new HashMap<>();
-
-    static {
-        TO_JS_MAP.put("in", "in_");
-        TO_JS_MAP.put("from", "from_");
-        TO_JS_MAP.forEach((k, v) -> FROM_JS_MAP.put(v, k));
-    }
-
-    private SymbolHelper() {
-        // static methods only, do not instantiate
-    }
-
-    public static String toJs(final String symbol) {
-        return TO_JS_MAP.getOrDefault(symbol, symbol);
-    }
-
-    public static String toJava(final String symbol) {
-        return FROM_JS_MAP.getOrDefault(symbol, symbol);
-    }
-
-    public static String decapitalize(String string) {
-        if (string == null || string.length() == 0) {
-            return string;
-        }
-        char c[] = string.toCharArray();
-        c[0] = Character.toLowerCase(c[0]);
-        return new String(c);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore b/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore
new file mode 100644
index 0000000..4c7120c
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore
@@ -0,0 +1,5 @@
+node_modules/
+.idea/
+npm-debug.log
+# maven plugin com.github.eirslett frontend-maven-plugin installs node.js runtime in "node" folder
+node/
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore b/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore
new file mode 100644
index 0000000..82943d0
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+*.gz
+*.tgz
+test/
+.DS_Store
+.idea
+node_modules/
+npm-debug.log
+# maven plugin com.github.eirslett frontend-maven-plugin installs node.js runtime in "node" folder
+node/
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md b/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md
new file mode 100644
index 0000000..388e175
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md
@@ -0,0 +1,39 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+# JavaScript Gremlin Language Variant
+
+[Apache TinkerPopâ„¢][tk] is a graph computing framework for both graph databases (OLTP) and graph analytic systems
+(OLAP). [Gremlin][gremlin] is the graph traversal language of TinkerPop. It can be described as a functional,
+data-flow language that enables users to succinctly express complex traversals on (or queries of) their application's
+property graph.
+
+Gremlin-Javascript implements Gremlin within the JavaScript language and can be used on Node.js.
+
+```bash
+npm install gremlin-javascript
+```
+
+Please see the [reference documentation][docs] at Apache TinkerPop for more information.
+
+[tk]: http://tinkerpop.apache.org
+[gremlin]: http://tinkerpop.apache.org/gremlin.html
+[docs]: http://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
deleted file mode 100644
index e19b537..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineRemoteConnectionModule() {
-  "use strict";
-
-  var t = loadModule.call(this, '../process/traversal.js');
-  var inherits = t.inherits;
-
-  function RemoteConnection(url, traversalSource) {
-    this.url = url;
-    this.traversalSource = traversalSource;
-  }
-
-  /**
-   * @abstract
-   * @param {Bytecode} bytecode
-   * @param {Function} callback
-   */
-  RemoteConnection.prototype.submit = function (bytecode, callback) {
-    throw new Error('submit() needs to be implemented');
-  };
-
-  /**
-   * @extends {Traversal}
-   * @constructor
-   */
-  function RemoteTraversal(traversers, sideEffects) {
-    t.Traversal.call(this, null, null, null);
-    this.traversers = traversers;
-    this.sideEffects = sideEffects;
-  }
-
-  inherits(RemoteTraversal, t.Traversal);
-
-  /**
-   *
-   * @param {RemoteConnection} connection
-   * @extends {TraversalStrategy}
-   * @constructor
-   */
-  function RemoteStrategy(connection) {
-    t.TraversalStrategy.call(this);
-    this.connection = connection;
-  }
-
-  inherits(RemoteStrategy, t.TraversalStrategy);
-
-  /** @override */
-  RemoteStrategy.prototype.apply = function (traversal, callback) {
-    if (traversal.traversers) {
-      return callback();
-    }
-    this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
-      if (err) {
-        return callback(err);
-      }
-      traversal.sideEffects = remoteTraversal.sideEffects;
-      traversal.traversers = remoteTraversal.traversers;
-      callback();
-    });
-  };
-
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
-      this.__dependencies = this.__dependencies || {};
-      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
-    }
-    throw new Error('No module loader was found');
-  }
-
-  var toExport = {
-    RemoteConnection: RemoteConnection,
-    RemoteStrategy: RemoteStrategy,
-    RemoteTraversal: RemoteTraversal
-  };
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
-  }
-  // Nashorn and rest
-  return toExport;
-}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index ddcdac2..600ac53 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -20,73 +20,54 @@
 /**
  * @author Jorge Bay Gondra
  */
-(function exportModule() {
-  "use strict";
+'use strict';
 
-  function loadModule(moduleName) {
-    if (typeof require !== 'undefined') {
-      return require(moduleName);
-    }
-    if (typeof load !== 'undefined') {
-      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
-      this.__dependencies = this.__dependencies || {};
-      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
-    }
-    throw new Error('No module loader was found');
-  }
+var t = require('./lib/process/traversal');
+var gt = require('./lib/process/graph-traversal');
+var strategiesModule = require('./lib/process/traversal-strategy');
+var graph = require('./lib/structure/graph');
+var gs = require('./lib/structure/io/graph-serializer');
+var rc = require('./lib/driver/remote-connection');
+var Bytecode = require('./lib/process/bytecode');
 
-  var t = loadModule.call(this, './process/traversal.js');
-  var gt = loadModule.call(this, './process/graph-traversal.js');
-  var graph = loadModule.call(this, './structure/graph.js');
-  var gs = loadModule.call(this, './structure/io/graph-serializer.js');
-  var rc = loadModule.call(this, './driver/remote-connection.js');
-  var toExport = {
-    driver: {
-      RemoteConnection: rc.RemoteConnection,
-      RemoteStrategy: rc.RemoteStrategy,
-      RemoteTraversal: rc.RemoteTraversal
-    },
-    process: {
-      Bytecode: t.Bytecode,
-      EnumValue: t.EnumValue,
-      P: t.P,
-      Traversal: t.Traversal,
-      TraversalSideEffects: t.TraversalSideEffects,
-      TraversalStrategies: t.TraversalStrategies,
-      TraversalStrategy: t.TraversalStrategy,
-      Traverser: t.Traverser,
-      barrier: t.barrier,
-      cardinality: t.cardinality,
-      column: t.column,
-      direction: t.direction,
-      operator: t.operator,
-      order: t.order,
-      pop: t.pop,
-      scope: t.scope,
-      t: t.t,
-      GraphTraversal: gt.GraphTraversal,
-      GraphTraversalSource: gt.GraphTraversalSource,
-      statics: gt.statics
+module.exports = {
+  driver: {
+    RemoteConnection: rc.RemoteConnection,
+    RemoteStrategy: rc.RemoteStrategy,
+    RemoteTraversal: rc.RemoteTraversal
+  },
+  process: {
+    Bytecode: Bytecode,
+    EnumValue: t.EnumValue,
+    P: t.P,
+    Traversal: t.Traversal,
+    TraversalSideEffects: t.TraversalSideEffects,
+    TraversalStrategies: strategiesModule.TraversalStrategies,
+    TraversalStrategy: strategiesModule.TraversalStrategy,
+    Traverser: t.Traverser,
+    barrier: t.barrier,
+    cardinality: t.cardinality,
+    column: t.column,
+    direction: t.direction,
+    operator: t.operator,
+    order: t.order,
+    pop: t.pop,
+    scope: t.scope,
+    t: t.t,
+    GraphTraversal: gt.GraphTraversal,
+    GraphTraversalSource: gt.GraphTraversalSource,
+    statics: gt.statics
+  },
+  structure: {
+    io: {
+      GraphSONReader: gs.GraphSONReader,
+      GraphSONWriter: gs.GraphSONWriter
     },
-    structure: {
-      io: {
-        GraphSONReader: gs.GraphSONReader,
-        GraphSONWriter: gs.GraphSONWriter
-      },
-      Edge: graph.Edge,
-      Graph: graph.Graph,
-      Path: graph.Path,
-      Property: graph.Property,
-      Vertex: graph.Vertex,
-      VertexProperty: graph.VertexProperty
-    }
-  };
-
-
-  if (typeof module !== 'undefined') {
-    // CommonJS
-    module.exports = toExport;
-    return;
+    Edge: graph.Edge,
+    Graph: graph.Graph,
+    Path: graph.Path,
+    Property: graph.Property,
+    Vertex: graph.Vertex,
+    VertexProperty: graph.VertexProperty
   }
-  return toExport;
-}).call(this);
\ No newline at end of file
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
new file mode 100644
index 0000000..0d6d507
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -0,0 +1,200 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var crypto = require('crypto');
+var WebSocket = require('ws');
+var util = require('util');
+var RemoteConnection = require('./remote-connection').RemoteConnection;
+var utils = require('../utils');
+var serializer = require('../structure/io/graph-serializer');
+var inherits = utils.inherits;
+var mimeType = 'application/vnd.gremlin-v2.0+json';
+var header = String.fromCharCode(mimeType.length) + mimeType;
+var responseStatusCode = {
+  success: 200,
+  noContent: 204,
+  partialContent: 206
+};
+
+/**
+ * Creates a new instance of DriverRemoteConnection.
+ * @param {String} url The resource uri.
+ * @param {Object} [options] The connection options.
+ * @param {Array} [options.ca] Trusted certificates.
+ * @param {String|Array|Buffer} [options.cert] The certificate key.
+ * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
+ * @param {GraphSONReader} [options.reader] The GraphSON2 reader to use.
+ * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
+ * @param {GraphSONWriter} [options.writer] The GraphSON2 writer to use.
+ * @constructor
+ */
+function DriverRemoteConnection(url, options) {
+  options = options || {};
+  this._ws = new WebSocket(url, {
+    ca: options.ca,
+    cert: options.cert,
+    pfx: options.pfx,
+    rejectUnauthorized: options.rejectUnauthorized
+  });
+  var self = this;
+  this._ws.on('open', function opened () {
+    self.isOpen = true;
+    if (self._openCallback) {
+      self._openCallback();
+    }
+  });
+  this._ws.on('message', function incoming (data) {
+    self._handleMessage(data);
+  });
+  // A map containing the request id and the handler
+  this._responseHandlers = {};
+  this._reader = options.reader || new serializer.GraphSONReader();
+  this._writer = options.writer || new serializer.GraphSONWriter();
+  this._openPromise = null;
+  this._openCallback = null;
+  this._closePromise = null;
+  this.isOpen = false;
+}
+
+inherits(DriverRemoteConnection, RemoteConnection);
+
+/**
+ * Opens the connection, if its not already opened.
+ * @returns {Promise}
+ */
+DriverRemoteConnection.prototype.open = function (promiseFactory) {
+  if (this._closePromise) {
+    return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+      callback(new Error('Connection has been closed'));
+    });
+  }
+  if (this._openPromise) {
+    return this._openPromise;
+  }
+  var self = this;
+  return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+    if (self.isOpen) {
+      return callback();
+    }
+    // It will be invoked when opened
+    self._openCallback = callback;
+  });
+};
+
+/** @override */
+DriverRemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
+  var self = this;
+  return this.open().then(function () {
+    return utils.toPromise(promiseFactory, function promiseHandler(callback) {
+      var requestId = getUuid();
+      self._responseHandlers[requestId] = {
+        callback: callback,
+        result: null
+      };
+      var message = bufferFromString(header + JSON.stringify(self._getRequest(requestId, bytecode)));
+      self._ws.send(message);
+    });
+  });
+};
+
+DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
+  return ({
+    'requestId': { '@type': 'g:UUID', '@value': id },
+    'op': 'bytecode',
+    'processor': 'traversal',
+    'args': {
+      'gremlin': this._writer.adaptObject(bytecode),
+      'aliases': { 'g': 'g'}
+    }
+  });
+};
+
+DriverRemoteConnection.prototype._handleMessage = function (data) {
+  var response = this._reader.read(JSON.parse(data.toString()));
+  var handler = this._responseHandlers[response.requestId];
+  if (response.status.code >= 400) {
+    // callback in error
+    return handler.callback(
+      new Error(util.format('Server error: %s (%d)', response.status.message, response.status.code)));
+  }
+  switch (response.status.code) {
+    case responseStatusCode.noContent:
+      return handler.callback(null, { traversers: []});
+    case responseStatusCode.partialContent:
+      handler.result = handler.result || [];
+      handler.result.push.apply(handler.result, response.result.data);
+      break;
+    default:
+      if (handler.result) {
+        handler.result.push.apply(handler.result, response.result.data);
+      }
+      else {
+        handler.result = response.result.data;
+      }
+      return handler.callback(null, { traversers: handler.result });
+  }
+};
+
+/**
+ * Closes the Connection.
+ * @return {Promise}
+ */
+DriverRemoteConnection.prototype.close = function (promiseFactory) {
+  if (this._closePromise) {
+    return this._closePromise;
+  }
+  var self = this;
+  return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+    self._ws.on('close', function () {
+      self.isOpen = false;
+      callback();
+    });
+    self._ws.close();
+  });
+};
+
+function getUuid() {
+  var buffer = crypto.randomBytes(16);
+  //clear the version
+  buffer[6] &= 0x0f;
+  //set the version 4
+  buffer[6] |= 0x40;
+  //clear the variant
+  buffer[8] &= 0x3f;
+  //set the IETF variant
+  buffer[8] |= 0x80;
+  var hex = buffer.toString('hex');
+  return (
+    hex.substr(0, 8) + '-' +
+    hex.substr(8, 4) + '-' +
+    hex.substr(12, 4) + '-' +
+    hex.substr(16, 4) + '-' +
+    hex.substr(20, 12));
+}
+
+var bufferFromString = Buffer.from || function newBuffer(text) {
+  return new Buffer(text, 'utf8');
+};
+
+module.exports = DriverRemoteConnection;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
new file mode 100644
index 0000000..8176c37
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -0,0 +1,84 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('../process/traversal');
+var TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy;
+var utils = require('../utils');
+var inherits = utils.inherits;
+
+function RemoteConnection(url, traversalSource) {
+  this.url = url;
+}
+
+/**
+ * @abstract
+ * @param {Bytecode} bytecode
+ * @param {Function|undefined} promiseFactory
+ * @returns {Promise}
+ */
+RemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
+  throw new Error('submit() was not implemented');
+};
+
+/**
+ * @extends {Traversal}
+ * @constructor
+ */
+function RemoteTraversal(traversers, sideEffects) {
+  t.Traversal.call(this, null, null, null);
+  this.traversers = traversers;
+  this.sideEffects = sideEffects;
+}
+
+inherits(RemoteTraversal, t.Traversal);
+
+/**
+ *
+ * @param {RemoteConnection} connection
+ * @extends {TraversalStrategy}
+ * @constructor
+ */
+function RemoteStrategy(connection) {
+  TraversalStrategy.call(this);
+  this.connection = connection;
+}
+
+inherits(RemoteStrategy, TraversalStrategy);
+
+/** @override */
+RemoteStrategy.prototype.apply = function (traversal, promiseFactory) {
+  if (traversal.traversers) {
+    return utils.resolvedPromise(promiseFactory);
+  }
+  return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) {
+    traversal.sideEffects = remoteTraversal.sideEffects;
+    traversal.traversers = remoteTraversal.traversers;
+  });
+};
+
+module.exports = {
+  RemoteConnection: RemoteConnection,
+  RemoteStrategy: RemoteStrategy,
+  RemoteTraversal: RemoteTraversal
+};

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/19736751/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
new file mode 100644
index 0000000..9256e6a
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
@@ -0,0 +1,99 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+/**
+ * Creates a new instance of Bytecode
+ * @param {Bytecode} [toClone]
+ * @constructor
+ */
+function Bytecode(toClone) {
+  if (!toClone) {
+    this.sourceInstructions = [];
+    this.stepInstructions = [];
+  }
+  else {
+    this.sourceInstructions = toClone.sourceInstructions.slice(0);
+    this.stepInstructions = toClone.sourceInstructions.slice(0);
+  }
+}
+
+/**
+ * Adds a new source instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+Bytecode.prototype.addSource = function (name, values) {
+  if (name === undefined) {
+    throw new Error('Name is not defined');
+  }
+  var instruction = new Array(values.length + 1);
+  instruction[0] = name;
+  for (var i = 0; i < values.length; ++i) {
+    instruction[i + 1] = this._convertToArgument(values[i]);
+  }
+  this.sourceInstructions.push(this._generateInstruction(name, values));
+  return this;
+};
+
+/**
+ * Adds a new step instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+Bytecode.prototype.addStep = function (name, values) {
+  if (name === undefined) {
+    throw new Error('Name is not defined');
+  }
+  this.stepInstructions.push(this._generateInstruction(name, values));
+  return this;
+};
+
+Bytecode.prototype._generateInstruction = function (name, values) {
+  var length = (values ? values.length : 0) + 1;
+  var instruction = new Array(length);
+  instruction[0] = name;
+  for (var i = 1; i < length; i++) {
+    instruction[i] = this._convertToArgument(values[i - 1]);
+  }
+  return instruction;
+};
+
+/**
+ * Returns the JSON representation of the source and step instructions
+ * @returns {String}
+ */
+Bytecode.prototype.toString = function () {
+  return (
+    (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+    (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
+  );
+};
+
+Bytecode.prototype._convertToArgument = function (value) {
+  return value;
+};
+
+module.exports = Bytecode;
\ No newline at end of file


[47/47] tinkerpop git commit: Include T deserializer

Posted by jo...@apache.org.
Include T deserializer


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/bf43cdc5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/bf43cdc5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/bf43cdc5

Branch: refs/heads/TINKERPOP-1489
Commit: bf43cdc5798a6a7bf6e00e3932b76c3d4b1f47a6
Parents: 343ddc2
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Jan 17 16:52:05 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:52:05 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/TraversalSource.template               | 4 ++++
 .../javascript/gremlin-javascript/lib/process/traversal.js    | 4 ++++
 .../gremlin-javascript/lib/structure/io/graph-serializer.js   | 3 ++-
 .../gremlin-javascript/lib/structure/io/type-serializers.js   | 7 +++++++
 4 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bf43cdc5/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index d707a42..3f289e4 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -182,6 +182,10 @@ class EnumValue {
     this.typeName = typeName;
     this.elementName = elementName;
   }
+
+  toString() {
+    return this.elementName;
+  }
 }
 
 module.exports = {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bf43cdc5/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 2877f02..a8d066a 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -242,6 +242,10 @@ class EnumValue {
     this.typeName = typeName;
     this.elementName = elementName;
   }
+
+  toString() {
+    return this.elementName;
+  }
 }
 
 module.exports = {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bf43cdc5/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index 3dbd340..df05659 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -159,7 +159,8 @@ const deserializers = {
   'g:Edge': typeSerializers.EdgeSerializer,
   'g:VertexProperty': typeSerializers.VertexPropertySerializer,
   'g:Property': typeSerializers.PropertySerializer,
-  'g:Path': typeSerializers.PathSerializer
+  'g:Path': typeSerializers.PathSerializer,
+  'g:T': typeSerializers.TSerializer
 };
 
 const serializers = [

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bf43cdc5/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
index d6f131c..304888f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
@@ -270,6 +270,12 @@ class PathSerializer extends TypeSerializer {
   }
 }
 
+class TSerializer extends TypeSerializer {
+  deserialize(obj) {
+    return t.t[obj[valueKey]];
+  }
+}
+
 module.exports = {
   BytecodeSerializer,
   EdgeSerializer,
@@ -280,6 +286,7 @@ module.exports = {
   PathSerializer,
   PropertySerializer,
   PSerializer,
+  TSerializer,
   TraverserSerializer,
   typeKey,
   valueKey,


[33/47] tinkerpop git commit: Parse maps and mark scenarios with lambdas as skipped

Posted by jo...@apache.org.
Parse maps and mark scenarios with lambdas as skipped


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ee684b54
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ee684b54
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ee684b54

Branch: refs/heads/TINKERPOP-1489
Commit: ee684b54622c2ceaff0841b7bfd0e182d8a71025
Parents: f6721d0
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Nov 27 14:42:26 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:21 2018 +0100

----------------------------------------------------------------------
 .../test/cucumber/feature-steps.js              | 84 ++++++++++++++++++--
 .../gremlin-javascript/test/cucumber/world.js   |  2 +-
 2 files changed, 78 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee684b54/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 6625f29..8ec2bdc 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -25,6 +25,7 @@
 const defineSupportCode = require('cucumber').defineSupportCode;
 const vm = require('vm');
 const expect = require('chai').expect;
+const util = require('util');
 const graphModule = require('../../lib/structure/graph');
 const graphTraversalModule = require('../../lib/process/graph-traversal');
 const traversalModule = require('../../lib/process/traversal');
@@ -32,6 +33,10 @@ const Graph = graphModule.Graph;
 const Path = graphModule.Path;
 const __ = graphTraversalModule.statics;
 
+// Determines whether the feature maps (m[]), are deserialized as objects (true) or maps (false).
+// Use false for GraphSON3.
+const mapAsObject = true;
+
 const parsers = [
   [ 'd\\[([\\d.]+)\\]\\.[ilfdm]', toNumeric ],
   [ 'v\\[(.+)\\]', toVertex ],
@@ -69,6 +74,8 @@ defineSupportCode(function(methods) {
   });
 
   methods.Given(/^using the parameter (.+) defined as "(.+)"$/, function (paramName, stringValue) {
+    // Remove escaped chars
+    stringValue = stringValue.replace(/\\"/g, '"');
     let p = Promise.resolve();
     if (this.graphName === 'empty') {
       p = this.loadEmptyGraphData();
@@ -76,6 +83,11 @@ defineSupportCode(function(methods) {
     const self = this;
     return p.then(() => {
       self.parameters[paramName] = parseValue.call(self, stringValue);
+    }).catch(err => {
+      if (err instanceof IgnoreError) {
+        return 'skipped';
+      }
+      throw err;
     });
   });
 
@@ -98,14 +110,14 @@ defineSupportCode(function(methods) {
     const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
     switch (characterizedAs) {
       case 'ordered':
-        console.log('--- ordered', expectedResult);
         expect(this.result).to.have.deep.ordered.members(expectedResult);
         break;
       case 'unordered':
-        console.log('--- unordered expected:', expectedResult);
-        console.log('--- obtained:', this.result);
         expect(this.result).to.have.deep.members(expectedResult);
         break;
+      case 'of':
+        expect(this.result).to.include.deep.members(expectedResult);
+        break;
     }
   });
 
@@ -117,7 +129,22 @@ defineSupportCode(function(methods) {
   });
 
   methods.Then(/^the result should have a count of (\d+)$/, function (stringCount) {
-    expect(this.result).to.have.lengthOf(parseInt(stringCount, 10));
+    const expected = parseInt(stringCount, 10);
+    if (!Array.isArray(this.result)) {
+      let count = 0;
+      if (this.result instanceof Map) {
+        count = this.result.size;
+      }
+      else if (typeof this.result === 'object') {
+        count = Object.keys(this.result).length;
+      }
+      else {
+        throw new Error('result not supported: ' + util.inspect(this.result));
+      }
+      expect(count).to.be.equal(expected);
+      return;
+    }
+    expect(this.result).to.have.lengthOf(expected);
   });
 
   methods.Then('nothing should happen because', _ => {});
@@ -187,7 +214,11 @@ function toVertexIdString(name) {
 }
 
 function toEdge(name) {
-  return this.getData().edges[name];
+  const e = this.getData().edges[name];
+  if (!e) {
+    throw new Error(util.format('Edge with key "%s" not found', name));
+  }
+  return e;
 }
 
 function toEdgeId(name) {
@@ -210,6 +241,45 @@ function toArray(stringList) {
   return stringList.split(',').map(x => parseValue.call(this, x));
 }
 
-function toMap() {}
+function toMap(stringMap) {
+  return parseMapValue.call(this, JSON.parse(stringMap));
+}
+
+function parseMapValue(value) {
+  if (typeof value === 'string') {
+    return parseValue.call(this, value);
+  }
+  if (Array.isArray(value)) {
+    return value.map(x => parseMapValue.call(this, x));
+  }
+  if (typeof value !== 'object') {
+    return value;
+  }
+  if (mapAsObject) {
+    const result = {};
+    Object.keys(value).forEach(key => {
+      result[key] = parseMapValue.call(this, value[key]);
+    });
+    return result;
+  }
+  const map = new Map();
+  Object.keys(value).forEach(key => {
+    map.set(key, parseMapValue.call(this, value[key]));
+  });
+  return map;
+}
+
+function toLambda() {
+  throw new IgnoreError(IgnoreError.reason.lambdaNotSupported);
+}
+
+function IgnoreError(reason) {
+  Error.call(this, reason);
+  Error.captureStackTrace(this, IgnoreError);
+}
+
+util.inherits(IgnoreError, Error);
 
-function toLambda() {}
\ No newline at end of file
+IgnoreError.reason = {
+  lambdaNotSupported: 'Lambdas are not supported on gremlin-javascript',
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee684b54/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 946d124..03febd1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -104,7 +104,7 @@ function getVertices(connection) {
 function getEdges(connection) {
   const g = new Graph().traversal().withRemote(connection);
   return g.E().group()
-    .by(__.project("o", "l", "i").by(__.outV().values("name")).by(__.inV().values("name")))
+    .by(__.project("o", "l", "i").by(__.outV().values("name")).by(__.label()).by(__.inV().values("name")))
     .by(__.tail())
     .next()
     .then(it => {


[11/47] tinkerpop git commit: TINKERPOP-1489 Cleaned up pom

Posted by jo...@apache.org.
TINKERPOP-1489 Cleaned up pom

Removed some weird characters in license and bumped version to 3.2.5-SNAPSHOT


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b0da2fe1
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b0da2fe1
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b0da2fe1

Branch: refs/heads/TINKERPOP-1489
Commit: b0da2fe15a5eb850535ff56bf0071f2e3234b773
Parents: 8818b57
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 18 12:47:48 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:18 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/pom.xml | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0da2fe1/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 387e628..b9b78cc 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~  Licensed to the Apache Software Foundation (ASF) under one
-  ~  or more contributor license agreements.  See the NOTICE file
-  ~  distributed with this work for additional information
-  ~  regarding copyright ownership.  The ASF licenses this file
-  ~  to you under the Apache License, Version 2.0 (the
-  ~  "License"); you may not use this file except in compliance
-  ~  with the License.  You may obtain a copy of the License at
-  ~
-  ~  http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~  Unless required by applicable law or agreed to in writing,
-  ~  software distributed under the License is distributed on an
-  ~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~  KIND, either express or implied.  See the License for the
-  ~  specific language governing permissions and limitations
-  ~  under the License.
-  -->
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -24,7 +21,7 @@
     <parent>
         <groupId>org.apache.tinkerpop</groupId>
         <artifactId>tinkerpop</artifactId>
-        <version>3.2.3-SNAPSHOT</version>
+        <version>3.2.5-SNAPSHOT</version>
     </parent>
     <artifactId>gremlin-javascript</artifactId>
     <name>Apache TinkerPop :: Gremlin Javascript</name>


[09/47] tinkerpop git commit: Javascript GLV

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
new file mode 100644
index 0000000..d9803ba
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -0,0 +1,2025 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ 
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphTraversalModule() {
+  "use strict";
+
+  var t = loadModule.call(this, './traversal.js');
+  var remote = loadModule.call(this, '../driver/remote-connection.js');
+  var Bytecode = t.Bytecode;
+  var inherits = t.inherits;
+  var parseArgs = t.parseArgs;
+
+  /**
+   *
+   * @param {Graph} graph
+   * @param {TraversalStrategies} traversalStrategies
+   * @param {Bytecode} [bytecode]
+   * @constructor
+   */
+  function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode || new Bytecode();
+  }
+
+  /**
+   * @param remoteConnection
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+    var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+    return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+  };
+
+  /**
+   * Returns the string representation of the GraphTraversalSource.
+   * @returns {string}
+   */
+  GraphTraversalSource.prototype.toString = function () {
+    return 'graphtraversalsource[' + this._graph.toString() + ']';
+  };
+
+  /**
+   * withBulk GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withBulk = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withComputer GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withComputer = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withPath GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withPath = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withSack GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withSack = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withSideEffect GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withSideEffect = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withStrategies GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withStrategies = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * withoutStrategies GraphTraversalSource method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  GraphTraversalSource.prototype.withoutStrategies = function (args) {
+    var b = new Bytecode(this._bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * E GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.E = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('E', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * V GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.V = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('V', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * addV GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.addV = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('addV', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * inject GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversalSource.prototype.inject = function (args) {
+    var b = new Bytecode(this._bytecode).addStep('inject', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+  };
+
+  /**
+   * Represents a graph traversal.
+   * @constructor
+   */
+  function GraphTraversal(graph, traversalStrategies, bytecode) {
+    t.Traversal.call(this, graph, traversalStrategies, bytecode);
+  }
+
+  inherits(GraphTraversal, t.Traversal);
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.V = function (args) {
+    this._bytecode.addStep('V', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addE = function (args) {
+    this._bytecode.addStep('addE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addInE = function (args) {
+    this._bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addOutE = function (args) {
+    this._bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.addV = function (args) {
+    this._bytecode.addStep('addV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.aggregate = function (args) {
+    this._bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.and = function (args) {
+    this._bytecode.addStep('and', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.as = function (args) {
+    this._bytecode.addStep('as', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.barrier = function (args) {
+    this._bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.both = function (args) {
+    this._bytecode.addStep('both', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.bothE = function (args) {
+    this._bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.bothV = function (args) {
+    this._bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.branch = function (args) {
+    this._bytecode.addStep('branch', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.by = function (args) {
+    this._bytecode.addStep('by', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.cap = function (args) {
+    this._bytecode.addStep('cap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.choose = function (args) {
+    this._bytecode.addStep('choose', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.coalesce = function (args) {
+    this._bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.coin = function (args) {
+    this._bytecode.addStep('coin', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.constant = function (args) {
+    this._bytecode.addStep('constant', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.count = function (args) {
+    this._bytecode.addStep('count', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.cyclicPath = function (args) {
+    this._bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.dedup = function (args) {
+    this._bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.drop = function (args) {
+    this._bytecode.addStep('drop', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.emit = function (args) {
+    this._bytecode.addStep('emit', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.filter = function (args) {
+    this._bytecode.addStep('filter', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.flatMap = function (args) {
+    this._bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.fold = function (args) {
+    this._bytecode.addStep('fold', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.from_ = function (args) {
+    this._bytecode.addStep('from', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.group = function (args) {
+    this._bytecode.addStep('group', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.groupCount = function (args) {
+    this._bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.groupV3d0 = function (args) {
+    this._bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.has = function (args) {
+    this._bytecode.addStep('has', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasId = function (args) {
+    this._bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasKey = function (args) {
+    this._bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasLabel = function (args) {
+    this._bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasNot = function (args) {
+    this._bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.hasValue = function (args) {
+    this._bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.id = function (args) {
+    this._bytecode.addStep('id', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.identity = function (args) {
+    this._bytecode.addStep('identity', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.inE = function (args) {
+    this._bytecode.addStep('inE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.inV = function (args) {
+    this._bytecode.addStep('inV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.in_ = function (args) {
+    this._bytecode.addStep('in', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.inject = function (args) {
+    this._bytecode.addStep('inject', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.is = function (args) {
+    this._bytecode.addStep('is', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.key = function (args) {
+    this._bytecode.addStep('key', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.label = function (args) {
+    this._bytecode.addStep('label', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.limit = function (args) {
+    this._bytecode.addStep('limit', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.local = function (args) {
+    this._bytecode.addStep('local', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.loops = function (args) {
+    this._bytecode.addStep('loops', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.map = function (args) {
+    this._bytecode.addStep('map', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.mapKeys = function (args) {
+    this._bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.mapValues = function (args) {
+    this._bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.match = function (args) {
+    this._bytecode.addStep('match', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.max = function (args) {
+    this._bytecode.addStep('max', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.mean = function (args) {
+    this._bytecode.addStep('mean', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.min = function (args) {
+    this._bytecode.addStep('min', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.not = function (args) {
+    this._bytecode.addStep('not', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.option = function (args) {
+    this._bytecode.addStep('option', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.optional = function (args) {
+    this._bytecode.addStep('optional', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.or = function (args) {
+    this._bytecode.addStep('or', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.order = function (args) {
+    this._bytecode.addStep('order', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.otherV = function (args) {
+    this._bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.out = function (args) {
+    this._bytecode.addStep('out', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.outE = function (args) {
+    this._bytecode.addStep('outE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.outV = function (args) {
+    this._bytecode.addStep('outV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.pageRank = function (args) {
+    this._bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.path = function (args) {
+    this._bytecode.addStep('path', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.peerPressure = function (args) {
+    this._bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.profile = function (args) {
+    this._bytecode.addStep('profile', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.program = function (args) {
+    this._bytecode.addStep('program', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.project = function (args) {
+    this._bytecode.addStep('project', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.properties = function (args) {
+    this._bytecode.addStep('properties', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.property = function (args) {
+    this._bytecode.addStep('property', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.propertyMap = function (args) {
+    this._bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.range = function (args) {
+    this._bytecode.addStep('range', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.repeat = function (args) {
+    this._bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sack = function (args) {
+    this._bytecode.addStep('sack', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sample = function (args) {
+    this._bytecode.addStep('sample', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.select = function (args) {
+    this._bytecode.addStep('select', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sideEffect = function (args) {
+    this._bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.simplePath = function (args) {
+    this._bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.store = function (args) {
+    this._bytecode.addStep('store', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.subgraph = function (args) {
+    this._bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.sum = function (args) {
+    this._bytecode.addStep('sum', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.tail = function (args) {
+    this._bytecode.addStep('tail', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.timeLimit = function (args) {
+    this._bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.times = function (args) {
+    this._bytecode.addStep('times', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.to = function (args) {
+    this._bytecode.addStep('to', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.toE = function (args) {
+    this._bytecode.addStep('toE', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.toV = function (args) {
+    this._bytecode.addStep('toV', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.tree = function (args) {
+    this._bytecode.addStep('tree', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.unfold = function (args) {
+    this._bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.union = function (args) {
+    this._bytecode.addStep('union', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.until = function (args) {
+    this._bytecode.addStep('until', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.value = function (args) {
+    this._bytecode.addStep('value', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.valueMap = function (args) {
+    this._bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.values = function (args) {
+    this._bytecode.addStep('values', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  GraphTraversal.prototype.where = function (args) {
+    this._bytecode.addStep('where', parseArgs.apply(null, arguments));
+    return this;
+  };
+
+  /**
+   * Contains the static method definitions
+   * @type {Object}
+   */
+  var statics = {};
+
+  /**
+   * V() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.V = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.V.apply(g, arguments);
+  };
+
+  /**
+   * __() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.__ = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.__.apply(g, arguments);
+  };
+
+  /**
+   * addE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addE.apply(g, arguments);
+  };
+
+  /**
+   * addInE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addInE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addInE.apply(g, arguments);
+  };
+
+  /**
+   * addOutE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addOutE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addOutE.apply(g, arguments);
+  };
+
+  /**
+   * addV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.addV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.addV.apply(g, arguments);
+  };
+
+  /**
+   * aggregate() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.aggregate = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.aggregate.apply(g, arguments);
+  };
+
+  /**
+   * and() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.and = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.and.apply(g, arguments);
+  };
+
+  /**
+   * as() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.as = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.as.apply(g, arguments);
+  };
+
+  /**
+   * barrier() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.barrier = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.barrier.apply(g, arguments);
+  };
+
+  /**
+   * both() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.both = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.both.apply(g, arguments);
+  };
+
+  /**
+   * bothE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.bothE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.bothE.apply(g, arguments);
+  };
+
+  /**
+   * bothV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.bothV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.bothV.apply(g, arguments);
+  };
+
+  /**
+   * branch() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.branch = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.branch.apply(g, arguments);
+  };
+
+  /**
+   * cap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.cap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.cap.apply(g, arguments);
+  };
+
+  /**
+   * choose() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.choose = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.choose.apply(g, arguments);
+  };
+
+  /**
+   * coalesce() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.coalesce = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.coalesce.apply(g, arguments);
+  };
+
+  /**
+   * coin() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.coin = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.coin.apply(g, arguments);
+  };
+
+  /**
+   * constant() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.constant = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.constant.apply(g, arguments);
+  };
+
+  /**
+   * count() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.count = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.count.apply(g, arguments);
+  };
+
+  /**
+   * cyclicPath() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.cyclicPath = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.cyclicPath.apply(g, arguments);
+  };
+
+  /**
+   * dedup() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.dedup = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.dedup.apply(g, arguments);
+  };
+
+  /**
+   * drop() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.drop = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.drop.apply(g, arguments);
+  };
+
+  /**
+   * emit() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.emit = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.emit.apply(g, arguments);
+  };
+
+  /**
+   * filter() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.filter = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.filter.apply(g, arguments);
+  };
+
+  /**
+   * flatMap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.flatMap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.flatMap.apply(g, arguments);
+  };
+
+  /**
+   * fold() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.fold = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.fold.apply(g, arguments);
+  };
+
+  /**
+   * group() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.group = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.group.apply(g, arguments);
+  };
+
+  /**
+   * groupCount() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.groupCount = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.groupCount.apply(g, arguments);
+  };
+
+  /**
+   * groupV3d0() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.groupV3d0 = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.groupV3d0.apply(g, arguments);
+  };
+
+  /**
+   * has() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.has = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.has.apply(g, arguments);
+  };
+
+  /**
+   * hasId() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasId = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasId.apply(g, arguments);
+  };
+
+  /**
+   * hasKey() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasKey = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasKey.apply(g, arguments);
+  };
+
+  /**
+   * hasLabel() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasLabel = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasLabel.apply(g, arguments);
+  };
+
+  /**
+   * hasNot() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasNot = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasNot.apply(g, arguments);
+  };
+
+  /**
+   * hasValue() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.hasValue = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.hasValue.apply(g, arguments);
+  };
+
+  /**
+   * id() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.id = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.id.apply(g, arguments);
+  };
+
+  /**
+   * identity() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.identity = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.identity.apply(g, arguments);
+  };
+
+  /**
+   * inE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.inE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.inE.apply(g, arguments);
+  };
+
+  /**
+   * inV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.inV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.inV.apply(g, arguments);
+  };
+
+  /**
+   * in_() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.in_ = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.in_.apply(g, arguments);
+  };
+
+  /**
+   * inject() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.inject = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.inject.apply(g, arguments);
+  };
+
+  /**
+   * is() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.is = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.is.apply(g, arguments);
+  };
+
+  /**
+   * key() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.key = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.key.apply(g, arguments);
+  };
+
+  /**
+   * label() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.label = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.label.apply(g, arguments);
+  };
+
+  /**
+   * limit() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.limit = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.limit.apply(g, arguments);
+  };
+
+  /**
+   * local() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.local = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.local.apply(g, arguments);
+  };
+
+  /**
+   * loops() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.loops = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.loops.apply(g, arguments);
+  };
+
+  /**
+   * map() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.map = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.map.apply(g, arguments);
+  };
+
+  /**
+   * mapKeys() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.mapKeys = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.mapKeys.apply(g, arguments);
+  };
+
+  /**
+   * mapValues() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.mapValues = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.mapValues.apply(g, arguments);
+  };
+
+  /**
+   * match() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.match = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.match.apply(g, arguments);
+  };
+
+  /**
+   * max() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.max = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.max.apply(g, arguments);
+  };
+
+  /**
+   * mean() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.mean = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.mean.apply(g, arguments);
+  };
+
+  /**
+   * min() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.min = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.min.apply(g, arguments);
+  };
+
+  /**
+   * not() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.not = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.not.apply(g, arguments);
+  };
+
+  /**
+   * optional() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.optional = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.optional.apply(g, arguments);
+  };
+
+  /**
+   * or() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.or = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.or.apply(g, arguments);
+  };
+
+  /**
+   * order() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.order = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.order.apply(g, arguments);
+  };
+
+  /**
+   * otherV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.otherV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.otherV.apply(g, arguments);
+  };
+
+  /**
+   * out() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.out = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.out.apply(g, arguments);
+  };
+
+  /**
+   * outE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.outE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.outE.apply(g, arguments);
+  };
+
+  /**
+   * outV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.outV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.outV.apply(g, arguments);
+  };
+
+  /**
+   * path() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.path = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.path.apply(g, arguments);
+  };
+
+  /**
+   * project() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.project = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.project.apply(g, arguments);
+  };
+
+  /**
+   * properties() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.properties = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.properties.apply(g, arguments);
+  };
+
+  /**
+   * property() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.property = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.property.apply(g, arguments);
+  };
+
+  /**
+   * propertyMap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.propertyMap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.propertyMap.apply(g, arguments);
+  };
+
+  /**
+   * range() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.range = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.range.apply(g, arguments);
+  };
+
+  /**
+   * repeat() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.repeat = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.repeat.apply(g, arguments);
+  };
+
+  /**
+   * sack() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sack = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sack.apply(g, arguments);
+  };
+
+  /**
+   * sample() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sample = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sample.apply(g, arguments);
+  };
+
+  /**
+   * select() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.select = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.select.apply(g, arguments);
+  };
+
+  /**
+   * sideEffect() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sideEffect = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sideEffect.apply(g, arguments);
+  };
+
+  /**
+   * simplePath() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.simplePath = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.simplePath.apply(g, arguments);
+  };
+
+  /**
+   * start() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.start = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.start.apply(g, arguments);
+  };
+
+  /**
+   * store() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.store = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.store.apply(g, arguments);
+  };
+
+  /**
+   * subgraph() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.subgraph = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.subgraph.apply(g, arguments);
+  };
+
+  /**
+   * sum() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.sum = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.sum.apply(g, arguments);
+  };
+
+  /**
+   * tail() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.tail = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.tail.apply(g, arguments);
+  };
+
+  /**
+   * timeLimit() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.timeLimit = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.timeLimit.apply(g, arguments);
+  };
+
+  /**
+   * times() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.times = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.times.apply(g, arguments);
+  };
+
+  /**
+   * to() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.to = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.to.apply(g, arguments);
+  };
+
+  /**
+   * toE() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.toE = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.toE.apply(g, arguments);
+  };
+
+  /**
+   * toV() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.toV = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.toV.apply(g, arguments);
+  };
+
+  /**
+   * tree() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.tree = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.tree.apply(g, arguments);
+  };
+
+  /**
+   * unfold() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.unfold = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.unfold.apply(g, arguments);
+  };
+
+  /**
+   * union() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.union = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.union.apply(g, arguments);
+  };
+
+  /**
+   * until() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.until = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.until.apply(g, arguments);
+  };
+
+  /**
+   * value() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.value = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.value.apply(g, arguments);
+  };
+
+  /**
+   * valueMap() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.valueMap = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.valueMap.apply(g, arguments);
+  };
+
+  /**
+   * values() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.values = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.values.apply(g, arguments);
+  };
+
+  /**
+   * where() static method
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  statics.where = function (args) {
+    var g = new GraphTraversal(null, null, new Bytecode());
+    return g.where.apply(g, arguments);
+  };
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    GraphTraversal: GraphTraversal,
+    GraphTraversalSource: GraphTraversalSource,
+    statics: statics
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
new file mode 100644
index 0000000..5c9bf6c
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -0,0 +1,395 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTraversalModule() {
+  "use strict";
+
+  function Traversal(graph, traversalStrategies, bytecode) {
+    this._graph = graph;
+    this._traversalStrategies = traversalStrategies;
+    this._bytecode = bytecode;
+    this.traversers = null;
+    this.sideEffects = null;
+  }
+
+  /** @returns {Bytecode} */
+  Traversal.prototype.getBytecode = function () {
+    return this._bytecode;
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.list = function (callback) {
+    var self = this;
+    this._traversalStrategies.applyStrategies(this, function (err) {
+      if (err) {
+        return callback(err);
+      }
+      callback(err, self.traversers);
+    });
+  };
+
+  /** @param {Function} callback */
+  Traversal.prototype.one = function (callback) {
+    this.list(function (err, result) {
+      callback(err, result ? result[0] : null);
+    });
+  };
+
+  /**
+   * Returns the Bytecode JSON representation of the traversal
+   * @returns {String}
+   */
+  Traversal.prototype.toString = function () {
+    return this._bytecode.toString();
+  };
+  
+  /**
+   * Represents an operation.
+   * @constructor
+   */
+  function P(operator, value, other) {
+    this.operator = operator;
+    this.value = value;
+    this.other = other;
+  }
+
+  /**
+   * Returns the string representation of the instance.
+   * @returns {string}
+   */
+  P.prototype.toString = function () {
+    if (this.other === undefined) {
+      return this.operator + '(' + this.value + ')';
+    }
+    return this.operator + '(' + this.value + ', ' + this.other + ')';
+  };
+
+  function createP(operator, args) {
+    args.unshift(null, operator);
+    return new (Function.prototype.bind.apply(P, args));
+  }
+
+  /** @param {...Object} args */
+  P.between = function (args) {
+    return createP('between', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.eq = function (args) {
+    return createP('eq', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.gt = function (args) {
+    return createP('gt', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.gte = function (args) {
+    return createP('gte', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.inside = function (args) {
+    return createP('inside', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.lt = function (args) {
+    return createP('lt', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.lte = function (args) {
+    return createP('lte', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.neq = function (args) {
+    return createP('neq', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.not = function (args) {
+    return createP('not', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.outside = function (args) {
+    return createP('outside', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.test = function (args) {
+    return createP('test', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.within = function (args) {
+    return createP('within', parseArgs.apply(null, arguments));
+  };
+
+  /** @param {...Object} args */
+  P.without = function (args) {
+    return createP('without', parseArgs.apply(null, arguments));
+  };
+
+  P.prototype.and = function (arg) {
+    return new P('and', this, arg);
+  };
+
+  P.prototype.or = function (arg) {
+    return new P('or', this, arg);
+  };
+
+  function Traverser(object, bulk) {
+    this.object = object;
+    this.bulk = bulk == undefined ? 1 : bulk;
+  }
+
+  function TraversalSideEffects() {
+
+  }
+
+  /**
+   * Creates a new instance of TraversalStrategies.
+   * @param {TraversalStrategies} [traversalStrategies]
+   * @constructor
+   */
+  function TraversalStrategies(traversalStrategies) {
+    /** @type {Array<TraversalStrategy>} */
+    this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
+  }
+
+  /** @param {TraversalStrategy} strategy */
+  TraversalStrategies.prototype.addStrategy = function (strategy) {
+    this.strategies.push(strategy);
+  };
+
+  /** @param {Traversal} traversal */
+  TraversalStrategies.prototype.applyStrategies = function (traversal) {
+    this.strategies.forEach(function eachStrategy(s) {
+      s.apply(traversal);
+    });
+  };
+
+  /**
+   * @abstract
+   * @constructor
+   */
+  function TraversalStrategy() {
+
+  }
+
+  /**
+   * @abstract
+   * @param {Traversal} traversal
+   */
+  TraversalStrategy.prototype.apply = function (traversal) {
+
+  };
+
+  /**
+   * Creates a new instance of Bytecode
+   * @param {Bytecode} [toClone]
+   * @constructor
+   */
+  function Bytecode(toClone) {
+    this._bindings = {};
+    if (!toClone) {
+      this.sourceInstructions = [];
+      this.stepInstructions = [];
+    }
+    else {
+      this.sourceInstructions = toClone.sourceInstructions.slice(0);
+      this.stepInstructions = toClone.sourceInstructions.slice(0);
+    }
+  }
+
+  /**
+   * Adds a new source instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addSource = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    this.sourceInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  /**
+   * Adds a new step instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  Bytecode.prototype.addStep = function (name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    this.stepInstructions.push(this._generateInstruction(name, values));
+    return this;
+  };
+
+  Bytecode.prototype._generateInstruction = function (name, values) {
+    var instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (var i = 0; i < values.length; ++i) {
+      instruction[i + 1] = this._convertToArgument(values[i]);
+    }
+    return instruction;
+  };
+
+  /**
+   * Returns the JSON representation of the source and step instructions
+   * @returns {String}
+   */
+  Bytecode.prototype.toString = function () {
+    return (
+      (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+      (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
+    );
+  };
+
+  Bytecode.prototype._convertToArgument = function (value) {
+    return value;
+  };
+
+  function toEnum(typeName, keys) {
+    var result = {};
+    keys.split(' ').forEach(function (k) {
+      if (k === k.toUpperCase()) {
+        k = k.toLowerCase();
+      }
+      result[k] = new EnumValue(typeName, k);
+    });
+    return result;
+  }
+
+  function EnumValue(typeName, elementName) {
+    this.typeName = typeName;
+    this.elementName = elementName;
+  }
+
+  /**
+   * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
+   */
+  var enums = {};
+  enums.barrier = toEnum('Barrier', 'normSack');
+  enums.cardinality = toEnum('Cardinality', 'list set single');
+  enums.column = toEnum('Column', 'keys values');
+  enums.direction = toEnum('Direction', 'BOTH IN OUT');
+  enums.operator = toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong');
+  enums.order = toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr');
+  enums.pop = toEnum('Pop', 'all first last');
+  enums.scope = toEnum('Scope', 'global local');
+  enums.t = toEnum('T', 'id key label value');
+
+  // Utility functions
+  /** @returns {Array} */
+  function parseArgs() {
+    return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+  }
+
+  /**
+   * @param {Array} arr
+   * @param {Function} fn
+   * @param {Function} [callback]
+   */
+  function eachSeries(arr, fn, callback) {
+    if (!Array.isArray(arr)) {
+      throw new TypeError('First parameter is not an Array');
+    }
+    callback = callback || noop;
+    var length = arr.length;
+    if (length === 0) {
+      return callback();
+    }
+    var sync;
+    var index = 1;
+    fn(arr[0], next);
+    if (sync === undefined) {
+      sync = false;
+    }
+
+    function next(err) {
+      if (err) {
+        return callback(err);
+      }
+      if (index >= length) {
+        return callback();
+      }
+      if (sync === undefined) {
+        sync = true;
+      }
+      if (sync) {
+        return process.nextTick(function () {
+          fn(arr[index++], next);
+        });
+      }
+      fn(arr[index++], next);
+    }
+  }
+
+  function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor;
+    ctor.prototype = Object.create(superCtor.prototype, {
+      constructor: {
+        value: ctor,
+        enumerable: false,
+        writable: true,
+        configurable: true
+      }
+    });
+  }
+
+  var toExport = {
+    Bytecode: Bytecode,
+    EnumValue: EnumValue,
+    inherits: inherits,
+    P: P,
+    parseArgs: parseArgs,
+    Traversal: Traversal,
+    TraversalSideEffects: TraversalSideEffects,
+    TraversalStrategies: TraversalStrategies,
+    TraversalStrategy: TraversalStrategy,
+    Traverser: Traverser
+  };
+  Object.keys(enums).forEach(function (k) {
+    toExport[k] = enums[k];
+  });
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
new file mode 100644
index 0000000..7c48819
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
@@ -0,0 +1,146 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphModule() {
+  "use strict";
+
+  var gt = loadModule.call(this, '../process/graph-traversal.js');
+  var t = loadModule.call(this, '../process/traversal.js');
+  var inherits = t.inherits;
+
+  function Graph() {
+
+  }
+
+  /**
+   * Returns the graph traversal source.
+   * @returns {GraphTraversalSource}
+   */
+  Graph.prototype.traversal = function () {
+    return new gt.GraphTraversalSource(this, new t.TraversalStrategies());
+  };
+
+  Graph.prototype.toString = function () {
+    return 'graph[empty]';
+  };
+
+  function Element(id, label) {
+    this.id = id;
+    this.label = label;
+  }
+
+  /**
+   * Compares this instance to another and determines if they can be considered as equal.
+   * @param {Element} other
+   * @returns {boolean}
+   */
+  Element.prototype.equals = function (other) {
+    return (other instanceof Element) && this.id === other.id;
+  };
+
+  function Vertex(id, label, properties) {
+    Element.call(this, id, label);
+    this.properties = properties;
+  }
+
+  Vertex.prototype.toString = function () {
+    return 'v[' + this.id + ']';
+  };
+
+  inherits(Vertex, Element);
+
+  function Edge(id, outV, label, inV) {
+    Element.call(this, id, label);
+    this.outV = outV;
+    this.inV = inV;
+  }
+
+  inherits(Edge, Element);
+
+  Edge.prototype.toString = function () {
+    return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
+  };
+
+  function VertexProperty(id, label, value) {
+    Element.call(this, id, label);
+    this.value = value;
+    this.key = this.label;
+  }
+
+  inherits(VertexProperty, Element);
+
+  VertexProperty.prototype.toString = function () {
+    return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
+  };
+
+  function Property(key, value) {
+    this.key = key;
+    this.value = value;
+  }
+
+  Property.prototype.toString = function () {
+    return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
+  };
+
+  Property.prototype.equals = function (other) {
+    return (other instanceof Property) && this.key === other.key && this.value === other.value;
+  };
+
+  /**
+   * Represents a walk through a graph as defined by a traversal.
+   * @param {Array} labels
+   * @param {Array} objects
+   * @constructor
+   */
+  function Path(labels, objects) {
+    this.labels = labels;
+    this.objects = objects;
+  }
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    Edge: Edge,
+    Graph: Graph,
+    Path: Path,
+    Property: Property,
+    Vertex: Vertex,
+    VertexProperty: VertexProperty
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
new file mode 100644
index 0000000..2dde340
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
@@ -0,0 +1,406 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function graphSerializerModule() {
+  "use strict";
+
+  var t = loadModule.call(this, '../../process/traversal.js');
+  var g = loadModule.call(this, '../graph.js');
+
+  /**
+   * A type serializer
+   * @typedef {Object} Serializer
+   * @property {Function} serialize
+   * @property {Function} deserialize
+   * @property {Function} [canBeUsedFor]
+   */
+
+  /**
+   * @const
+   * @private
+   */
+  var valueKey = '@value';
+
+  /**
+   * @const
+   * @private
+   */
+  var typeKey = '@type';
+
+  var deserializers = {
+    'g:Traverser': TraverserSerializer,
+    'g:Int32':  NumberSerializer,
+    'g:Int64':  NumberSerializer,
+    'g:Float':  NumberSerializer,
+    'g:Double': NumberSerializer,
+    'g:Vertex': VertexSerializer,
+    'g:Edge': EdgeSerializer,
+    'g:VertexProperty': VertexPropertySerializer,
+    'g:Property': PropertySerializer,
+    'g:Path': PathSerializer
+  };
+
+  var serializers = [
+    NumberSerializer,
+    BytecodeSerializer,
+    TraverserSerializer,
+    PSerializer,
+    LambdaSerializer,
+    EnumSerializer
+  ];
+
+  /**
+   * GraphSON Writer
+   * @param {Object} [options]
+   * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
+   * serializer instances as values, ie: { 'g:Int64': longSerializer }.
+   * @constructor
+   */
+  function GraphSONWriter(options) {
+    this._options = options || {};
+    // Create instance of the default serializers
+    this._serializers = serializers.map(function (serializerConstructor) {
+      var s = new serializerConstructor();
+      s.writer = this;
+      return s;
+    }, this);
+    var customSerializers = this._options.serializers || {};
+    Object.keys(customSerializers).forEach(function (key) {
+      var s = customSerializers[key];
+      if (!s.serialize) {
+        return;
+      }
+      s.writer = this;
+      // Insert custom serializers first
+      this._serializers.unshift(s);
+    }, this);
+  }
+
+  GraphSONWriter.prototype.adaptObject = function (value) {
+    var s;
+    if (Array.isArray(value)) {
+      return value.map(function (item) {
+        return this.adaptObject(item);
+      }, this);
+    }
+    for (var i = 0; i < this._serializers.length; i++) {
+      var currentSerializer = this._serializers[i];
+      if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
+        s = currentSerializer;
+        break;
+      }
+    }
+    if (s) {
+      return s.serialize(value);
+    }
+    // Default (strings / objects / ...)
+    return value;
+  };
+
+  /**
+   * Returns the GraphSON representation of the provided object instance.
+   * @param {Object} obj
+   * @returns {String}
+   */
+  GraphSONWriter.prototype.write = function (obj) {
+    return JSON.stringify(this.adaptObject(obj));
+  };
+
+  /**
+   * GraphSON Reader
+   * @param {Object} [options]
+   * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
+   * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
+   * @constructor
+   */
+  function GraphSONReader(options) {
+    this._options = options || {};
+    this._deserializers = {};
+    Object.keys(deserializers).forEach(function (typeName) {
+      var serializerConstructor = deserializers[typeName];
+      var s = new serializerConstructor();
+      s.reader = this;
+      this._deserializers[typeName] = s;
+    }, this);
+    if (this._options.serializers) {
+      var customSerializers = this._options.serializers || {};
+      Object.keys(customSerializers).forEach(function (key) {
+        var s = customSerializers[key];
+        if (!s.deserialize) {
+          return;
+        }
+        s.reader = this;
+        this._deserializers[key] = s;
+      }, this);
+    }
+  }
+
+  GraphSONReader.prototype.read = function (obj) {
+    if (Array.isArray(obj)) {
+      return obj.map(function mapEach(item) {
+        return this.read(item);
+      }, this);
+    }
+    var type = obj[typeKey];
+    if (type) {
+      var d = this._deserializers[type];
+      if (d) {
+        // Use type serializer
+        return d.deserialize(obj);
+      }
+      return obj[valueKey];
+    }
+    if (obj && typeof obj === 'object' && obj.constructor === Object) {
+      return this._deserializeObject(obj);
+    }
+    // Default (for boolean, number and other scalars)
+    return obj;
+  };
+
+  GraphSONReader.prototype._deserializeObject = function (obj) {
+    var keys = Object.keys(obj);
+    var result = {};
+    for (var i = 0; i < keys.length; i++) {
+      result[keys[i]] = this.read(obj[keys[i]]);
+    }
+    return result;
+  };
+
+  function NumberSerializer() {
+
+  }
+
+  NumberSerializer.prototype.serialize = function (item) {
+    return item;
+  };
+
+  NumberSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return parseFloat(value);
+  };
+
+  NumberSerializer.prototype.canBeUsedFor = function (value) {
+    return (typeof value === 'number');
+  };
+
+  function BytecodeSerializer() {
+
+  }
+
+  BytecodeSerializer.prototype.serialize = function (item) {
+    var bytecode = item;
+    if (item instanceof t.Traversal) {
+      bytecode = item.getBytecode();
+    }
+    var result = {};
+    result[typeKey] = 'g:Bytecode';
+    var resultValue = result[valueKey] = {};
+    var sources = this._serializeInstructions(bytecode.sourceInstructions);
+    if (sources) {
+      resultValue['source'] = sources;
+    }
+    var steps = this._serializeInstructions(bytecode.stepInstructions);
+    if (steps) {
+      resultValue['step'] = steps;
+    }
+    return result;
+  };
+
+  BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
+    if (instructions.length === 0) {
+      return null;
+    }
+    var result = new Array(instructions.length);
+    result[0] = instructions[0];
+    for (var i = 1; i < instructions.length; i++) {
+      result[i] = this.writer.adaptObject(instructions[i]);
+    }
+    return result;
+  };
+
+  BytecodeSerializer.prototype.canBeUsedFor = function (value) {
+    return (value instanceof t.Bytecode) || (value instanceof t.Traversal);
+  };
+
+  function PSerializer() {
+
+  }
+
+  /** @param {P} item */
+  PSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:P';
+    var resultValue = result[valueKey] = {
+      'predicate': item.operator
+    };
+    if (item.other == undefined) {
+      resultValue['value'] = this.writer.adaptObject(item.value);
+    }
+    else {
+      resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+    }
+    return result;
+  };
+
+  PSerializer.prototype.canBeUsedFor = function (value) {
+    return (value instanceof t.P);
+  };
+
+  function LambdaSerializer() {
+
+  }
+
+  /** @param {Function} item */
+  LambdaSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:Lambda';
+    result[valueKey] = {
+      'arguments': item.length,
+      'language': 'gremlin-javascript',
+      'script': item.toString()
+    };
+    return result;
+  };
+
+  LambdaSerializer.prototype.canBeUsedFor = function (value) {
+    return (typeof value === 'function');
+  };
+
+  function EnumSerializer() {
+
+  }
+
+  /** @param {EnumValue} item */
+  EnumSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:' + item.typeName;
+    result[valueKey] = item.elementName;
+    return result;
+  };
+
+  EnumSerializer.prototype.canBeUsedFor = function (value) {
+    return value && value.typeName && value instanceof t.EnumValue;
+  };
+
+  function TraverserSerializer() {
+
+  }
+
+  /** @param {Traverser} item */
+  TraverserSerializer.prototype.serialize = function (item) {
+    var result = {};
+    result[typeKey] = 'g:Traverser';
+    result[valueKey] = {
+      'value': this.writer.adaptObject(item.object),
+      'bulk': this.writer.adaptObject(item.bulk)
+    };
+    return result;
+  };
+
+  TraverserSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
+  };
+
+  TraverserSerializer.prototype.canBeUsedFor = function (value) {
+    return (value instanceof t.Traverser);
+  };
+
+  function VertexSerializer() {
+
+  }
+
+  VertexSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
+  };
+
+  function VertexPropertySerializer() {
+
+  }
+
+  VertexPropertySerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.VertexProperty(this.reader.read(value['id']), value['label'], this.reader.read(value['value']));
+  };
+
+  function PropertySerializer() {
+
+  }
+
+  PropertySerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.Property(
+      value['key'],
+      this.reader.read(value['value']));
+  };
+
+  function EdgeSerializer() {
+
+  }
+
+  EdgeSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    return new g.Edge(
+      this.reader.read(value['id']),
+      this.reader.read(value['outV']),
+      value['label'],
+      this.reader.read(value['inV'])
+    );
+  };
+
+  function PathSerializer() {
+
+  }
+
+  PathSerializer.prototype.deserialize = function (obj) {
+    var value = obj[valueKey];
+    var objects = value['objects'].map(function objectMapItem(o) {
+      return this.reader.read(o);
+    }, this);
+    return new g.Path(this.reader.read(value['labels']), objects);
+  };
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  var toExport = {
+    GraphSONWriter: GraphSONWriter,
+    GraphSONReader: GraphSONReader
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  // Nashorn and rest
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
new file mode 100644
index 0000000..858ed06
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
@@ -0,0 +1,84 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineHelperModule() {
+  "use strict";
+
+  var assert = {
+    ok: function (condition, message) {
+      if (!condition) {
+        throw new AssertError(message || (condition + ' == true'));
+      }
+    },
+    strictEqual: function (val1, val2, message) {
+      if (val1 !== val2) {
+        throw new AssertError(message || (val1 + ' === ' + val2));
+      }
+    }
+  };
+
+  function loadLibModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      moduleName = '../lib/' + moduleName;
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined' && typeof java !== 'undefined') {
+      moduleName = __DIR__ + '../../../main/javascript/gremlin-javascript/' + moduleName;
+      var path = new java.io.File(moduleName).getCanonicalPath();
+      this.__dependencies = this.__dependencies || {};
+      return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+    }
+    throw new Error('No module loader was found');
+  }
+
+  function AssertError(message) {
+    Error.call(this, message);
+    this.stack = (new Error(message)).stack;
+    if (typeof print !== 'undefined') {
+      print(this.stack);
+    }
+  }
+
+  inherits(AssertError, Error);
+
+  function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor;
+    ctor.prototype = Object.create(superCtor.prototype, {
+      constructor: {
+        value: ctor,
+        enumerable: false,
+        writable: true,
+        configurable: true
+      }
+    });
+  }
+  var toExport = {
+    assert: assert,
+    loadLibModule: loadLibModule
+  };
+  if (typeof module !== 'undefined') {
+    // CommonJS
+    module.exports = toExport;
+    return;
+  }
+  return toExport;
+}).call(this);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e768a81/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
new file mode 100644
index 0000000..6edb323
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+  "use strict";
+
+  var helper = loadModule.call(this, './helper.js');
+  var assert = helper.assert;
+  var glvModule = helper.loadLibModule.call(this, './index.js');
+
+  [
+    function testExports() {
+      assert.ok(glvModule);
+
+      assert.ok(glvModule.process);
+      assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
+      assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
+      assert.strictEqual(typeof glvModule.process.inherits, 'function');
+      assert.strictEqual(typeof glvModule.process.P, 'function');
+      assert.strictEqual(typeof glvModule.process.parseArgs, 'function');
+      assert.strictEqual(typeof glvModule.process.Traversal, 'function');
+      assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
+      assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
+      assert.strictEqual(typeof glvModule.process.TraversalStrategy, 'function');
+      assert.strictEqual(typeof glvModule.process.Traverser, 'function');
+      assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
+      assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+      assert.ok(glvModule.process.statics);
+
+      assert.ok(glvModule.structure);
+      assert.ok(glvModule.structure.io);
+      assert.strictEqual(typeof glvModule.structure.io.GraphSONReader, 'function');
+      assert.strictEqual(typeof glvModule.structure.io.GraphSONWriter, 'function');
+      assert.strictEqual(typeof glvModule.structure.Edge, 'function');
+      assert.strictEqual(typeof glvModule.structure.Graph, 'function');
+      assert.strictEqual(typeof glvModule.structure.Path, 'function');
+      assert.strictEqual(typeof glvModule.structure.Property, 'function');
+      assert.strictEqual(typeof glvModule.structure.Vertex, 'function');
+      assert.strictEqual(typeof glvModule.structure.VertexProperty, 'function');
+
+      assert.ok(glvModule.driver);
+      assert.strictEqual(typeof glvModule.driver.RemoteConnection, 'function');
+      assert.strictEqual(typeof glvModule.driver.RemoteStrategy, 'function');
+      assert.strictEqual(typeof glvModule.driver.RemoteTraversal, 'function');
+    }
+  ].forEach(function (testCase) {
+    testCase.call(null);
+  });
+
+  function loadModule(moduleName) {
+    if (typeof require !== 'undefined') {
+      return require(moduleName);
+    }
+    if (typeof load !== 'undefined') {
+      return load(__DIR__ + moduleName);
+    }
+    throw new Error('No module loader was found');
+  }
+}).call(this)
\ No newline at end of file


[24/47] tinkerpop git commit: TINKERPOP-1489 Bump to 3.2.7-SNAPSHOT for gremlin-javascript

Posted by jo...@apache.org.
TINKERPOP-1489 Bump to 3.2.7-SNAPSHOT for gremlin-javascript


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7d15e66f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7d15e66f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7d15e66f

Branch: refs/heads/TINKERPOP-1489
Commit: 7d15e66f5c5e73da0d278a7019840f0a27c9e292
Parents: 14a8821
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 5 10:15:11 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:19 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7d15e66f/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 203e59e..919c87e 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
     <parent>
         <groupId>org.apache.tinkerpop</groupId>
         <artifactId>tinkerpop</artifactId>
-        <version>3.2.6-SNAPSHOT</version>
+        <version>3.2.7-SNAPSHOT</version>
     </parent>
     <artifactId>gremlin-javascript</artifactId>
     <name>Apache TinkerPop :: Gremlin Javascript</name>


[35/47] tinkerpop git commit: Fix Bytecode cloning

Posted by jo...@apache.org.
Fix Bytecode cloning


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7e3d4be8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7e3d4be8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7e3d4be8

Branch: refs/heads/TINKERPOP-1489
Commit: 7e3d4be8dd6fad21b1f2d17ed4bd605900ab65e4
Parents: ee684b5
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 11:02:10 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:21 2018 +0100

----------------------------------------------------------------------
 .../src/main/javascript/gremlin-javascript/lib/process/bytecode.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7e3d4be8/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
index 9256e6a..2909718 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
@@ -34,7 +34,7 @@ function Bytecode(toClone) {
   }
   else {
     this.sourceInstructions = toClone.sourceInstructions.slice(0);
-    this.stepInstructions = toClone.sourceInstructions.slice(0);
+    this.stepInstructions = toClone.stepInstructions.slice(0);
   }
 }
 


[40/47] tinkerpop git commit: Use ES6 syntax

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index d887fe0..2877f02 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -26,202 +26,209 @@ const utils = require('../utils');
 const parseArgs = utils.parseArgs;
 const itemDone = Object.freeze({ value: null, done: true });
 
-function Traversal(graph, traversalStrategies, bytecode) {
-  this.graph = graph;
-  this.traversalStrategies = traversalStrategies;
-  this.bytecode = bytecode;
-  /** @type {Array<Traverser>} */
-  this.traversers = null;
-  this.sideEffects = null;
-  this._traversalStrategiesPromise = null;
-  this._traversersIteratorIndex = 0;
-}
+class Traversal {
+  constructor(graph, traversalStrategies, bytecode) {
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode;
+    /** @type {Array<Traverser>} */
+    this.traversers = null;
+    this.sideEffects = null;
+    this._traversalStrategiesPromise = null;
+    this._traversersIteratorIndex = 0;
+  }
 
-/** @returns {Bytecode} */
-Traversal.prototype.getBytecode = function () {
-  return this.bytecode;
-};
+  /** @returns {Bytecode} */
+  getBytecode() {
+    return this.bytecode;
+  }
 
-/**
- * Returns an Array containing the traverser objects.
- * @returns {Promise.<Array>}
- */
-Traversal.prototype.toList = function () {
-  return this._applyStrategies().then(() => {
-    const result = [];
-    let it;
-    while ((it = this._getNext()) && !it.done) {
-      result.push(it.value);
+  /**
+   * Returns an Array containing the traverser objects.
+   * @returns {Promise.<Array>}
+   */
+  toList() {
+    return this._applyStrategies().then(() => {
+      const result = [];
+      let it;
+      while ((it = this._getNext()) && !it.done) {
+        result.push(it.value);
+      }
+      return result;
+    });
+  };
+
+  /**
+   * Iterates all Traverser instances in the traversal.
+   * @returns {Promise}
+   */
+  iterate() {
+    return this._applyStrategies().then(() => {
+      let it;
+      while ((it = this._getNext()) && !it.done) {
+      }
+    });
+  }
+
+  /**
+   * Async iterator method implementation.
+   * Returns a promise containing an iterator item.
+   * @returns {Promise.<{value, done}>}
+   */
+  next() {
+    return this._applyStrategies().then(() => this._getNext());
+  }
+
+  /**
+   * Synchronous iterator of traversers including
+   * @private
+   */
+  _getNext() {
+    while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+      let traverser = this.traversers[this._traversersIteratorIndex];
+      if (traverser.bulk > 0) {
+        traverser.bulk--;
+        return { value: traverser.object, done: false };
+      }
+      this._traversersIteratorIndex++;
     }
-    return result;
-  });
-};
+    return itemDone;
+  }
 
-/**
- * Iterates all Traverser instances in the traversal.
- * @returns {Promise}
- */
-Traversal.prototype.iterate = function () {
-  return this._applyStrategies().then(() => {
-    let it;
-    while ((it = this._getNext()) && !it.done) {
+  _applyStrategies() {
+    if (this._traversalStrategiesPromise) {
+      // Apply strategies only once
+      return this._traversalStrategiesPromise;
     }
-  });
-};
+    return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+  }
 
-/**
- * Async iterator method implementation.
- * Returns a promise containing an iterator item.
- * @returns {Promise.<{value, done}>}
- */
-Traversal.prototype.next = function () {
-  return this._applyStrategies().then(() => this._getNext());
-};
+  /**
+   * Returns the Bytecode JSON representation of the traversal
+   * @returns {String}
+   */
+  toString() {
+    return this.bytecode.toString();
+  };
+}
 
-/**
- * Synchronous iterator of traversers including
- * @private
- */
-Traversal.prototype._getNext = function () {
-  while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
-    let traverser = this.traversers[this._traversersIteratorIndex];
-    if (traverser.bulk > 0) {
-      traverser.bulk--;
-      return { value: traverser.object, done: false };
+class P {
+  /**
+   * Represents an operation.
+   * @constructor
+   */
+  constructor(operator, value, other) {
+    this.operator = operator;
+    this.value = value;
+    this.other = other;
+  }
+
+  /**
+   * Returns the string representation of the instance.
+   * @returns {string}
+   */
+  toString() {
+    if (this.other === undefined) {
+      return this.operator + '(' + this.value + ')';
     }
-    this._traversersIteratorIndex++;
+    return this.operator + '(' + this.value + ', ' + this.other + ')';
   }
-  return itemDone;
-};
 
-Traversal.prototype._applyStrategies = function () {
-  if (this._traversalStrategiesPromise) {
-    // Apply strategies only once
-    return this._traversalStrategiesPromise;
+  and(arg) {
+    return new P('and', this, arg);
   }
-  return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
-};
 
-/**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
-Traversal.prototype.toString = function () {
-  return this.bytecode.toString();
-};
+  or(arg) {
+    return new P('or', this, arg);
+  }
 
-/**
- * Represents an operation.
- * @constructor
- */
-function P(operator, value, other) {
-  this.operator = operator;
-  this.value = value;
-  this.other = other;
-}
+  /** @param {...Object} args */
+  static between(args) {
+    return createP('between', parseArgs.apply(null, arguments));
+  }
 
-/**
- * Returns the string representation of the instance.
- * @returns {string}
- */
-P.prototype.toString = function () {
-  if (this.other === undefined) {
-    return this.operator + '(' + this.value + ')';
+  /** @param {...Object} args */
+  static eq(args) {
+    return createP('eq', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static gt(args) {
+    return createP('gt', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static gte(args) {
+    return createP('gte', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static inside(args) {
+    return createP('inside', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static lt(args) {
+    return createP('lt', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static lte(args) {
+    return createP('lte', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static neq(args) {
+    return createP('neq', parseArgs.apply(null, arguments));
   }
-  return this.operator + '(' + this.value + ', ' + this.other + ')';
-};
+
+  /** @param {...Object} args */
+  static not(args) {
+    return createP('not', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static outside(args) {
+    return createP('outside', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static test(args) {
+    return createP('test', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static within(args) {
+    return createP('within', parseArgs.apply(null, arguments));
+  }
+
+  /** @param {...Object} args */
+  static without(args) {
+    return createP('without', parseArgs.apply(null, arguments));
+  }
+
+}
 
 function createP(operator, args) {
   args.unshift(null, operator);
   return new (Function.prototype.bind.apply(P, args));
 }
 
-/** @param {...Object} args */
-P.between = function (args) {
-  return createP('between', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.eq = function (args) {
-  return createP('eq', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.gt = function (args) {
-  return createP('gt', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.gte = function (args) {
-  return createP('gte', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.inside = function (args) {
-  return createP('inside', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.lt = function (args) {
-  return createP('lt', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.lte = function (args) {
-  return createP('lte', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.neq = function (args) {
-  return createP('neq', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.not = function (args) {
-  return createP('not', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.outside = function (args) {
-  return createP('outside', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.test = function (args) {
-  return createP('test', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.within = function (args) {
-  return createP('within', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.without = function (args) {
-  return createP('without', parseArgs.apply(null, arguments));
-};
-
-P.prototype.and = function (arg) {
-  return new P('and', this, arg);
-};
-
-P.prototype.or = function (arg) {
-  return new P('or', this, arg);
-};
-
-function Traverser(object, bulk) {
-  this.object = object;
-  this.bulk = bulk || 1;
+class Traverser {
+  constructor(object, bulk) {
+    this.object = object;
+    this.bulk = bulk || 1;
+  }
 }
 
-function TraversalSideEffects() {
+class TraversalSideEffects {
 
 }
 
 function toEnum(typeName, keys) {
-  var result = {};
-  keys.split(' ').forEach(function (k) {
-    var jsKey = k;
+  const result = {};
+  keys.split(' ').forEach(k => {
+    let jsKey = k;
     if (jsKey === jsKey.toUpperCase()) {
       jsKey = jsKey.toLowerCase();
     }
@@ -230,17 +237,19 @@ function toEnum(typeName, keys) {
   return result;
 }
 
-function EnumValue(typeName, elementName) {
-  this.typeName = typeName;
-  this.elementName = elementName;
+class EnumValue {
+  constructor(typeName, elementName) {
+    this.typeName = typeName;
+    this.elementName = elementName;
+  }
 }
 
 module.exports = {
-  EnumValue: EnumValue,
-  P: P,
-  Traversal: Traversal,
-  TraversalSideEffects: TraversalSideEffects,
-  Traverser: Traverser,
+  EnumValue,
+  P,
+  Traversal,
+  TraversalSideEffects,
+  Traverser,
   barrier: toEnum('Barrier', 'normSack'),
   cardinality: toEnum('Cardinality', 'list set single'),
   column: toEnum('Column', 'keys values'),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
index cbb7e2c..2861a50 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -22,120 +22,120 @@
  */
 'use strict';
 
-var gt = require('../process/graph-traversal');
-var TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
-var utils = require('../utils');
-var inherits = utils.inherits;
-
-function Graph() {
+const gt = require('../process/graph-traversal');
+const TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
+
+class Graph {
+  /**
+   * Returns the graph traversal source.
+   * @returns {GraphTraversalSource}
+   */
+  traversal() {
+    return new gt.GraphTraversalSource(this, new TraversalStrategies());
+  }
 
+  toString() {
+    return 'graph[empty]';
+  }
 }
 
-/**
- * Returns the graph traversal source.
- * @returns {GraphTraversalSource}
- */
-Graph.prototype.traversal = function () {
-  return new gt.GraphTraversalSource(this, new TraversalStrategies());
-};
-
-Graph.prototype.toString = function () {
-  return 'graph[empty]';
-};
+class Element {
+  constructor(id, label) {
+    this.id = id;
+    this.label = label;
+  }
 
-function Element(id, label) {
-  this.id = id;
-  this.label = label;
+  /**
+   * Compares this instance to another and determines if they can be considered as equal.
+   * @param {Element} other
+   * @returns {boolean}
+   */
+  equals(other) {
+    return (other instanceof Element) && this.id === other.id;
+  }
 }
 
-/**
- * Compares this instance to another and determines if they can be considered as equal.
- * @param {Element} other
- * @returns {boolean}
- */
-Element.prototype.equals = function (other) {
-  return (other instanceof Element) && this.id === other.id;
-};
+class Vertex extends Element {
+  constructor(id, label, properties) {
+    super(id, label);
+    this.properties = properties;
+  }
 
-function Vertex(id, label, properties) {
-  Element.call(this, id, label);
-  this.properties = properties;
+  toString() {
+    return 'v[' + this.id + ']';
+  }
 }
 
-Vertex.prototype.toString = function () {
-  return 'v[' + this.id + ']';
-};
-
-inherits(Vertex, Element);
-
-function Edge(id, outV, label, inV, properties) {
-  Element.call(this, id, label);
-  this.outV = outV;
-  this.inV = inV;
-  this.properties = {};
-  (function adaptProperties(self) {
+class Edge extends Element {
+  constructor(id, outV, label, inV, properties) {
+    super(id, label);
+    this.outV = outV;
+    this.inV = inV;
+    this.properties = {};
     if (properties) {
-      var keys = Object.keys(properties);
-      for (var i = 0; i < keys.length; i++) {
-        var k = keys[i];
-        self.properties[k] = properties[k].value;
+      const keys = Object.keys(properties);
+      for (let i = 0; i < keys.length; i++) {
+        const k = keys[i];
+        this.properties[k] = properties[k].value;
       }
     }
-  })(this);
-}
-
-inherits(Edge, Element);
-
-Edge.prototype.toString = function () {
-  return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
-};
+  }
 
-function VertexProperty(id, label, value, properties) {
-  Element.call(this, id, label);
-  this.value = value;
-  this.key = this.label;
-  this.properties = properties;
+  toString() {
+    return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
+  }
 }
 
-inherits(VertexProperty, Element);
-
-VertexProperty.prototype.toString = function () {
-  return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
-};
+class VertexProperty extends Element {
+  constructor(id, label, value, properties) {
+    super(id, label);
+    this.value = value;
+    this.key = this.label;
+    this.properties = properties;
+  }
 
-function Property(key, value) {
-  this.key = key;
-  this.value = value;
+  toString() {
+    return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
+  }
 }
 
-Property.prototype.toString = function () {
-  return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
-};
+class Property {
+  constructor(key, value) {
+    this.key = key;
+    this.value = value;
+  }
 
-Property.prototype.equals = function (other) {
-  return (other instanceof Property) && this.key === other.key && this.value === other.value;
-};
+  toString() {
+    return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
+  }
 
-/**
- * Represents a walk through a graph as defined by a traversal.
- * @param {Array} labels
- * @param {Array} objects
- * @constructor
- */
-function Path(labels, objects) {
-  this.labels = labels;
-  this.objects = objects;
+  equals(other) {
+    return (other instanceof Property) && this.key === other.key && this.value === other.value;
+  }
 }
 
-Path.prototype.equals = function (other) {
-  if (!(other instanceof Path)) {
-    return false;
+class Path {
+  /**
+   * Represents a walk through a graph as defined by a traversal.
+   * @param {Array} labels
+   * @param {Array} objects
+   * @constructor
+   */
+  constructor(labels, objects) {
+    this.labels = labels;
+    this.objects = objects;
   }
-  if (other === this) {
-    return true;
+
+  equals(other) {
+    if (!(other instanceof Path)) {
+      return false;
+    }
+    if (other === this) {
+      return true;
+    }
+    return areEqual(this.objects, other.objects) && areEqual(this.labels, other.labels);
   }
-  return areEqual(this.objects, other.objects) && areEqual(this.labels, other.labels);
-};
+}
 
 function areEqual(obj1, obj2) {
   if (obj1 === obj2) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index 8e4ad5e..3dbd340 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -22,430 +22,159 @@
  */
 'use strict';
 
-var t = require('../../process/traversal');
-var Bytecode = require('../../process/bytecode');
-var g = require('../graph');
-var utils = require('../../utils');
-
-/**
- * A type serializer
- * @typedef {Object} Serializer
- * @property {Function} serialize
- * @property {Function} deserialize
- * @property {Function} [canBeUsedFor]
- */
-
-/**
- * @const
- * @private
- */
-var valueKey = '@value';
-
-/**
- * @const
- * @private
- */
-var typeKey = '@type';
-
-var deserializers = {
-  'g:Traverser': TraverserSerializer,
-  'g:Int32':  NumberSerializer,
-  'g:Int64':  NumberSerializer,
-  'g:Float':  NumberSerializer,
-  'g:Double': NumberSerializer,
-  'g:Vertex': VertexSerializer,
-  'g:Edge': EdgeSerializer,
-  'g:VertexProperty': VertexPropertySerializer,
-  'g:Property': PropertySerializer,
-  'g:Path': PathSerializer
-};
-
-var serializers = [
-  NumberSerializer,
-  BytecodeSerializer,
-  TraverserSerializer,
-  PSerializer,
-  LambdaSerializer,
-  EnumSerializer,
-  VertexSerializer,
-  EdgeSerializer,
-  LongSerializer
-];
+const typeSerializers = require('./type-serializers');
 
 /**
  * GraphSON Writer
- * @param {Object} [options]
- * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
- * serializer instances as values, ie: { 'g:Int64': longSerializer }.
- * @constructor
- */
-function GraphSONWriter(options) {
-  this._options = options || {};
-  // Create instance of the default serializers
-  this._serializers = serializers.map(function (serializerConstructor) {
-    var s = new serializerConstructor();
-    s.writer = this;
-    return s;
-  }, this);
-  var customSerializers = this._options.serializers || {};
-  Object.keys(customSerializers).forEach(function (key) {
-    var s = customSerializers[key];
-    if (!s.serialize) {
-      return;
-    }
-    s.writer = this;
-    // Insert custom serializers first
-    this._serializers.unshift(s);
-  }, this);
-}
-
-GraphSONWriter.prototype.adaptObject = function (value) {
-  var s;
-  if (Array.isArray(value)) {
-    return value.map(function (item) {
-      return this.adaptObject(item);
-    }, this);
-  }
-  for (var i = 0; i < this._serializers.length; i++) {
-    var currentSerializer = this._serializers[i];
-    if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
-      s = currentSerializer;
-      break;
-    }
-  }
-  if (s) {
-    return s.serialize(value);
-  }
-  // Default (strings / objects / ...)
-  return value;
-};
-
-/**
- * Returns the GraphSON representation of the provided object instance.
- * @param {Object} obj
- * @returns {String}
  */
-GraphSONWriter.prototype.write = function (obj) {
-  return JSON.stringify(this.adaptObject(obj));
-};
-
-/**
- * GraphSON Reader
- * @param {Object} [options]
- * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
- * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
- * @constructor
- */
-function GraphSONReader(options) {
-  this._options = options || {};
-  this._deserializers = {};
-  Object.keys(deserializers).forEach(function (typeName) {
-    var serializerConstructor = deserializers[typeName];
-    var s = new serializerConstructor();
-    s.reader = this;
-    this._deserializers[typeName] = s;
-  }, this);
-  if (this._options.serializers) {
-    var customSerializers = this._options.serializers || {};
-    Object.keys(customSerializers).forEach(function (key) {
-      var s = customSerializers[key];
-      if (!s.deserialize) {
+class GraphSONWriter {
+  /**
+   * @param {Object} [options]
+   * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
+   * serializer instances as values, ie: { 'g:Int64': longSerializer }.
+   * @constructor
+   */
+  constructor(options) {
+    this._options = options || {};
+    // Create instance of the default serializers
+    this._serializers = serializers.map(serializerConstructor => {
+      const s = new serializerConstructor();
+      s.writer = this;
+      return s;
+    });
+    const customSerializers = this._options.serializers || {};
+    Object.keys(customSerializers).forEach(key => {
+      const s = customSerializers[key];
+      if (!s.serialize) {
         return;
       }
-      s.reader = this;
-      this._deserializers[key] = s;
-    }, this);
+      s.writer = this;
+      // Insert custom serializers first
+      this._serializers.unshift(s);
+    });
   }
-}
 
-GraphSONReader.prototype.read = function (obj) {
-  if (obj === undefined) {
-    return undefined;
-  }
-  if (obj === null) {
-    return null;
-  }
-  if (Array.isArray(obj)) {
-    return obj.map(function mapEach(item) {
-      return this.read(item);
-    }, this);
-  }
-  var type = obj[typeKey];
-  if (type) {
-    var d = this._deserializers[type];
-    if (d) {
-      // Use type serializer
-      return d.deserialize(obj);
+  adaptObject(value) {
+    let s;
+    if (Array.isArray(value)) {
+      return value.map(item => this.adaptObject(item));
     }
-    return obj[valueKey];
-  }
-  if (obj && typeof obj === 'object' && obj.constructor === Object) {
-    return this._deserializeObject(obj);
+    for (let i = 0; i < this._serializers.length; i++) {
+      const currentSerializer = this._serializers[i];
+      if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
+        s = currentSerializer;
+        break;
+      }
+    }
+    if (s) {
+      return s.serialize(value);
+    }
+    // Default (strings / objects / ...)
+    return value;
   }
-  // Default (for boolean, number and other scalars)
-  return obj;
-};
 
-GraphSONReader.prototype._deserializeObject = function (obj) {
-  var keys = Object.keys(obj);
-  var result = {};
-  for (var i = 0; i < keys.length; i++) {
-    result[keys[i]] = this.read(obj[keys[i]]);
+  /**
+   * Returns the GraphSON representation of the provided object instance.
+   * @param {Object} obj
+   * @returns {String}
+   */
+  write(obj) {
+    return JSON.stringify(this.adaptObject(obj));
   }
-  return result;
-};
-
-function NumberSerializer() {
-
-}
-
-NumberSerializer.prototype.serialize = function (item) {
-  return item;
-};
-
-NumberSerializer.prototype.deserialize = function (obj) {
-  var value = obj[valueKey];
-  return parseFloat(value);
-};
-
-NumberSerializer.prototype.canBeUsedFor = function (value) {
-  return (typeof value === 'number');
-};
-
-function LongSerializer() {
-
-}
-
-NumberSerializer.prototype.serialize = function (item) {
-  return {
-    [typeKey]: 'g:Int64',
-    [valueKey]: item.value
-  };
-};
-
-NumberSerializer.prototype.canBeUsedFor = function (value) {
-  return (value instanceof utils.Long);
-};
-
-function BytecodeSerializer() {
-
 }
 
-BytecodeSerializer.prototype.serialize = function (item) {
-  var bytecode = item;
-  if (item instanceof t.Traversal) {
-    bytecode = item.getBytecode();
-  }
-  var result = {};
-  result[typeKey] = 'g:Bytecode';
-  var resultValue = result[valueKey] = {};
-  var sources = this._serializeInstructions(bytecode.sourceInstructions);
-  if (sources) {
-    resultValue['source'] = sources;
-  }
-  var steps = this._serializeInstructions(bytecode.stepInstructions);
-  if (steps) {
-    resultValue['step'] = steps;
+class GraphSONReader {
+  /**
+   * GraphSON Reader
+   * @param {Object} [options]
+   * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
+   * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
+   * @constructor
+   */
+  constructor(options) {
+    this._options = options || {};
+    this._deserializers = {};
+    Object.keys(deserializers).forEach(typeName => {
+      const serializerConstructor = deserializers[typeName];
+      const s = new serializerConstructor();
+      s.reader = this;
+      this._deserializers[typeName] = s;
+    });
+    if (this._options.serializers) {
+      const customSerializers = this._options.serializers || {};
+      Object.keys(customSerializers).forEach(key => {
+        const s = customSerializers[key];
+        if (!s.deserialize) {
+          return;
+        }
+        s.reader = this;
+        this._deserializers[key] = s;
+      });
+    }
   }
-  return result;
-};
 
-BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
-  if (instructions.length === 0) {
-    return null;
-  }
-  var result = new Array(instructions.length);
-  result[0] = instructions[0];
-  for (var i = 0; i < instructions.length; i++) {
-    result[i] = this.writer.adaptObject(instructions[i]);
+  read(obj) {
+    if (obj === undefined) {
+      return undefined;
+    }
+    if (obj === null) {
+      return null;
+    }
+    if (Array.isArray(obj)) {
+      return obj.map(item => this.read(item));
+    }
+    const type = obj[typeSerializers.typeKey];
+    if (type) {
+      const d = this._deserializers[type];
+      if (d) {
+        // Use type serializer
+        return d.deserialize(obj);
+      }
+      return obj[typeSerializers.valueKey];
+    }
+    if (obj && typeof obj === 'object' && obj.constructor === Object) {
+      return this._deserializeObject(obj);
+    }
+    // Default (for boolean, number and other scalars)
+    return obj;
   }
-  return result;
-};
-
-BytecodeSerializer.prototype.canBeUsedFor = function (value) {
-  return (value instanceof Bytecode) || (value instanceof t.Traversal);
-};
-
-function PSerializer() {
 
-}
-
-/** @param {P} item */
-PSerializer.prototype.serialize = function (item) {
-  var result = {};
-  result[typeKey] = 'g:P';
-  var resultValue = result[valueKey] = {
-    'predicate': item.operator
-  };
-  if (item.other === undefined || item.other === null) {
-    resultValue['value'] = this.writer.adaptObject(item.value);
-  }
-  else {
-    resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+  _deserializeObject(obj) {
+    const keys = Object.keys(obj);
+    const result = {};
+    for (let i = 0; i < keys.length; i++) {
+      result[keys[i]] = this.read(obj[keys[i]]);
+    }
+    return result;
   }
-  return result;
-};
-
-PSerializer.prototype.canBeUsedFor = function (value) {
-  return (value instanceof t.P);
-};
-
-function LambdaSerializer() {
-
-}
-
-/** @param {Function} item */
-LambdaSerializer.prototype.serialize = function (item) {
-  var result = {};
-  result[typeKey] = 'g:Lambda';
-  result[valueKey] = {
-    'arguments': item.length,
-    'language': 'gremlin-javascript',
-    'script': item.toString()
-  };
-  return result;
-};
-
-LambdaSerializer.prototype.canBeUsedFor = function (value) {
-  return (typeof value === 'function');
-};
-
-function EnumSerializer() {
-
 }
 
-/** @param {EnumValue} item */
-EnumSerializer.prototype.serialize = function (item) {
-  var result = {};
-  result[typeKey] = 'g:' + item.typeName;
-  result[valueKey] = item.elementName;
-  return result;
-};
-
-EnumSerializer.prototype.canBeUsedFor = function (value) {
-  return value && value.typeName && value instanceof t.EnumValue;
-};
-
-function TraverserSerializer() {
-
-}
-
-/** @param {Traverser} item */
-TraverserSerializer.prototype.serialize = function (item) {
-  var result = {};
-  result[typeKey] = 'g:Traverser';
-  result[valueKey] = {
-    'value': this.writer.adaptObject(item.object),
-    'bulk': this.writer.adaptObject(item.bulk)
-  };
-  return result;
-};
-
-TraverserSerializer.prototype.deserialize = function (obj) {
-  var value = obj[valueKey];
-  return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
-};
-
-TraverserSerializer.prototype.canBeUsedFor = function (value) {
-  return (value instanceof t.Traverser);
-};
-
-function VertexSerializer() {
-
-}
-
-VertexSerializer.prototype.deserialize = function (obj) {
-  var value = obj[valueKey];
-  return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
-};
-
-/** @param {Vertex} item */
-VertexSerializer.prototype.serialize = function (item) {
-  var result = {};
-  result[typeKey] = 'g:Vertex';
-  result[valueKey] = {
-    'id': this.writer.adaptObject(item.id),
-    'label': item.label
-  };
-  return result;
-};
-
-VertexSerializer.prototype.canBeUsedFor = function (value) {
-  return (value instanceof g.Vertex);
-};
-
-function VertexPropertySerializer() {
-
-}
-
-VertexPropertySerializer.prototype.deserialize = function (obj) {
-  var value = obj[valueKey];
-  return new g.VertexProperty(
-    this.reader.read(value['id']),
-    value['label'],
-    this.reader.read(value['value']),
-    this.reader.read(value['properties'])
-  );
-};
-
-function PropertySerializer() {
-
-}
-
-PropertySerializer.prototype.deserialize = function (obj) {
-  var value = obj[valueKey];
-  return new g.Property(
-    value['key'],
-    this.reader.read(value['value']));
-};
-
-function EdgeSerializer() {
-
-}
-
-EdgeSerializer.prototype.deserialize = function (obj) {
-  var value = obj[valueKey];
-  return new g.Edge(
-    this.reader.read(value['id']),
-    this.reader.read(value['outV']),
-    value['label'],
-    this.reader.read(value['inV']),
-    this.reader.read(value['properties'])
-  );
-};
-
-/** @param {Edge} item */
-EdgeSerializer.prototype.serialize = function (item) {
-  var result = {};
-  result[typeKey] = 'g:Edge';
-  result[valueKey] = {
-    'id': this.writer.adaptObject(item.id),
-    'label': item.label,
-    'outV': this.writer.adaptObject(item.outV.id),
-    'outVLabel': item.outV.label,
-    'inV': this.writer.adaptObject(item.inV.id),
-    'inVLabel': item.inV.label
-  };
-  return result;
-};
-
-EdgeSerializer.prototype.canBeUsedFor = function (value) {
-  return (value instanceof g.Edge);
-};
-
-function PathSerializer() {
-
-}
-
-PathSerializer.prototype.deserialize = function (obj) {
-  var value = obj[valueKey];
-  var objects = value['objects'].map(function objectMapItem(o) {
-    return this.reader.read(o);
-  }, this);
-  return new g.Path(this.reader.read(value['labels']), objects);
-};
+const deserializers = {
+  'g:Traverser': typeSerializers.TraverserSerializer,
+  'g:Int32':  typeSerializers.NumberSerializer,
+  'g:Int64':  typeSerializers.NumberSerializer,
+  'g:Float':  typeSerializers.NumberSerializer,
+  'g:Double': typeSerializers.NumberSerializer,
+  'g:Vertex': typeSerializers.VertexSerializer,
+  'g:Edge': typeSerializers.EdgeSerializer,
+  'g:VertexProperty': typeSerializers.VertexPropertySerializer,
+  'g:Property': typeSerializers.PropertySerializer,
+  'g:Path': typeSerializers.PathSerializer
+};
+
+const serializers = [
+  typeSerializers.NumberSerializer,
+  typeSerializers.BytecodeSerializer,
+  typeSerializers.TraverserSerializer,
+  typeSerializers.PSerializer,
+  typeSerializers.LambdaSerializer,
+  typeSerializers.EnumSerializer,
+  typeSerializers.VertexSerializer,
+  typeSerializers.EdgeSerializer,
+  typeSerializers.LongSerializer
+];
 
 module.exports = {
-  GraphSONWriter: GraphSONWriter,
-  GraphSONReader: GraphSONReader
+  GraphSONWriter,
+  GraphSONReader
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
new file mode 100644
index 0000000..d6f131c
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
@@ -0,0 +1,288 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const t = require('../../process/traversal');
+const Bytecode = require('../../process/bytecode');
+const g = require('../graph');
+const utils = require('../../utils');
+
+const valueKey = '@value';
+const typeKey = '@type';
+
+/**
+ * @abstract
+ */
+class TypeSerializer {
+  serialize() {
+    throw new Error('serialize() method not implemented for ' + this.constructor.name);
+  }
+
+  deserialize() {
+    throw new Error('deserialize() method not implemented for ' + this.constructor.name);
+  }
+
+  canBeUsedFor() {
+    throw new Error('canBeUsedFor() method not implemented for ' + this.constructor.name);
+  }
+}
+
+class NumberSerializer extends TypeSerializer {
+  serialize(item) {
+    return item;
+  }
+
+  deserialize(obj) {
+    return parseFloat(obj[valueKey]);
+  }
+
+  canBeUsedFor(value) {
+    return (typeof value === 'number');
+  }
+}
+
+class LongSerializer extends TypeSerializer {
+  serialize(item) {
+    return {
+      [typeKey]: 'g:Int64',
+      [valueKey]: item.value
+    };
+  }
+
+  canBeUsedFor(value) {
+    return (value instanceof utils.Long);
+  }
+}
+
+class BytecodeSerializer extends TypeSerializer {
+  serialize(item) {
+    let bytecode = item;
+    if (item instanceof t.Traversal) {
+      bytecode = item.getBytecode();
+    }
+    const result = {};
+    result[typeKey] = 'g:Bytecode';
+    const resultValue = result[valueKey] = {};
+    const sources = this._serializeInstructions(bytecode.sourceInstructions);
+    if (sources) {
+      resultValue['source'] = sources;
+    }
+    const steps = this._serializeInstructions(bytecode.stepInstructions);
+    if (steps) {
+      resultValue['step'] = steps;
+    }
+    return result;
+  }
+
+  _serializeInstructions(instructions) {
+    if (instructions.length === 0) {
+      return null;
+    }
+    const result = new Array(instructions.length);
+    result[0] = instructions[0];
+    for (let i = 0; i < instructions.length; i++) {
+      result[i] = this.writer.adaptObject(instructions[i]);
+    }
+    return result;
+  }
+
+  canBeUsedFor(value) {
+    return (value instanceof Bytecode) || (value instanceof t.Traversal);
+  }
+}
+
+class PSerializer extends TypeSerializer {
+  /** @param {P} item */
+  serialize(item) {
+    const result = {};
+    result[typeKey] = 'g:P';
+    const resultValue = result[valueKey] = {
+      'predicate': item.operator
+    };
+    if (item.other === undefined || item.other === null) {
+      resultValue['value'] = this.writer.adaptObject(item.value);
+    }
+    else {
+      resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+    }
+    return result;
+  }
+
+  canBeUsedFor(value) {
+    return (value instanceof t.P);
+  }
+}
+
+class LambdaSerializer extends TypeSerializer {
+  /** @param {Function} item */
+  serialize(item) {
+    return {
+      [typeKey]: 'g:Lambda',
+      [valueKey]: {
+        'arguments': item.length,
+        'language': 'gremlin-javascript',
+        'script': item.toString()
+      }
+    };
+  }
+
+  canBeUsedFor(value) {
+    return (typeof value === 'function');
+  }
+}
+
+class EnumSerializer extends TypeSerializer {
+  /** @param {EnumValue} item */
+  serialize(item) {
+    return {
+      [typeKey]: 'g:' + item.typeName,
+      [valueKey]: item.elementName
+    };
+  }
+
+  canBeUsedFor(value) {
+    return value && value.typeName && value instanceof t.EnumValue;
+  }
+}
+
+class TraverserSerializer extends TypeSerializer {
+  /** @param {Traverser} item */
+  serialize(item) {
+    return {
+      [typeKey]: 'g:Traverser',
+      [valueKey]: {
+        'value': this.writer.adaptObject(item.object),
+        'bulk': this.writer.adaptObject(item.bulk)
+      }
+    };
+  }
+
+  deserialize(obj) {
+    const value = obj[valueKey];
+    return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
+  }
+
+  canBeUsedFor(value) {
+    return (value instanceof t.Traverser);
+  }
+}
+
+class VertexSerializer extends TypeSerializer {
+  deserialize(obj) {
+    const value = obj[valueKey];
+    return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
+  }
+
+  /** @param {Vertex} item */
+  serialize(item) {
+    return {
+      [typeKey]: 'g:Vertex',
+      [valueKey]: {
+        'id': this.writer.adaptObject(item.id),
+        'label': item.label
+      }
+    };
+  }
+
+  canBeUsedFor(value) {
+    return (value instanceof g.Vertex);
+  }
+}
+
+class VertexPropertySerializer extends TypeSerializer {
+  deserialize(obj) {
+    const value = obj[valueKey];
+    return new g.VertexProperty(
+      this.reader.read(value['id']),
+      value['label'],
+      this.reader.read(value['value']),
+      this.reader.read(value['properties'])
+    );
+  }
+}
+
+class PropertySerializer extends TypeSerializer {
+  deserialize(obj) {
+    const value = obj[valueKey];
+    return new g.Property(
+      value['key'],
+      this.reader.read(value['value']));
+  }
+}
+
+class EdgeSerializer extends TypeSerializer {
+  deserialize(obj) {
+    const value = obj[valueKey];
+    return new g.Edge(
+      this.reader.read(value['id']),
+      this.reader.read(value['outV']),
+      value['label'],
+      this.reader.read(value['inV']),
+      this.reader.read(value['properties'])
+    );
+  }
+
+  /** @param {Edge} item */
+  serialize(item) {
+    return {
+      [typeKey]: 'g:Edge',
+      [valueKey]: {
+        'id': this.writer.adaptObject(item.id),
+        'label': item.label,
+        'outV': this.writer.adaptObject(item.outV.id),
+        'outVLabel': item.outV.label,
+        'inV': this.writer.adaptObject(item.inV.id),
+        'inVLabel': item.inV.label
+      }
+    };
+  }
+
+  canBeUsedFor(value) {
+    return (value instanceof g.Edge);
+  }
+}
+
+class PathSerializer extends TypeSerializer {
+  deserialize(obj) {
+    const value = obj[valueKey];
+    const objects = value['objects'].map(o => this.reader.read(o));
+    return new g.Path(this.reader.read(value['labels']), objects);
+  }
+}
+
+module.exports = {
+  BytecodeSerializer,
+  EdgeSerializer,
+  EnumSerializer,
+  LambdaSerializer,
+  LongSerializer,
+  NumberSerializer,
+  PathSerializer,
+  PropertySerializer,
+  PSerializer,
+  TraverserSerializer,
+  typeKey,
+  valueKey,
+  VertexPropertySerializer,
+  VertexSerializer
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
index cbaa53e..bf87368 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -22,9 +22,6 @@
  * @author Jorge Bay Gondra
  */
 'use strict';
-var util = require('util');
-
-exports.inherits = util.inherits;
 
 exports.parseArgs = function parseArgs() {
   return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
@@ -56,7 +53,7 @@ exports.resolvedPromise = function (promiseFactory) {
   });
 };
 
-var toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
+const toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
   promiseFactory = promiseFactory || defaultPromiseFactory;
   return promiseFactory(handler);
 };
@@ -65,7 +62,7 @@ exports.toLong = function toLong(value) {
   return new Long(value);
 };
 
-var Long = exports.Long = function Long(value) {
+const Long = exports.Long = function Long(value) {
   if (typeof value !== 'string' && typeof value !== 'number') {
     throw new TypeError('Ty')
   }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
index e4895fe..9e115be 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -27,7 +27,7 @@ const Bytecode = require('../../lib/process/bytecode');
 const graphModule = require('../../lib/structure/graph');
 const helper = require('../helper');
 
-var connection;
+let connection;
 
 describe('DriverRemoteConnection', function () {
   before(function () {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index 7109427..01dde62 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -29,7 +29,7 @@ const Vertex = graphModule.Vertex;
 const utils = require('../../lib/utils');
 const helper = require('../helper');
 
-var connection;
+let connection;
 
 describe('Traversal', function () {
   before(function () {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
index 3864a4a..53b6577 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
@@ -22,8 +22,8 @@
  */
 'use strict';
 
-var assert = require('assert');
-var glvModule = require('../../');
+const assert = require('assert');
+const glvModule = require('../../');
 
 describe('API', function () {
   it('should export fields under process', function () {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
index ed5beb3..8bc7571 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
@@ -22,23 +22,23 @@
  */
 'use strict';
 
-var assert = require('assert');
-var graph = require('../../lib/structure/graph');
-var t = require('../../lib/process/traversal.js');
-var gs = require('../../lib/structure/io/graph-serializer.js');
-var GraphSONReader = gs.GraphSONReader;
-var GraphSONWriter = gs.GraphSONWriter;
-var P = t.P;
+const assert = require('assert');
+const graph = require('../../lib/structure/graph');
+const t = require('../../lib/process/traversal.js');
+const gs = require('../../lib/structure/io/graph-serializer.js');
+const GraphSONReader = gs.GraphSONReader;
+const GraphSONWriter = gs.GraphSONWriter;
+const P = t.P;
 
 describe('GraphSONReader', function () {
   it('should parse GraphSON int32, float and double to Number from GraphSON', function () {
-    var reader = new GraphSONReader();
+    const reader = new GraphSONReader();
     [
       [ 'g:Int32', 31 ],
       [ 'g:Float', 31.3],
       [ 'g:Double', 31.2]
     ].forEach(function (item) {
-      var result = reader.read({
+      const result = reader.read({
         "@type": item[0],
         "@value": item[1]
       });
@@ -47,12 +47,12 @@ describe('GraphSONReader', function () {
     });
   });
   it('should parse vertices from GraphSON', function () {
-    var obj = {
+    const obj = {
       "@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
         "properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],
           "age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
-    var reader = new GraphSONReader(obj);
-    var result = reader.read(obj);
+    const reader = new GraphSONReader(obj);
+    const result = reader.read(obj);
     assert.ok(result instanceof graph.Vertex);
     assert.strictEqual(result.label, 'person');
     assert.strictEqual(typeof result.id, 'number');
@@ -65,7 +65,7 @@ describe('GraphSONReader', function () {
     assert.strictEqual(result.properties['age'][0].value, 29);
   });
   it('should parse paths from GraphSON', function () {
-    var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
+    const obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
       {
         "@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
         "properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},
@@ -79,8 +79,8 @@ describe('GraphSONReader', function () {
           "lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},
             "value":"java","label":"lang"}}]}}},
       "lop"]}};
-    var reader = new GraphSONReader(obj);
-    var result = reader.read(obj);
+    const reader = new GraphSONReader(obj);
+    const result = reader.read(obj);
     assert.ok(result);
     assert.ok(result.objects);
     assert.ok(result.labels);
@@ -93,17 +93,17 @@ describe('GraphSONReader', function () {
 });
 describe('GraphSONWriter', function () {
   it('should write numbers', function () {
-    var writer = new GraphSONWriter();
+    const writer = new GraphSONWriter();
     assert.strictEqual(writer.write(2), '2');
   });
   it('should write boolean values', function () {
-    var writer = new GraphSONWriter();
+    const writer = new GraphSONWriter();
     assert.strictEqual(writer.write(true), 'true');
     assert.strictEqual(writer.write(false), 'false');
   });
   it('should write P', function () {
-    var writer = new GraphSONWriter();
-    var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[
+    const writer = new GraphSONWriter();
+    const expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[
       {"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},
         {"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},
       {"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index 2be504b..9310143 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -33,8 +33,8 @@ describe('Traversal', function () {
 
   describe('#getByteCode()', function () {
     it('should add steps for with a string parameter', function () {
-      var g = new graph.Graph().traversal();
-      var bytecode = g.V().out('created').getBytecode();
+      const g = new graph.Graph().traversal();
+      const bytecode = g.V().out('created').getBytecode();
       assert.ok(bytecode);
       assert.strictEqual(bytecode.sourceInstructions.length, 0);
       assert.strictEqual(bytecode.stepInstructions.length, 2);
@@ -44,8 +44,8 @@ describe('Traversal', function () {
     });
 
     it('should add steps with an enum value', function () {
-      var g = new graph.Graph().traversal();
-      var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
+      const g = new graph.Graph().traversal();
+      const bytecode = g.V().order().by('age', t.order.decr).getBytecode();
       assert.ok(bytecode);
       assert.strictEqual(bytecode.sourceInstructions.length, 0);
       assert.strictEqual(bytecode.stepInstructions.length, 3);
@@ -61,15 +61,15 @@ describe('Traversal', function () {
 
   describe('#next()', function () {
     it('should apply the strategies and return a Promise with the iterator item', function () {
-      var strategyMock = {
+      const strategyMock = {
         apply: function (traversal) {
           traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 1) ];
           return utils.resolvedPromise();
         }
       };
-      var strategies = new TraversalStrategies();
+      const strategies = new TraversalStrategies();
       strategies.addStrategy(strategyMock);
-      var traversal = new t.Traversal(null, strategies, null);
+      const traversal = new t.Traversal(null, strategies, null);
       return traversal.next()
         .then(function (item) {
           assert.strictEqual(item.value, 1);
@@ -125,15 +125,15 @@ describe('Traversal', function () {
   describe('#toList()', function () {
 
     it('should apply the strategies and return a Promise with an array', function () {
-      var strategyMock = {
+      const strategyMock = {
         apply: function (traversal) {
           traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
           return utils.resolvedPromise();
         }
       };
-      var strategies = new TraversalStrategies();
+      const strategies = new TraversalStrategies();
       strategies.addStrategy(strategyMock);
-      var traversal = new t.Traversal(null, strategies, null);
+      const traversal = new t.Traversal(null, strategies, null);
       return traversal.toList().then(function (list) {
         assert.ok(list);
         assert.deepEqual(list, [ 'a', 'b' ]);
@@ -141,15 +141,15 @@ describe('Traversal', function () {
     });
 
     it('should return an empty array when traversers is empty', function () {
-      var strategyMock = {
+      const strategyMock = {
         apply: function (traversal) {
           traversal.traversers = [];
           return utils.resolvedPromise();
         }
       };
-      var strategies = new TraversalStrategies();
+      const strategies = new TraversalStrategies();
       strategies.addStrategy(strategyMock);
-      var traversal = new t.Traversal(null, strategies, null);
+      const traversal = new t.Traversal(null, strategies, null);
       return traversal.toList().then(function (list) {
         assert.ok(Array.isArray(list));
         assert.strictEqual(list.length, 0);


[13/47] tinkerpop git commit: Use null as empty result

Posted by jo...@apache.org.
Use null as empty result


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9d7687f9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9d7687f9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9d7687f9

Branch: refs/heads/TINKERPOP-1489
Commit: 9d7687f9a4ca3d5c498a72a8e824c25d17bffe60
Parents: 0ec3993
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 3 14:34:28 2016 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:18 2018 +0100

----------------------------------------------------------------------
 .../tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy   | 2 +-
 .../src/main/javascript/gremlin-javascript/process/traversal.js    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9d7687f9/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index 46f65a4..d5899f0 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -87,7 +87,7 @@ class TraversalSourceGenerator {
   /** @param {Function} callback */
   Traversal.prototype.one = function (callback) {
     this.list(function (err, result) {
-      callback(err, result ? result[0] : null);
+      callback(err, result && result.length > 0 ? result[0] : null);
     });
   };
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9d7687f9/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index a7a9bb7..f585161 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -50,7 +50,7 @@
   /** @param {Function} callback */
   Traversal.prototype.one = function (callback) {
     this.list(function (err, result) {
-      callback(err, result ? result[0] : null);
+      callback(err, result && result.length > 0 ? result[0] : null);
     });
   };
 


[18/47] tinkerpop git commit: Js GLV: Use Groovy templates for generation

Posted by jo...@apache.org.
Js GLV: Use Groovy templates for generation


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/14a88215
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/14a88215
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/14a88215

Branch: refs/heads/TINKERPOP-1489
Commit: 14a88215814a6490fc94f0654136e8074184b641
Parents: 2ff9c97
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Aug 17 17:28:32 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:19 2018 +0100

----------------------------------------------------------------------
 .../glv/GraphTraversalSource.template           | 127 ++++++++++
 gremlin-javascript/glv/PackageJson.template     |  55 +++++
 gremlin-javascript/glv/TraversalSource.template | 171 +++++++++++++
 gremlin-javascript/pom.xml                      | 131 ++++++++--
 .../javascript/GenerateGremlinJavascript.groovy |  36 ---
 .../GraphTraversalSourceGenerator.groovy        | 231 ------------------
 .../javascript/PackageJsonGenerator.groovy      |  72 ------
 .../gremlin/javascript/SymbolHelper.groovy      |  50 ----
 .../javascript/TraversalSourceGenerator.groovy  | 237 -------------------
 .../lib/process/graph-traversal.js              |  42 +---
 .../gremlin-javascript/lib/process/traversal.js |   6 +-
 .../javascript/gremlin-javascript/package.json  |   2 +-
 12 files changed, 475 insertions(+), 685 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/glv/GraphTraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/GraphTraversalSource.template b/gremlin-javascript/glv/GraphTraversalSource.template
new file mode 100644
index 0000000..e0fb453
--- /dev/null
+++ b/gremlin-javascript/glv/GraphTraversalSource.template
@@ -0,0 +1,127 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('./traversal.js');
+var remote = require('../driver/remote-connection');
+var utils = require('../utils');
+var Bytecode = require('./bytecode');
+var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+var inherits = utils.inherits;
+var parseArgs = utils.parseArgs;
+
+/**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+  this.graph = graph;
+  this.traversalStrategies = traversalStrategies;
+  this.bytecode = bytecode || new Bytecode();
+}
+
+/**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+  var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+  traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+  return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+};
+
+/**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+GraphTraversalSource.prototype.toString = function () {
+  return 'graphtraversalsource[' + this.graph.toString() + ']';
+};
+<% sourceStepMethods.each{ method -> %>
+/**
+ * Graph Traversal Source <%= method %> method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
+  var b = new Bytecode(this.bytecode).addSource('<%= method %>', parseArgs.apply(null, arguments));
+  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+<%
+}
+sourceSpawnMethods.each{ method -> %>
+/**
+ * <%= method %> GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
+  var b = new Bytecode(this.bytecode).addStep('<%= method %>', parseArgs.apply(null, arguments));
+  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+<% } %>
+/**
+ * Represents a graph traversal.
+ * @extends Traversal
+ * @constructor
+ */
+function GraphTraversal(graph, traversalStrategies, bytecode) {
+  t.Traversal.call(this, graph, traversalStrategies, bytecode);
+}
+
+inherits(GraphTraversal, t.Traversal);
+<% graphStepMethods.each{ method -> %>
+/**
+ * Graph traversal <%= method %> method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.<%= toJs.call(method) %> = function (args) {
+  this.bytecode.addStep('<%= method %>', parseArgs.apply(null, arguments));
+  return this;
+};
+<% } %>
+/**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+var statics = {};
+<% anonStepMethods.each{ method -> %>
+/**
+ * <%= method %>() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.<%= toJs.call(method) %> = function (args) {
+  var g = new GraphTraversal(null, null, new Bytecode());
+  return g.<%= toJs.call(method) %>.apply(g, arguments);
+};
+<% } %>
+module.exports = {
+  GraphTraversal: GraphTraversal,
+  GraphTraversalSource: GraphTraversalSource,
+  statics: statics
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
new file mode 100644
index 0000000..f61913f
--- /dev/null
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -0,0 +1,55 @@
+<%
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+%>{
+  "name": "gremlin-javascript",
+  "version": "<%= version %>",
+  "description": "JavaScript Gremlin Language Variant",
+  "author": "Apache TinkerPop team",
+  "keywords": [
+    "graph",
+    "gremlin",
+    "tinkerpop",
+    "connection",
+    "glv",
+    "driver",
+    "graphdb"
+  ],
+  "license": "Apache-2.0",
+  "dependencies": {
+    "ws": "^3.0.0"
+  },
+  "devDependencies": {
+    "mocha": ">= 1.14.0"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/tinkerpop.git"
+  },
+  "bugs": {
+    "url": "https://issues.apache.org/jira/browse/TINKERPOP"
+  },
+  "scripts": {
+    "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+    "unit-test": "./node_modules/.bin/mocha test/unit"
+  },
+  "engines": {
+    "node": ">=4"
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
new file mode 100644
index 0000000..dbb7bc4
--- /dev/null
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -0,0 +1,171 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var utils = require('../utils');
+var parseArgs = utils.parseArgs;
+var itemDone = Object.freeze({ value: null, done: true });
+var emptyArray = Object.freeze([]);
+
+function Traversal(graph, traversalStrategies, bytecode) {
+  this.graph = graph;
+  this.traversalStrategies = traversalStrategies;
+  this.bytecode = bytecode;
+  this.traversers = null;
+  this.sideEffects = null;
+  this._traversalStrategiesPromise = null;
+  this._traversersIteratorIndex = 0;
+}
+
+/** @returns {Bytecode} */
+Traversal.prototype.getBytecode = function () {
+  return this.bytecode;
+};
+
+/**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+Traversal.prototype.toList = function () {
+  var self = this;
+  return this._applyStrategies().then(function () {
+    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+      return emptyArray;
+    }
+    var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
+    for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
+      arr[i] = self.traversers[i].object;
+    }
+    self._traversersIteratorIndex = self.traversers.length;
+    return arr;
+  });
+};
+
+/**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+Traversal.prototype.next = function () {
+  var self = this;
+  return this._applyStrategies().then(function () {
+    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+      return itemDone;
+    }
+    return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
+  });
+};
+
+Traversal.prototype._applyStrategies = function () {
+  if (this._traversalStrategiesPromise) {
+    // Apply strategies only once
+    return this._traversalStrategiesPromise;
+  }
+  return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+};
+
+/**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+Traversal.prototype.toString = function () {
+  return this.bytecode.toString();
+};
+
+/**
+ * Represents an operation.
+ * @constructor
+ */
+function P(operator, value, other) {
+  this.operator = operator;
+  this.value = value;
+  this.other = other;
+}
+
+/**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+P.prototype.toString = function () {
+  if (this.other === undefined) {
+    return this.operator + '(' + this.value + ')';
+  }
+  return this.operator + '(' + this.value + ', ' + this.other + ')';
+};
+
+function createP(operator, args) {
+  args.unshift(null, operator);
+  return new (Function.prototype.bind.apply(P, args));
+}
+<% pmethods.each{ method -> %>
+/** @param {...Object} args */
+P.<%= toJs.call(method) %> = function (args) {
+  return createP('<%= method %>', parseArgs.apply(null, arguments));
+};
+<% } %>
+P.prototype.and = function (arg) {
+  return new P('and', this, arg);
+};
+
+P.prototype.or = function (arg) {
+  return new P('or', this, arg);
+};
+
+function Traverser(object, bulk) {
+  this.object = object;
+  this.bulk = bulk == undefined ? 1 : bulk;
+}
+
+function TraversalSideEffects() {
+
+}
+
+function toEnum(typeName, keys) {
+  var result = {};
+  keys.split(' ').forEach(function (k) {
+    var jsKey = k;
+    if (jsKey === jsKey.toUpperCase()) {
+      jsKey = jsKey.toLowerCase();
+    }
+    result[jsKey] = new EnumValue(typeName, k);
+  });
+  return result;
+}
+
+function EnumValue(typeName, elementName) {
+  this.typeName = typeName;
+  this.elementName = elementName;
+}
+
+module.exports = {
+  EnumValue: EnumValue,
+  P: P,
+  Traversal: Traversal,
+  TraversalSideEffects: TraversalSideEffects,
+  Traverser: Traverser<%
+enums.each{ enumClass ->
+    out.print ",\n  " + decapitalize.call(enumClass.simpleName) + ": toEnum('" + enumClass.simpleName + "', '" +
+        enumClass.getEnumConstants().sort { a, b -> a.name() <=> b.name() }.collect { toJs.call(it.name()) }.join(' ') + "')"
+}
+%>
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 452e183..203e59e 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -31,12 +31,6 @@ limitations under the License.
             <artifactId>gremlin-core</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
         <!-- TESTING -->
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
@@ -72,27 +66,18 @@ limitations under the License.
         <finalName>${project.artifactId}-${project.version}</finalName>
         <plugins>
             <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>exec-maven-plugin</artifactId>
-                <version>1.2.1</version>
-                <executions>
-                    <execution>
-                        <id>generate-javascript</id>
-                        <phase>generate-test-resources</phase>
-                        <goals>
-                            <goal>java</goal>
-                        </goals>
-                        <configuration>
-                            <mainClass>org.apache.tinkerpop.gremlin.javascript.GenerateGremlinJavascript</mainClass>
-                            <arguments>
-                                <argument>${project.version}</argument>
-                                <argument>${basedir}</argument>
-                            </arguments>
-                        </configuration>
-                    </execution>
-                </executions>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-install-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
             </plugin>
             <plugin>
+                <!--
+                Use gmavenplus-plugin to:
+                    - Generate js sources
+                    - Start and stop gremlin server for integration tests
+                -->
                 <groupId>org.codehaus.gmavenplus</groupId>
                 <artifactId>gmavenplus-plugin</artifactId>
                 <dependencies>
@@ -116,6 +101,102 @@ limitations under the License.
                 </dependencies>
                 <executions>
                     <execution>
+                        <id>generate-javascript</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                            <scripts>
+                                <script><![CDATA[
+import org.apache.tinkerpop.gremlin.jsr223.CoreImports
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import java.lang.reflect.Modifier
+
+def toJsMap = ["in": "in_",
+               "from": "from_"]
+
+def toJs = { symbol -> toJsMap.getOrDefault(symbol, symbol) }
+
+def decapitalize = {
+    String string = it;
+    if (string == null || string.length() == 0) {
+        return string;
+    }
+    def c = string.toCharArray();
+    c[0] = Character.toLowerCase(c[0]);
+    return new String(c);
+}
+
+def determineVersion = {
+    def env = System.getenv()
+    def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("JS_RELEASE_VERSION") : '${project.version}'
+    return mavenVersion.replace("-SNAPSHOT", "-alpha1")
+}
+
+def binding = ["enums": CoreImports.getClassImports()
+                                 .findAll { Enum.class.isAssignableFrom(it) }
+                                 .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() },
+               "pmethods": P.class.getMethods().
+                                 findAll { Modifier.isStatic(it.getModifiers()) }.
+                                 findAll { P.class.isAssignableFrom(it.returnType) }.
+                                 collect { it.name }.
+                                 unique().
+                                 sort { a, b -> a <=> b },
+               "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS
+                                        findAll { GraphTraversalSource.class.equals(it.returnType) }.
+                                        findAll {
+                                            !it.name.equals("clone") &&
+                                                    !it.name.equals(TraversalSource.Symbols.withBindings) &&
+                                                    !it.name.equals(TraversalSource.Symbols.withRemote) &&
+                                                    !it.name.equals(TraversalSource.Symbols.withComputer)
+                                        }.
+                                        collect { it.name }.
+                                        unique().
+                                        sort { a, b -> a <=> b },
+               "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS
+                                        findAll { GraphTraversal.class.equals(it.returnType) }.
+                                        collect { it.name }.
+                                        unique().
+                                        sort { a, b -> a <=> b },
+               "graphStepMethods": GraphTraversal.getMethods().
+                                        findAll { GraphTraversal.class.equals(it.returnType) }.
+                                        findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
+                                        collect { it.name }.
+                                        unique().
+                                        sort { a, b -> a <=> b },
+               "anonStepMethods": __.class.getMethods().
+                                        findAll { GraphTraversal.class.equals(it.returnType) }.
+                                        findAll { Modifier.isStatic(it.getModifiers()) }.
+                                        findAll { !it.name.equals("__") && !it.name.equals("start") }.
+                                        collect { it.name }.
+                                        unique().
+                                        sort { a, b -> a <=> b },
+               "toJs": toJs,
+               "version": determineVersion(),
+               "decapitalize": decapitalize]
+
+def engine = new groovy.text.GStringTemplateEngine()
+def graphTraversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/GraphTraversalSource.template')).make(binding)
+def graphTraversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js')
+graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate }
+
+def traversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/TraversalSource.template')).make(binding)
+def traversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/traversal.js')
+traversalFile.newWriter().withWriter{ it << traversalTemplate }
+
+def packageJsonTemplate = engine.createTemplate(new File('${project.basedir}/glv/PackageJson.template')).make(binding)
+def packageJsonFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/package.json')
+packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
+]]>                                     </script>
+                            </scripts>
+                        </configuration>
+                    </execution>
+                    <execution>
                         <id>gremlin-server-start</id>
                         <phase>pre-integration-test</phase>
                         <goals>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
deleted file mode 100644
index ab9eaf1..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-public class GenerateGremlinJavascript {
-    public static void main(String[] args) {
-        String projectVersion = args[0];
-        final String baseDir = args[1];
-        final String jsModuleDir = "${baseDir}/src/main/javascript/gremlin-javascript";
-        Integer versionSnapshotIndex = projectVersion.indexOf("-SNAPSHOT");
-        if (versionSnapshotIndex > 0) {
-            // Use a alpha version x.y.z-alpha1
-            projectVersion = projectVersion.substring(0, versionSnapshotIndex) + "-alpha1";
-        }
-        TraversalSourceGenerator.create("$jsModuleDir/lib/process/traversal.js");
-        GraphTraversalSourceGenerator.create("$jsModuleDir/lib/process/graph-traversal.js");
-        PackageJsonGenerator.create("$jsModuleDir/package.json", projectVersion);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
deleted file mode 100644
index 3227f2c..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
-import org.apache.tinkerpop.gremlin.javascript.SymbolHelper
-
-import java.lang.reflect.Modifier
-
-/**
- * @author Jorge Bay Gondra
- */
-class GraphTraversalSourceGenerator {
-
-    public static void create(final String graphTraversalSourceFile) {
-
-        final StringBuilder moduleOutput = new StringBuilder()
-
-        moduleOutput.append("""/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
- """)
-
-//////////////////////////
-// GraphTraversalSource //
-//////////////////////////
-        moduleOutput.append("""
-/**
- * @author Jorge Bay Gondra
- */
-'use strict';
-
-var t = require('./traversal.js');
-var remote = require('../driver/remote-connection');
-var utils = require('../utils');
-var Bytecode = require('./bytecode');
-var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-var inherits = utils.inherits;
-var parseArgs = utils.parseArgs;
-
-/**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
-function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-  this.graph = graph;
-  this.traversalStrategies = traversalStrategies;
-  this.bytecode = bytecode || new Bytecode();
-}
-
-/**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-  var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
-  traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-  return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-};
-
-/**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
-GraphTraversalSource.prototype.toString = function () {
-  return 'graphtraversalsource[' + this.graph.toString() + ']';
-};
-""")
-        GraphTraversalSource.getMethods(). // SOURCE STEPS
-                findAll { GraphTraversalSource.class.equals(it.returnType) }.
-                findAll {
-                    !it.name.equals("clone") &&
-                            !it.name.equals(TraversalSource.Symbols.withBindings) &&
-                            !it.name.equals(TraversalSource.Symbols.withRemote)
-                }.
-                collect { it.name }.
-                unique().
-                sort { a, b -> a <=> b }.
-                forEach { methodName ->
-                    moduleOutput.append(
-                            """
-/**
- * Graph Traversal Source ${methodName} method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('$methodName', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-""")
-                }
-        GraphTraversalSource.getMethods().
-                findAll { GraphTraversal.class.equals(it.returnType) }.
-                collect { it.name }.
-                unique().
-                sort { a, b -> a <=> b }.
-                forEach { methodName ->
-                    moduleOutput.append(
-                            """
-/**
- * $methodName GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
-  var b = new Bytecode(this.bytecode).addStep('$methodName', parseArgs.apply(null, arguments));
-  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-""")
-                }
-////////////////////
-// GraphTraversal //
-////////////////////
-        moduleOutput.append(
-                """
-/**
- * Represents a graph traversal.
- * @extends Traversal
- * @constructor
- */
-function GraphTraversal(graph, traversalStrategies, bytecode) {
-  t.Traversal.call(this, graph, traversalStrategies, bytecode);
-}
-
-inherits(GraphTraversal, t.Traversal);
-""")
-        GraphTraversal.getMethods().
-                findAll { GraphTraversal.class.equals(it.returnType) }.
-                findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
-                collect { it.name }.
-                unique().
-                sort { a, b -> a <=> b }.
-                forEach { methodName ->
-                    moduleOutput.append(
-                            """
-/**
- * Graph traversal $methodName method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
-  this.bytecode.addStep('$methodName', parseArgs.apply(null, arguments));
-  return this;
-};
-""")
-                };
-
-////////////////////////
-// AnonymousTraversal //
-////////////////////////
-        moduleOutput.append("""
-/**
- * Contains the static method definitions
- * @type {Object}
- */
-var statics = {};
-""");
-        __.class.getMethods().
-                findAll { GraphTraversal.class.equals(it.returnType) }.
-                findAll { Modifier.isStatic(it.getModifiers()) }.
-                findAll { !it.name.equals("__") }.
-                collect { SymbolHelper.toJs(it.name) }.
-                unique().
-                sort { a, b -> a <=> b }.
-                forEach { method ->
-                    moduleOutput.append(
-                            """
-/**
- * ${method}() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.${method} = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
-  return g.${method}.apply(g, arguments);
-};
-""")
-                };
-
-        moduleOutput.append("""
-module.exports = {
-  GraphTraversal: GraphTraversal,
-  GraphTraversalSource: GraphTraversalSource,
-  statics: statics
-};""");
-
-        // save to file
-        final File file = new File(graphTraversalSourceFile);
-        file.delete()
-        moduleOutput.eachLine { file.append(it + "\n") }
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
deleted file mode 100644
index 4b4d012..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-/**
- * @author Jorge Bay Gondra
- */
-class PackageJsonGenerator {
-
-    public static void create(final String traversalSourceFile, final String version) {
-
-        final StringBuilder moduleOutput = new StringBuilder();
-        moduleOutput.append("""{
-  "name": "gremlin-javascript",
-  "version": "${version}",
-  "description": "JavaScript Gremlin Language Variant",
-  "author": "Apache TinkerPop team",
-  "keywords": [
-    "graph",
-    "gremlin",
-    "tinkerpop",
-    "connection",
-    "glv",
-    "driver",
-    "graphdb"
-  ],
-  "license": "Apache-2.0",
-  "dependencies": {
-    "ws": "^3.0.0"
-  },
-  "devDependencies": {
-    "mocha": ">= 1.14.0"
-  },
-  "repository": {
-    "type": "git",
-    "url": "https://github.com/apache/tinkerpop.git"
-  },
-  "bugs": {
-    "url": "https://issues.apache.org/jira/browse/TINKERPOP"
-  },
-  "scripts": {
-    "test": "./node_modules/.bin/mocha test --recursive -t 5000",
-    "unit-test": "./node_modules/.bin/mocha test/unit"
-  },
-  "engines": {
-    "node": ">=4"
-  }
-}"""    );
-
-        // save to a file
-        final File file = new File(traversalSourceFile);
-        file.delete()
-        moduleOutput.eachLine { file.append(it + "\n") }
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
deleted file mode 100644
index ed45cdb..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-/**
- * @author Jorge Bay Gondra
- */
-public final class SymbolHelper {
-
-    private final static Map<String, String> TO_JS_MAP = new HashMap<>();
-
-    static {
-        TO_JS_MAP.put("in", "in_");
-        TO_JS_MAP.put("from", "from_");
-    }
-
-    private SymbolHelper() {
-        // static methods only, do not instantiate
-    }
-
-    public static String toJs(final String symbol) {
-        return TO_JS_MAP.getOrDefault(symbol, symbol);
-    }
-
-    public static String decapitalize(String string) {
-        if (string == null || string.length() == 0) {
-            return string;
-        }
-        def c = string.toCharArray();
-        c[0] = Character.toLowerCase(c[0]);
-        return new String(c);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
deleted file mode 100644
index f3405c3..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-import org.apache.tinkerpop.gremlin.process.traversal.P
-import org.apache.tinkerpop.gremlin.util.CoreImports
-
-import java.lang.reflect.Modifier
-
-/**
- * @author Jorge Bay Gondra
- */
-class TraversalSourceGenerator {
-
-    public static void create(final String traversalSourceFile) {
-
-        final StringBuilder moduleOutput = new StringBuilder()
-
-        moduleOutput.append("""/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-""")
-        moduleOutput.append("""
-/**
- * @author Jorge Bay Gondra
- */
-'use strict';
-
-var utils = require('../utils');
-var parseArgs = utils.parseArgs;
-var itemDone = Object.freeze({ value: null, done: true });
-var emptyArray = Object.freeze([]);
-
-function Traversal(graph, traversalStrategies, bytecode) {
-  this.graph = graph;
-  this.traversalStrategies = traversalStrategies;
-  this.bytecode = bytecode;
-  this.traversers = null;
-  this.sideEffects = null;
-  this._traversalStrategiesPromise = null;
-  this._traversersIteratorIndex = 0;
-}
-
-/** @returns {Bytecode} */
-Traversal.prototype.getBytecode = function () {
-  return this.bytecode;
-};
-
-/**
- * Returns an Array containing the traverser objects.
- * @returns {Promise.<Array>}
- */
-Traversal.prototype.toList = function () {
-  var self = this;
-  return this._applyStrategies().then(function () {
-    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
-      return emptyArray;
-    }
-    var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
-    for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
-      arr[i] = self.traversers[i].object;
-    }
-    self._traversersIteratorIndex = self.traversers.length;
-    return arr;
-  });
-};
-
-/**
- * Async iterator method implementation.
- * Returns a promise containing an iterator item.
- * @returns {Promise.<{value, done}>}
- */
-Traversal.prototype.next = function () {
-  var self = this;
-  return this._applyStrategies().then(function () {
-    if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
-      return itemDone;
-    }
-    return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
-  });
-};
-
-Traversal.prototype._applyStrategies = function () {
-  if (this._traversalStrategiesPromise) {
-    // Apply strategies only once
-    return this._traversalStrategiesPromise;
-  }
-  return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
-};
-
-/**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
-Traversal.prototype.toString = function () {
-  return this.bytecode.toString();
-};
-  """);
-
-        moduleOutput.append("""
-/**
- * Represents an operation.
- * @constructor
- */
-function P(operator, value, other) {
-  this.operator = operator;
-  this.value = value;
-  this.other = other;
-}
-
-/**
- * Returns the string representation of the instance.
- * @returns {string}
- */
-P.prototype.toString = function () {
-  if (this.other === undefined) {
-    return this.operator + '(' + this.value + ')';
-  }
-  return this.operator + '(' + this.value + ', ' + this.other + ')';
-};
-
-function createP(operator, args) {
-  args.unshift(null, operator);
-  return new (Function.prototype.bind.apply(P, args));
-}
-""")
-        P.class.getMethods().
-                findAll { Modifier.isStatic(it.getModifiers()) }.
-                findAll { P.class.isAssignableFrom(it.returnType) }.
-                collect { it.name }.
-                unique().
-                sort { a, b -> a <=> b }.
-                each { methodName ->
-                    moduleOutput.append(
-                            """
-/** @param {...Object} args */
-P.${SymbolHelper.toJs(methodName)} = function (args) {
-  return createP('$methodName', parseArgs.apply(null, arguments));
-};
-""")
-                };
-        moduleOutput.append("""
-P.prototype.and = function (arg) {
-  return new P('and', this, arg);
-};
-
-P.prototype.or = function (arg) {
-  return new P('or', this, arg);
-};
-""")
-
-        moduleOutput.append("""
-function Traverser(object, bulk) {
-  this.object = object;
-  this.bulk = bulk == undefined ? 1 : bulk;
-}
-
-function TraversalSideEffects() {
-
-}
-
-function toEnum(typeName, keys) {
-  var result = {};
-  keys.split(' ').forEach(function (k) {
-    var jsKey = k;
-    if (jsKey === jsKey.toUpperCase()) {
-      jsKey = jsKey.toLowerCase();
-    }
-    result[jsKey] = new EnumValue(typeName, k);
-  });
-  return result;
-}
-
-function EnumValue(typeName, elementName) {
-  this.typeName = typeName;
-  this.elementName = elementName;
-}
-
-module.exports = {
-  EnumValue: EnumValue,
-  P: P,
-  Traversal: Traversal,
-  TraversalSideEffects: TraversalSideEffects,
-  Traverser: Traverser""")
-        for (final Class<? extends Enum> enumClass : CoreImports.getClassImports().
-                findAll { Enum.class.isAssignableFrom(it) }.
-                sort { a, b -> a.simpleName <=> b.simpleName }) {
-            moduleOutput.append(",\n  ${SymbolHelper.decapitalize(enumClass.simpleName)}: " +
-                    "toEnum('${SymbolHelper.toJs(enumClass.simpleName)}', '");
-            moduleOutput.append(
-                enumClass.getEnumConstants().
-                        sort { a, b -> a.name() <=> b.name() }.
-                        collect { SymbolHelper.toJs(it.name()) }.
-                        join(' '));
-            moduleOutput.append("\')");
-        }
-
-        moduleOutput.append("""\n};""");
-
-        // save to a file
-        final File file = new File(traversalSourceFile);
-        file.delete()
-        moduleOutput.eachLine { file.append(it + "\n") }
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index 5ee734a1..f6a0de1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -16,7 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
- 
+
 /**
  * @author Jorge Bay Gondra
  */
@@ -72,16 +72,6 @@ GraphTraversalSource.prototype.withBulk = function (args) {
 };
 
 /**
- * Graph Traversal Source withComputer method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withComputer = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
  * Graph Traversal Source withPath method.
  * @param {...Object} args
  * @returns {GraphTraversalSource}
@@ -1539,33 +1529,33 @@ statics.identity = function (args) {
 };
 
 /**
- * inE() static method
+ * in() static method
  * @param {...Object} args
  * @returns {GraphTraversal}
  */
-statics.inE = function (args) {
+statics.in_ = function (args) {
   var g = new GraphTraversal(null, null, new Bytecode());
-  return g.inE.apply(g, arguments);
+  return g.in_.apply(g, arguments);
 };
 
 /**
- * inV() static method
+ * inE() static method
  * @param {...Object} args
  * @returns {GraphTraversal}
  */
-statics.inV = function (args) {
+statics.inE = function (args) {
   var g = new GraphTraversal(null, null, new Bytecode());
-  return g.inV.apply(g, arguments);
+  return g.inE.apply(g, arguments);
 };
 
 /**
- * in_() static method
+ * inV() static method
  * @param {...Object} args
  * @returns {GraphTraversal}
  */
-statics.in_ = function (args) {
+statics.inV = function (args) {
   var g = new GraphTraversal(null, null, new Bytecode());
-  return g.in_.apply(g, arguments);
+  return g.inV.apply(g, arguments);
 };
 
 /**
@@ -1909,16 +1899,6 @@ statics.simplePath = function (args) {
 };
 
 /**
- * start() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.start = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
-  return g.start.apply(g, arguments);
-};
-
-/**
  * store() static method
  * @param {...Object} args
  * @returns {GraphTraversal}
@@ -2092,4 +2072,4 @@ module.exports = {
   GraphTraversal: GraphTraversal,
   GraphTraversalSource: GraphTraversalSource,
   statics: statics
-};
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 1cd6b53..49c6aef 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -91,7 +91,7 @@ Traversal.prototype._applyStrategies = function () {
 Traversal.prototype.toString = function () {
   return this.bytecode.toString();
 };
-  
+
 /**
  * Represents an operation.
  * @constructor
@@ -227,10 +227,12 @@ module.exports = {
   cardinality: toEnum('Cardinality', 'list set single'),
   column: toEnum('Column', 'keys values'),
   direction: toEnum('Direction', 'BOTH IN OUT'),
+  graphSONVersion: toEnum('GraphSONVersion', 'V1_0 V2_0'),
+  gryoVersion: toEnum('GryoVersion', 'V1_0'),
   operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
   order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
   pick: toEnum('Pick', 'any none'),
   pop: toEnum('Pop', 'all first last'),
   scope: toEnum('Scope', 'global local'),
   t: toEnum('T', 'id key label value')
-};
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14a88215/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index db6d3fe..514663b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -33,4 +33,4 @@
   "engines": {
     "node": ">=4"
   }
-}
+}
\ No newline at end of file


[42/47] tinkerpop git commit: Use ES6 syntax

Posted by jo...@apache.org.
Use ES6 syntax

- Use class definitions
- Use const and let
- Computed property names in object literals


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/cdd114c1
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/cdd114c1
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/cdd114c1

Branch: refs/heads/TINKERPOP-1489
Commit: cdd114c1684bac6c3935fd5ddb2d1645f3cd5105
Parents: 615b530
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 30 14:45:22 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Wed Jan 17 16:16:22 2018 +0100

----------------------------------------------------------------------
 .../glv/GraphTraversalSource.template           |  155 +-
 gremlin-javascript/glv/TraversalSource.template |  247 +-
 .../lib/driver/driver-remote-connection.js      |  279 +-
 .../lib/driver/remote-connection.js             |   86 +-
 .../gremlin-javascript/lib/process/bytecode.js  |  125 +-
 .../lib/process/graph-traversal.js              | 2439 +++++++++---------
 .../lib/process/traversal-strategy.js           |   99 +-
 .../gremlin-javascript/lib/process/traversal.js |  363 +--
 .../gremlin-javascript/lib/structure/graph.js   |  180 +-
 .../lib/structure/io/graph-serializer.js        |  535 +---
 .../lib/structure/io/type-serializers.js        |  288 +++
 .../javascript/gremlin-javascript/lib/utils.js  |    7 +-
 .../test/integration/remote-connection-tests.js |    2 +-
 .../test/integration/traversal-test.js          |    2 +-
 .../test/unit/exports-test.js                   |    4 +-
 .../test/unit/graphson-test.js                  |   38 +-
 .../test/unit/traversal-test.js                 |   26 +-
 17 files changed, 2451 insertions(+), 2424 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/glv/GraphTraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/GraphTraversalSource.template b/gremlin-javascript/glv/GraphTraversalSource.template
index e0fb453..812cfcf 100644
--- a/gremlin-javascript/glv/GraphTraversalSource.template
+++ b/gremlin-javascript/glv/GraphTraversalSource.template
@@ -22,93 +22,96 @@
  */
 'use strict';
 
-var t = require('./traversal.js');
-var remote = require('../driver/remote-connection');
-var utils = require('../utils');
-var Bytecode = require('./bytecode');
-var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-var inherits = utils.inherits;
-var parseArgs = utils.parseArgs;
+const Traversal = require('./traversal').Traversal;
+const remote = require('../driver/remote-connection');
+const utils = require('../utils');
+const Bytecode = require('./bytecode');
+const TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+const parseArgs = utils.parseArgs;
 
-/**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
-function GraphTraversalSource(graph, traversalStrategies, bytecode) {
-  this.graph = graph;
-  this.traversalStrategies = traversalStrategies;
-  this.bytecode = bytecode || new Bytecode();
-}
 
 /**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
+ * Represents the primary DSL of the Gremlin traversal machine.
  */
-GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
-  var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
-  traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
-  return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-};
+class GraphTraversalSource {
+  /**
+   * @param {Graph} graph
+   * @param {TraversalStrategies} traversalStrategies
+   * @param {Bytecode} [bytecode]
+   */
+  constructor(graph, traversalStrategies, bytecode) {
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode || new Bytecode();
+  }
 
-/**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
-GraphTraversalSource.prototype.toString = function () {
-  return 'graphtraversalsource[' + this.graph.toString() + ']';
-};
-<% sourceStepMethods.each{ method -> %>
-/**
- * Graph Traversal Source <%= method %> method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
-  var b = new Bytecode(this.bytecode).addSource('<%= method %>', parseArgs.apply(null, arguments));
-  return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-<%
+  /**
+   * @param remoteConnection
+   * @returns {GraphTraversalSource}
+   */
+  withRemote(remoteConnection) {
+    const traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+    traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+    return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+  }
+
+  /**
+   * Returns the string representation of the GraphTraversalSource.
+   * @returns {string}
+   */
+  toString() {
+    return 'graphtraversalsource[' + this.graph.toString() + ']';
+  }
+  <% sourceStepMethods.each{ method -> %>
+  /**
+   * Graph Traversal Source <%= method %> method.
+   * @param {...Object} args
+   * @returns {GraphTraversalSource}
+   */
+  <%= toJs.call(method) %>(args) {
+    const b = new Bytecode(this.bytecode).addSource('<%= method %>', parseArgs.apply(null, arguments));
+    return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  <%
+  }
+  sourceSpawnMethods.each{ method -> %>
+  /**
+   * <%= method %> GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  <%= toJs.call(method) %>(args) {
+    const b = new Bytecode(this.bytecode).addStep('<%= method %>', parseArgs.apply(null, arguments));
+    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  <% } %>
 }
-sourceSpawnMethods.each{ method -> %>
-/**
- * <%= method %> GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
-  var b = new Bytecode(this.bytecode).addStep('<%= method %>', parseArgs.apply(null, arguments));
-  return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-<% } %>
+
 /**
  * Represents a graph traversal.
- * @extends Traversal
- * @constructor
  */
-function GraphTraversal(graph, traversalStrategies, bytecode) {
-  t.Traversal.call(this, graph, traversalStrategies, bytecode);
+class GraphTraversal extends Traversal {
+  constructor(graph, traversalStrategies, bytecode) {
+    super(graph, traversalStrategies, bytecode);
+  }
+  <% graphStepMethods.each{ method -> %>
+  /**
+   * Graph traversal <%= method %> method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  <%= toJs.call(method) %>(args) {
+    this.bytecode.addStep('<%= method %>', parseArgs.apply(null, arguments));
+    return this;
+  }
+  <% } %>
 }
 
-inherits(GraphTraversal, t.Traversal);
-<% graphStepMethods.each{ method -> %>
-/**
- * Graph traversal <%= method %> method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.<%= toJs.call(method) %> = function (args) {
-  this.bytecode.addStep('<%= method %>', parseArgs.apply(null, arguments));
-  return this;
-};
-<% } %>
 /**
  * Contains the static method definitions
  * @type {Object}
  */
-var statics = {};
+const statics = {};
 <% anonStepMethods.each{ method -> %>
 /**
  * <%= method %>() static method
@@ -116,12 +119,12 @@ var statics = {};
  * @returns {GraphTraversal}
  */
 statics.<%= toJs.call(method) %> = function (args) {
-  var g = new GraphTraversal(null, null, new Bytecode());
+  const g = new GraphTraversal(null, null, new Bytecode());
   return g.<%= toJs.call(method) %>.apply(g, arguments);
 };
 <% } %>
 module.exports = {
-  GraphTraversal: GraphTraversal,
-  GraphTraversalSource: GraphTraversalSource,
-  statics: statics
+  GraphTraversal,
+  GraphTraversalSource,
+  statics
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index 0d45e90..d707a42 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -26,142 +26,149 @@ const utils = require('../utils');
 const parseArgs = utils.parseArgs;
 const itemDone = Object.freeze({ value: null, done: true });
 
-function Traversal(graph, traversalStrategies, bytecode) {
-  this.graph = graph;
-  this.traversalStrategies = traversalStrategies;
-  this.bytecode = bytecode;
-  /** @type {Array<Traverser>} */
-  this.traversers = null;
-  this.sideEffects = null;
-  this._traversalStrategiesPromise = null;
-  this._traversersIteratorIndex = 0;
-}
+class Traversal {
+  constructor(graph, traversalStrategies, bytecode) {
+    this.graph = graph;
+    this.traversalStrategies = traversalStrategies;
+    this.bytecode = bytecode;
+    /** @type {Array<Traverser>} */
+    this.traversers = null;
+    this.sideEffects = null;
+    this._traversalStrategiesPromise = null;
+    this._traversersIteratorIndex = 0;
+  }
 
-/** @returns {Bytecode} */
-Traversal.prototype.getBytecode = function () {
-  return this.bytecode;
-};
+  /** @returns {Bytecode} */
+  getBytecode() {
+    return this.bytecode;
+  }
 
-/**
- * Returns an Array containing the traverser objects.
- * @returns {Promise.<Array>}
- */
-Traversal.prototype.toList = function () {
-  return this._applyStrategies().then(() => {
-    const result = [];
-    let it;
-    while ((it = this._getNext()) && !it.done) {
-      result.push(it.value);
-    }
-    return result;
-  });
-};
+  /**
+   * Returns an Array containing the traverser objects.
+   * @returns {Promise.<Array>}
+   */
+  toList() {
+    return this._applyStrategies().then(() => {
+      const result = [];
+      let it;
+      while ((it = this._getNext()) && !it.done) {
+        result.push(it.value);
+      }
+      return result;
+    });
+  };
+
+  /**
+   * Iterates all Traverser instances in the traversal.
+   * @returns {Promise}
+   */
+  iterate() {
+    return this._applyStrategies().then(() => {
+      let it;
+      while ((it = this._getNext()) && !it.done) {
+      }
+    });
+  }
 
-/**
- * Iterates all Traverser instances in the traversal.
- * @returns {Promise}
- */
-Traversal.prototype.iterate = function () {
-  return this._applyStrategies().then(() => {
-    let it;
-    while ((it = this._getNext()) && !it.done) {
-    }
-  });
-};
+  /**
+   * Async iterator method implementation.
+   * Returns a promise containing an iterator item.
+   * @returns {Promise.<{value, done}>}
+   */
+  next() {
+    return this._applyStrategies().then(() => this._getNext());
+  }
 
-/**
- * Async iterator method implementation.
- * Returns a promise containing an iterator item.
- * @returns {Promise.<{value, done}>}
- */
-Traversal.prototype.next = function () {
-  return this._applyStrategies().then(() => this._getNext());
-};
+  /**
+   * Synchronous iterator of traversers including
+   * @private
+   */
+  _getNext() {
+    while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+      let traverser = this.traversers[this._traversersIteratorIndex];
+      if (traverser.bulk > 0) {
+        traverser.bulk--;
+        return { value: traverser.object, done: false };
+      }
+      this._traversersIteratorIndex++;
+    }
+    return itemDone;
+  }
 
-/**
- * Synchronous iterator of traversers including
- * @private
- */
-Traversal.prototype._getNext = function () {
-  while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
-    let traverser = this.traversers[this._traversersIteratorIndex];
-    if (traverser.bulk > 0) {
-      traverser.bulk--;
-      return { value: traverser.object, done: false };
+  _applyStrategies() {
+    if (this._traversalStrategiesPromise) {
+      // Apply strategies only once
+      return this._traversalStrategiesPromise;
     }
-    this._traversersIteratorIndex++;
+    return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
   }
-  return itemDone;
-};
 
-Traversal.prototype._applyStrategies = function () {
-  if (this._traversalStrategiesPromise) {
-    // Apply strategies only once
-    return this._traversalStrategiesPromise;
+  /**
+   * Returns the Bytecode JSON representation of the traversal
+   * @returns {String}
+   */
+  toString() {
+    return this.bytecode.toString();
+  };
+}
+
+class P {
+  /**
+   * Represents an operation.
+   * @constructor
+   */
+  constructor(operator, value, other) {
+    this.operator = operator;
+    this.value = value;
+    this.other = other;
   }
-  return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
-};
 
-/**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
-Traversal.prototype.toString = function () {
-  return this.bytecode.toString();
-};
+  /**
+   * Returns the string representation of the instance.
+   * @returns {string}
+   */
+  toString() {
+    if (this.other === undefined) {
+      return this.operator + '(' + this.value + ')';
+    }
+    return this.operator + '(' + this.value + ', ' + this.other + ')';
+  }
 
-/**
- * Represents an operation.
- * @constructor
- */
-function P(operator, value, other) {
-  this.operator = operator;
-  this.value = value;
-  this.other = other;
-}
+  and(arg) {
+    return new P('and', this, arg);
+  }
 
-/**
- * Returns the string representation of the instance.
- * @returns {string}
- */
-P.prototype.toString = function () {
-  if (this.other === undefined) {
-    return this.operator + '(' + this.value + ')';
+  or(arg) {
+    return new P('or', this, arg);
+  }
+<% pmethods.each{ method -> %>
+  /** @param {...Object} args */
+  static <%= toJs.call(method) %>(args) {
+    return createP('<%= method %>', parseArgs.apply(null, arguments));
   }
-  return this.operator + '(' + this.value + ', ' + this.other + ')';
-};
+<% } %>
+}
 
 function createP(operator, args) {
   args.unshift(null, operator);
   return new (Function.prototype.bind.apply(P, args));
 }
-<% pmethods.each{ method -> %>
-/** @param {...Object} args */
-P.<%= toJs.call(method) %> = function (args) {
-  return createP('<%= method %>', parseArgs.apply(null, arguments));
-};
-<% } %>
-P.prototype.and = function (arg) {
-  return new P('and', this, arg);
-};
-
-P.prototype.or = function (arg) {
-  return new P('or', this, arg);
-};
 
-function Traverser(object, bulk) {
-  this.object = object;
-  this.bulk = bulk || 1;
+class Traverser {
+  constructor(object, bulk) {
+    this.object = object;
+    this.bulk = bulk || 1;
+  }
 }
 
-function TraversalSideEffects() {
+class TraversalSideEffects {
 
 }
 
 function toEnum(typeName, keys) {
-  var result = {};
-  keys.split(' ').forEach(function (k) {
-    var jsKey = k;
+  const result = {};
+  keys.split(' ').forEach(k => {
+    let jsKey = k;
     if (jsKey === jsKey.toUpperCase()) {
       jsKey = jsKey.toLowerCase();
     }
@@ -170,17 +177,19 @@ function toEnum(typeName, keys) {
   return result;
 }
 
-function EnumValue(typeName, elementName) {
-  this.typeName = typeName;
-  this.elementName = elementName;
+class EnumValue {
+  constructor(typeName, elementName) {
+    this.typeName = typeName;
+    this.elementName = elementName;
+  }
 }
 
 module.exports = {
-  EnumValue: EnumValue,
-  P: P,
-  Traversal: Traversal,
-  TraversalSideEffects: TraversalSideEffects,
-  Traverser: Traverser<%
+  EnumValue,
+  P,
+  Traversal,
+  TraversalSideEffects,
+  Traverser<%
 enums.each{ enumClass ->
     out.print ",\n  " + decapitalize.call(enumClass.simpleName) + ": toEnum('" + enumClass.simpleName + "', '" +
         enumClass.getEnumConstants().sort { a, b -> a.name() <=> b.name() }.collect { toJs.call(it.name()) }.join(' ') + "')"

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 51661c3..ac3fb0f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -22,165 +22,164 @@
  */
 'use strict';
 
-var crypto = require('crypto');
-var WebSocket = require('ws');
-var util = require('util');
-var RemoteConnection = require('./remote-connection').RemoteConnection;
-var utils = require('../utils');
-var serializer = require('../structure/io/graph-serializer');
-var inherits = utils.inherits;
-var defaultMimeType = 'application/vnd.gremlin-v2.0+json';
-var responseStatusCode = {
+const crypto = require('crypto');
+const WebSocket = require('ws');
+const util = require('util');
+const RemoteConnection = require('./remote-connection').RemoteConnection;
+const utils = require('../utils');
+const serializer = require('../structure/io/graph-serializer');
+const responseStatusCode = {
   success: 200,
   noContent: 204,
   partialContent: 206
 };
+const defaultMimeType = 'application/vnd.gremlin-v2.0+json';
 
-/**
- * Creates a new instance of DriverRemoteConnection.
- * @param {String} url The resource uri.
- * @param {Object} [options] The connection options.
- * @param {Array} [options.ca] Trusted certificates.
- * @param {String|Array|Buffer} [options.cert] The certificate key.
- * @param {String} [options.mimeType] The mime type to use.
- * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
- * @param {GraphSONReader} [options.reader] The reader to use.
- * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
- * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
- * @param {GraphSONWriter} [options.writer] The writer to use.
- * @constructor
- */
-function DriverRemoteConnection(url, options) {
-  RemoteConnection.call(this, url);
-  options = options || {};
-  this._ws = new WebSocket(url, {
-    ca: options.ca,
-    cert: options.cert,
-    pfx: options.pfx,
-    rejectUnauthorized: options.rejectUnauthorized
-  });
-  var self = this;
-  this._ws.on('open', function opened () {
-    self.isOpen = true;
-    if (self._openCallback) {
-      self._openCallback();
-    }
-  });
-  this._ws.on('message', function incoming (data) {
-    self._handleMessage(data);
-  });
-  // A map containing the request id and the handler
-  this._responseHandlers = {};
-  this._reader = options.reader || new serializer.GraphSONReader();
-  this._writer = options.writer || new serializer.GraphSONWriter();
-  this._openPromise = null;
-  this._openCallback = null;
-  this._closePromise = null;
-  var mimeType = options.mimeType || defaultMimeType;
-  this._header = String.fromCharCode(mimeType.length) + mimeType;
-  this.isOpen = false;
-  this.traversalSource = options.traversalSource || 'g';
-}
-
-inherits(DriverRemoteConnection, RemoteConnection);
+class DriverRemoteConnection extends RemoteConnection {
+  /**
+   * Creates a new instance of DriverRemoteConnection.
+   * @param {String} url The resource uri.
+   * @param {Object} [options] The connection options.
+   * @param {Array} [options.ca] Trusted certificates.
+   * @param {String|Array|Buffer} [options.cert] The certificate key.
+   * @param {String} [options.mimeType] The mime type to use.
+   * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
+   * @param {GraphSONReader} [options.reader] The reader to use.
+   * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
+   * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
+   * @param {GraphSONWriter} [options.writer] The writer to use.
+   * @constructor
+   */
+  constructor(url, options) {
+    super(url);
+    options = options || {};
+    this._ws = new WebSocket(url, {
+      ca: options.ca,
+      cert: options.cert,
+      pfx: options.pfx,
+      rejectUnauthorized: options.rejectUnauthorized
+    });
+    var self = this;
+    this._ws.on('open', function opened () {
+      self.isOpen = true;
+      if (self._openCallback) {
+        self._openCallback();
+      }
+    });
+    this._ws.on('message', function incoming (data) {
+      self._handleMessage(data);
+    });
+    // A map containing the request id and the handler
+    this._responseHandlers = {};
+    this._reader = options.reader || new serializer.GraphSONReader();
+    this._writer = options.writer || new serializer.GraphSONWriter();
+    this._openPromise = null;
+    this._openCallback = null;
+    this._closePromise = null;
+    const mimeType = options.mimeType || defaultMimeType;
+    this._header = String.fromCharCode(mimeType.length) + mimeType;
+    this.isOpen = false;
+    this.traversalSource = options.traversalSource || 'g';
+  }
 
-/**
- * Opens the connection, if its not already opened.
- * @returns {Promise}
- */
-DriverRemoteConnection.prototype.open = function (promiseFactory) {
-  if (this._closePromise) {
+  /**
+   * Opens the connection, if its not already opened.
+   * @returns {Promise}
+   */
+  open(promiseFactory) {
+    if (this._closePromise) {
+      return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+        callback(new Error('Connection has been closed'));
+      });
+    }
+    if (this._openPromise) {
+      return this._openPromise;
+    }
+    const self = this;
     return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
-      callback(new Error('Connection has been closed'));
+      if (self.isOpen) {
+        return callback();
+      }
+      // It will be invoked when opened
+      self._openCallback = callback;
     });
   }
-  if (this._openPromise) {
-    return this._openPromise;
+
+  /** @override */
+  submit(bytecode, promiseFactory) {
+    const self = this;
+    return this.open().then(function () {
+      return utils.toPromise(promiseFactory, function promiseHandler(callback) {
+        const requestId = getUuid();
+        self._responseHandlers[requestId] = {
+          callback: callback,
+          result: null
+        };
+        const message = bufferFromString(self._header + JSON.stringify(self._getRequest(requestId, bytecode)));
+        self._ws.send(message);
+      });
+    });
   }
-  var self = this;
-  return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
-    if (self.isOpen) {
-      return callback();
-    }
-    // It will be invoked when opened
-    self._openCallback = callback;
-  });
-};
 
-/** @override */
-DriverRemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
-  var self = this;
-  return this.open().then(function () {
-    return utils.toPromise(promiseFactory, function promiseHandler(callback) {
-      var requestId = getUuid();
-      self._responseHandlers[requestId] = {
-        callback: callback,
-        result: null
-      };
-      var message = bufferFromString(self._header + JSON.stringify(self._getRequest(requestId, bytecode)));
-      self._ws.send(message);
+  _getRequest(id, bytecode) {
+    return ({
+      'requestId': { '@type': 'g:UUID', '@value': id },
+      'op': 'bytecode',
+      'processor': 'traversal',
+      'args': {
+        'gremlin': this._writer.adaptObject(bytecode),
+        'aliases': { 'g': this.traversalSource }
+      }
     });
-  });
-};
+  }
 
-DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
-  return ({
-    'requestId': { '@type': 'g:UUID', '@value': id },
-    'op': 'bytecode',
-    'processor': 'traversal',
-    'args': {
-      'gremlin': this._writer.adaptObject(bytecode),
-      'aliases': { 'g': this.traversalSource }
+  _handleMessage(data) {
+    const response = this._reader.read(JSON.parse(data.toString()));
+    const handler = this._responseHandlers[response.requestId];
+    if (response.status.code >= 400) {
+      // callback in error
+      return handler.callback(
+        new Error(util.format('Server error: %s (%d)', response.status.message, response.status.code)));
     }
-  });
-};
-
-DriverRemoteConnection.prototype._handleMessage = function (data) {
-  var response = this._reader.read(JSON.parse(data.toString()));
-  var handler = this._responseHandlers[response.requestId];
-  if (response.status.code >= 400) {
-    // callback in error
-    return handler.callback(
-      new Error(util.format('Server error: %s (%d)', response.status.message, response.status.code)));
-  }
-  switch (response.status.code) {
-    case responseStatusCode.noContent:
-      return handler.callback(null, { traversers: []});
-    case responseStatusCode.partialContent:
-      handler.result = handler.result || [];
-      handler.result.push.apply(handler.result, response.result.data);
-      break;
-    default:
-      if (handler.result) {
+    switch (response.status.code) {
+      case responseStatusCode.noContent:
+        return handler.callback(null, { traversers: []});
+      case responseStatusCode.partialContent:
+        handler.result = handler.result || [];
         handler.result.push.apply(handler.result, response.result.data);
-      }
-      else {
-        handler.result = response.result.data;
-      }
-      return handler.callback(null, { traversers: handler.result });
+        break;
+      default:
+        if (handler.result) {
+          handler.result.push.apply(handler.result, response.result.data);
+        }
+        else {
+          handler.result = response.result.data;
+        }
+        return handler.callback(null, { traversers: handler.result });
+    }
   }
-};
 
-/**
- * Closes the Connection.
- * @return {Promise}
- */
-DriverRemoteConnection.prototype.close = function (promiseFactory) {
-  if (this._closePromise) {
-    return this._closePromise;
-  }
-  var self = this;
-  return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
-    self._ws.on('close', function () {
-      self.isOpen = false;
-      callback();
+  /**
+   * Closes the Connection.
+   * @return {Promise}
+   */
+  close(promiseFactory) {
+    if (this._closePromise) {
+      return this._closePromise;
+    }
+    const self = this;
+    return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+      self._ws.on('close', function () {
+        self.isOpen = false;
+        callback();
+      });
+      self._ws.close();
     });
-    self._ws.close();
-  });
-};
+  }
+}
 
 function getUuid() {
-  var buffer = crypto.randomBytes(16);
+  const buffer = crypto.randomBytes(16);
   //clear the version
   buffer[6] &= 0x0f;
   //set the version 4
@@ -189,7 +188,7 @@ function getUuid() {
   buffer[8] &= 0x3f;
   //set the IETF variant
   buffer[8] |= 0x80;
-  var hex = buffer.toString('hex');
+  const hex = buffer.toString('hex');
   return (
     hex.substr(0, 8) + '-' +
     hex.substr(8, 4) + '-' +

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 235375a..37f3d0e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -22,60 +22,54 @@
  */
 'use strict';
 
-var t = require('../process/traversal');
-var TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy;
-var utils = require('../utils');
-var inherits = utils.inherits;
+const t = require('../process/traversal');
+const TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy;
 
-function RemoteConnection(url) {
-  this.url = url;
-}
-
-/**
- * @abstract
- * @param {Bytecode} bytecode
- * @param {Function|undefined} promiseFactory
- * @returns {Promise}
- */
-RemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
-  throw new Error('submit() was not implemented');
-};
+class RemoteConnection {
+  constructor(url) {
+    this.url = url;
+  }
 
-/**
- * @extends {Traversal}
- * @constructor
- */
-function RemoteTraversal(traversers, sideEffects) {
-  t.Traversal.call(this, null, null, null);
-  this.traversers = traversers;
-  this.sideEffects = sideEffects;
+  /**
+   * @abstract
+   * @param {Bytecode} bytecode
+   * @param {Function|undefined} promiseFactory
+   * @returns {Promise}
+   */
+  submit(bytecode, promiseFactory) {
+    throw new Error('submit() was not implemented');
+  };
 }
 
-inherits(RemoteTraversal, t.Traversal);
-
-/**
- *
- * @param {RemoteConnection} connection
- * @extends {TraversalStrategy}
- * @constructor
- */
-function RemoteStrategy(connection) {
-  TraversalStrategy.call(this);
-  this.connection = connection;
+class RemoteTraversal extends t.Traversal {
+  constructor(traversers, sideEffects) {
+    super(null, null, null);
+    this.traversers = traversers;
+    this.sideEffects = sideEffects;
+  }
 }
 
-inherits(RemoteStrategy, TraversalStrategy);
+class RemoteStrategy extends TraversalStrategy {
+  /**
+   * Creates a new instance of RemoteStrategy.
+   * @param {RemoteConnection} connection
+   */
+  constructor(connection) {
+    super();
+    this.connection = connection;
+  }
 
-/** @override */
-RemoteStrategy.prototype.apply = function (traversal, promiseFactory) {
-  if (traversal.traversers) {
-    return utils.resolvedPromise(promiseFactory);
+  /** @override */
+  apply(traversal, promiseFactory) {
+    if (traversal.traversers) {
+      return utils.resolvedPromise(promiseFactory);
+    }
+    return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) {
+      traversal.sideEffects = remoteTraversal.sideEffects;
+      traversal.traversers = remoteTraversal.traversers;
+    });
   }
-  return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) {
-    traversal.sideEffects = remoteTraversal.sideEffects;
-    traversal.traversers = remoteTraversal.traversers;
-  });
-};
+}
 
 module.exports = {
   RemoteConnection: RemoteConnection,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cdd114c1/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
index 2909718..85a4fc2 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
@@ -22,78 +22,77 @@
  */
 'use strict';
 
-/**
- * Creates a new instance of Bytecode
- * @param {Bytecode} [toClone]
- * @constructor
- */
-function Bytecode(toClone) {
-  if (!toClone) {
-    this.sourceInstructions = [];
-    this.stepInstructions = [];
-  }
-  else {
-    this.sourceInstructions = toClone.sourceInstructions.slice(0);
-    this.stepInstructions = toClone.stepInstructions.slice(0);
+class Bytecode {
+  /**
+   * Creates a new instance of Bytecode
+   * @param {Bytecode} [toClone]
+   */
+  constructor(toClone) {
+    if (!toClone) {
+      this.sourceInstructions = [];
+      this.stepInstructions = [];
+    }
+    else {
+      this.sourceInstructions = toClone.sourceInstructions.slice(0);
+      this.stepInstructions = toClone.stepInstructions.slice(0);
+    }
   }
-}
 
-/**
- * Adds a new source instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
-Bytecode.prototype.addSource = function (name, values) {
-  if (name === undefined) {
-    throw new Error('Name is not defined');
+  /**
+   * Adds a new source instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  addSource(name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    const instruction = new Array(values.length + 1);
+    instruction[0] = name;
+    for (let i = 0; i < values.length; ++i) {
+      instruction[i + 1] = values[i];
+    }
+    this.sourceInstructions.push(Bytecode._generateInstruction(name, values));
+    return this;
   }
-  var instruction = new Array(values.length + 1);
-  instruction[0] = name;
-  for (var i = 0; i < values.length; ++i) {
-    instruction[i + 1] = this._convertToArgument(values[i]);
+
+  /**
+   * Adds a new step instructions
+   * @param {String} name
+   * @param {Array} values
+   * @returns {Bytecode}
+   */
+  addStep(name, values) {
+    if (name === undefined) {
+      throw new Error('Name is not defined');
+    }
+    this.stepInstructions.push(Bytecode._generateInstruction(name, values));
+    return this;
   }
-  this.sourceInstructions.push(this._generateInstruction(name, values));
-  return this;
-};
 
-/**
- * Adds a new step instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
-Bytecode.prototype.addStep = function (name, values) {
-  if (name === undefined) {
-    throw new Error('Name is not defined');
+  static _generateInstruction(name, values) {
+    const length = (values ? values.length : 0) + 1;
+    const instruction = new Array(length);
+    instruction[0] = name;
+    for (let i = 1; i < length; i++) {
+      instruction[i] = values[i - 1];
+    }
+    return instruction;
   }
-  this.stepInstructions.push(this._generateInstruction(name, values));
-  return this;
-};
 
-Bytecode.prototype._generateInstruction = function (name, values) {
-  var length = (values ? values.length : 0) + 1;
-  var instruction = new Array(length);
-  instruction[0] = name;
-  for (var i = 1; i < length; i++) {
-    instruction[i] = this._convertToArgument(values[i - 1]);
+  /**
+   * Returns the JSON representation of the source and step instructions
+   * @returns {String}
+   */
+  toString() {
+    return (
+      (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+      (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
+    );
   }
-  return instruction;
-};
+}
 
-/**
- * Returns the JSON representation of the source and step instructions
- * @returns {String}
- */
-Bytecode.prototype.toString = function () {
-  return (
-    (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
-    (this.stepInstructions.length   > 0 ? JSON.stringify(this.stepInstructions) : '')
-  );
-};
 
-Bytecode.prototype._convertToArgument = function (value) {
-  return value;
-};
 
 module.exports = Bytecode;
\ No newline at end of file