You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/06/15 16:32:23 UTC
[1/4] tinkerpop git commit: Update Javascript GLV
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1489 74bffea00 -> 392c1f9c4
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 165f9db..ff63a3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -309,6 +309,10 @@ limitations under the License.
<exclude>**/.glv</exclude>
<exclude>bin/gremlin.sh</exclude>
<exclude>gremlin-console/bin/gremlin.sh</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"/>
[2/4] tinkerpop git commit: Update Javascript GLV
Posted by sp...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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
[3/4] tinkerpop git commit: Update Javascript GLV
Posted by sp...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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"
+ }
+}
[4/4] tinkerpop git commit: Update Javascript GLV
Posted by sp...@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/392c1f9c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/392c1f9c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/392c1f9c
Branch: refs/heads/TINKERPOP-1489
Commit: 392c1f9c45b822c3fa7977b436f1ba4be25993df
Parents: 74bffea
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Jun 6 15:05:14 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Tue Jun 13 11:54:51 2017 +0200
----------------------------------------------------------------------
docs/src/reference/gremlin-variants.asciidoc | 71 +
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, 4623 insertions(+), 4028 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/392c1f9c/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index 39b5558..7eaa706 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -354,4 +354,75 @@ graphson_writer = GraphSONWriter({MyType: MyType})
connection = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g',
graphson_reader=graphson_reader,
graphson_writer=graphson_writer)
+----
+
+[[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();
----
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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/392c1f9c/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