http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/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/2b4e8e3b/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/2b4e8e3b/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/2b4e8e3b/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/2b4e8e3b/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/2b4e8e3b/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