gremlin-javascript
Advanced tools
Comparing version 0.1.0-alpha1 to 3.2.8
@@ -32,2 +32,3 @@ /* | ||
var Bytecode = require('./lib/process/bytecode'); | ||
var utils = require('./lib/utils'); | ||
@@ -72,4 +73,5 @@ module.exports = { | ||
Vertex: graph.Vertex, | ||
VertexProperty: graph.VertexProperty | ||
VertexProperty: graph.VertexProperty, | ||
toLong: utils.toLong | ||
} | ||
}; |
@@ -25,12 +25,9 @@ /* | ||
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 = { | ||
const crypto = require('crypto'); | ||
const WebSocket = require('ws'); | ||
const util = require('util'); | ||
const RemoteConnection = require('./remote-connection').RemoteConnection; | ||
const utils = require('../utils'); | ||
const serializer = require('../structure/io/graph-serializer'); | ||
const responseStatusCode = { | ||
success: 200, | ||
@@ -40,142 +37,174 @@ noContent: 204, | ||
}; | ||
const defaultMimeType = 'application/vnd.gremlin-v2.0+json'; | ||
/** | ||
* Creates a new instance of DriverRemoteConnection. | ||
* @param {String} url The resource uri. | ||
* @param {Object} [options] The connection options. | ||
* @param {Array} [options.ca] Trusted certificates. | ||
* @param {String|Array|Buffer} [options.cert] The certificate key. | ||
* @param {String|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(); | ||
class DriverRemoteConnection extends RemoteConnection { | ||
/** | ||
* Creates a new instance of DriverRemoteConnection. | ||
* @param {String} url The resource uri. | ||
* @param {Object} [options] The connection options. | ||
* @param {Array} [options.ca] Trusted certificates. | ||
* @param {String|Array|Buffer} [options.cert] The certificate key. | ||
* @param {String} [options.mimeType] The mime type to use. | ||
* @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs. | ||
* @param {GraphSONReader} [options.reader] The reader to use. | ||
* @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate. | ||
* @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'. | ||
* @param {GraphSONWriter} [options.writer] The writer to use. | ||
* @constructor | ||
*/ | ||
constructor(url, options) { | ||
super(url); | ||
options = options || {}; | ||
this._ws = new WebSocket(url, { | ||
ca: options.ca, | ||
cert: options.cert, | ||
pfx: options.pfx, | ||
rejectUnauthorized: options.rejectUnauthorized | ||
}); | ||
this._ws.on('open', () => { | ||
this.isOpen = true; | ||
if (this._openCallback) { | ||
this._openCallback(); | ||
} | ||
}); | ||
this._ws.on('message', data => this._handleMessage(data)); | ||
// A map containing the request id and the handler | ||
this._responseHandlers = {}; | ||
this._reader = options.reader || new serializer.GraphSONReader(); | ||
this._writer = options.writer || new serializer.GraphSONWriter(); | ||
this._openPromise = null; | ||
this._openCallback = null; | ||
this._closePromise = null; | ||
const mimeType = options.mimeType || defaultMimeType; | ||
this._header = String.fromCharCode(mimeType.length) + mimeType; | ||
this.isOpen = false; | ||
this.traversalSource = options.traversalSource || 'g'; | ||
} | ||
/** | ||
* Opens the connection, if its not already opened. | ||
* @returns {Promise} | ||
*/ | ||
open() { | ||
if (this._closePromise) { | ||
return this._openPromise = Promise.reject(new Error('Connection has been closed')); | ||
} | ||
}); | ||
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.isOpen) { | ||
return Promise.resolve(); | ||
} | ||
if (this._openPromise) { | ||
return this._openPromise; | ||
} | ||
return this._openPromise = new Promise((resolve, reject) => { | ||
// Set the callback that will be invoked once the WS is opened | ||
this._openCallback = err => err ? reject(err) : resolve(); | ||
}); | ||
} | ||
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, | ||
/** @override */ | ||
submit(bytecode) { | ||
return this.open().then(() => new Promise((resolve, reject) => { | ||
const requestId = getUuid(); | ||
this._responseHandlers[requestId] = { | ||
callback: (err, result) => err ? reject(err) : resolve(result), | ||
result: null | ||
}; | ||
var message = bufferFromString(header + JSON.stringify(self._getRequest(requestId, bytecode))); | ||
self._ws.send(message); | ||
const message = bufferFromString(this._header + JSON.stringify(this._getRequest(requestId, bytecode))); | ||
this._ws.send(message); | ||
})); | ||
} | ||
_getRequest(id, bytecode) { | ||
return ({ | ||
'requestId': { '@type': 'g:UUID', '@value': id }, | ||
'op': 'bytecode', | ||
'processor': 'traversal', | ||
'args': { | ||
'gremlin': this._writer.adaptObject(bytecode), | ||
'aliases': { 'g': this.traversalSource } | ||
} | ||
}); | ||
}); | ||
}; | ||
} | ||
DriverRemoteConnection.prototype._getRequest = function (id, bytecode) { | ||
return ({ | ||
'requestId': { '@type': 'g:UUID', '@value': id }, | ||
'op': 'bytecode', | ||
'processor': 'traversal', | ||
'args': { | ||
'gremlin': this._writer.adaptObject(bytecode), | ||
'aliases': { 'g': 'g'} | ||
_handleMessage(data) { | ||
const response = this._reader.read(JSON.parse(data.toString())); | ||
if (response.requestId === null || response.requestId === undefined) { | ||
// There was a serialization issue on the server that prevented the parsing of the request id | ||
// We invoke any of the pending handlers with an error | ||
Object.keys(this._responseHandlers).forEach(requestId => { | ||
const handler = this._responseHandlers[requestId]; | ||
this._clearHandler(requestId); | ||
if (response.status !== undefined && response.status.message) { | ||
return handler.callback( | ||
new Error(util.format( | ||
'Server error (no request information): %s (%d)', response.status.message, response.status.code))); | ||
} else { | ||
return handler.callback(new Error(util.format('Server error (no request information): %j', response))); | ||
} | ||
}); | ||
return; | ||
} | ||
}); | ||
}; | ||
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) { | ||
const handler = this._responseHandlers[response.requestId]; | ||
if (!handler) { | ||
// The handler for a given request id was not found | ||
// It was probably invoked earlier due to a serialization issue. | ||
return; | ||
} | ||
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: | ||
this._clearHandler(response.requestId); | ||
return handler.callback(null, { traversers: []}); | ||
case responseStatusCode.partialContent: | ||
handler.result = handler.result || []; | ||
handler.result.push.apply(handler.result, response.result.data); | ||
} | ||
else { | ||
handler.result = response.result.data; | ||
} | ||
return handler.callback(null, { traversers: handler.result }); | ||
break; | ||
default: | ||
if (handler.result) { | ||
handler.result.push.apply(handler.result, response.result.data); | ||
} | ||
else { | ||
handler.result = response.result.data; | ||
} | ||
this._clearHandler(response.requestId); | ||
return handler.callback(null, { traversers: handler.result }); | ||
} | ||
} | ||
}; | ||
/** | ||
* Closes the Connection. | ||
* @return {Promise} | ||
*/ | ||
DriverRemoteConnection.prototype.close = function (promiseFactory) { | ||
if (this._closePromise) { | ||
return this._closePromise; | ||
/** | ||
* Clears the internal state containing the callback and result buffer of a given request. | ||
* @param requestId | ||
* @private | ||
*/ | ||
_clearHandler(requestId) { | ||
delete this._responseHandlers[requestId]; | ||
} | ||
var self = this; | ||
return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) { | ||
self._ws.on('close', function () { | ||
self.isOpen = false; | ||
callback(); | ||
/** | ||
* Closes the Connection. | ||
* @return {Promise} | ||
*/ | ||
close() { | ||
if (this._closePromise) { | ||
return this._closePromise; | ||
} | ||
this._closePromise = new Promise(resolve => { | ||
this._ws.on('close', function () { | ||
this.isOpen = false; | ||
resolve(); | ||
}); | ||
this._ws.close(); | ||
}); | ||
self._ws.close(); | ||
}); | ||
}; | ||
} | ||
} | ||
function getUuid() { | ||
var buffer = crypto.randomBytes(16); | ||
const buffer = crypto.randomBytes(16); | ||
//clear the version | ||
@@ -189,3 +218,3 @@ buffer[6] &= 0x0f; | ||
buffer[8] |= 0x80; | ||
var hex = buffer.toString('hex'); | ||
const hex = buffer.toString('hex'); | ||
return ( | ||
@@ -199,3 +228,3 @@ hex.substr(0, 8) + '-' + | ||
var bufferFromString = Buffer.from || function newBuffer(text) { | ||
const bufferFromString = (Int8Array.from !== Buffer.from && Buffer.from) || function newBuffer(text) { | ||
return new Buffer(text, 'utf8'); | ||
@@ -202,0 +231,0 @@ }; |
@@ -25,56 +25,49 @@ /* | ||
var t = require('../process/traversal'); | ||
var TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy; | ||
var utils = require('../utils'); | ||
var inherits = utils.inherits; | ||
const t = require('../process/traversal'); | ||
const TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy; | ||
function RemoteConnection(url, traversalSource) { | ||
this.url = url; | ||
} | ||
class RemoteConnection { | ||
constructor(url) { | ||
this.url = url; | ||
} | ||
/** | ||
* @abstract | ||
* @param {Bytecode} bytecode | ||
* @param {Function|undefined} promiseFactory | ||
* @returns {Promise} | ||
*/ | ||
RemoteConnection.prototype.submit = function (bytecode, promiseFactory) { | ||
throw new Error('submit() was not implemented'); | ||
}; | ||
/** | ||
* @extends {Traversal} | ||
* @constructor | ||
*/ | ||
function RemoteTraversal(traversers, sideEffects) { | ||
t.Traversal.call(this, null, null, null); | ||
this.traversers = traversers; | ||
this.sideEffects = sideEffects; | ||
/** | ||
* @abstract | ||
* @param {Bytecode} bytecode | ||
* @returns {Promise} | ||
*/ | ||
submit(bytecode) { | ||
throw new Error('submit() was not implemented'); | ||
}; | ||
} | ||
inherits(RemoteTraversal, t.Traversal); | ||
/** | ||
* | ||
* @param {RemoteConnection} connection | ||
* @extends {TraversalStrategy} | ||
* @constructor | ||
*/ | ||
function RemoteStrategy(connection) { | ||
TraversalStrategy.call(this); | ||
this.connection = connection; | ||
class RemoteTraversal extends t.Traversal { | ||
constructor(traversers, sideEffects) { | ||
super(null, null, null); | ||
this.traversers = traversers; | ||
this.sideEffects = sideEffects; | ||
} | ||
} | ||
inherits(RemoteStrategy, TraversalStrategy); | ||
class RemoteStrategy extends TraversalStrategy { | ||
/** | ||
* Creates a new instance of RemoteStrategy. | ||
* @param {RemoteConnection} connection | ||
*/ | ||
constructor(connection) { | ||
super(); | ||
this.connection = connection; | ||
} | ||
/** @override */ | ||
RemoteStrategy.prototype.apply = function (traversal, promiseFactory) { | ||
if (traversal.traversers) { | ||
return utils.resolvedPromise(promiseFactory); | ||
/** @override */ | ||
apply(traversal) { | ||
if (traversal.traversers) { | ||
return Promise.resolve(); | ||
} | ||
return this.connection.submit(traversal.getBytecode()).then(function (remoteTraversal) { | ||
traversal.sideEffects = remoteTraversal.sideEffects; | ||
traversal.traversers = remoteTraversal.traversers; | ||
}); | ||
} | ||
return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) { | ||
traversal.sideEffects = remoteTraversal.sideEffects; | ||
traversal.traversers = remoteTraversal.traversers; | ||
}); | ||
}; | ||
} | ||
@@ -81,0 +74,0 @@ module.exports = { |
@@ -25,76 +25,75 @@ /* | ||
/** | ||
* Creates a new instance of Bytecode | ||
* @param {Bytecode} [toClone] | ||
* @constructor | ||
*/ | ||
function Bytecode(toClone) { | ||
if (!toClone) { | ||
this.sourceInstructions = []; | ||
this.stepInstructions = []; | ||
class Bytecode { | ||
/** | ||
* Creates a new instance of Bytecode | ||
* @param {Bytecode} [toClone] | ||
*/ | ||
constructor(toClone) { | ||
if (!toClone) { | ||
this.sourceInstructions = []; | ||
this.stepInstructions = []; | ||
} | ||
else { | ||
this.sourceInstructions = [...toClone.sourceInstructions]; | ||
this.stepInstructions = [...toClone.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} | ||
*/ | ||
addSource(name, values) { | ||
if (name === undefined) { | ||
throw new Error('Name is not defined'); | ||
} | ||
const instruction = new Array(values.length + 1); | ||
instruction[0] = name; | ||
for (let i = 0; i < values.length; ++i) { | ||
instruction[i + 1] = values[i]; | ||
} | ||
this.sourceInstructions.push(Bytecode._generateInstruction(name, values)); | ||
return this; | ||
} | ||
} | ||
/** | ||
* Adds a new source instructions | ||
* @param {String} name | ||
* @param {Array} values | ||
* @returns {Bytecode} | ||
*/ | ||
Bytecode.prototype.addSource = function (name, values) { | ||
if (name === undefined) { | ||
throw new Error('Name is not defined'); | ||
/** | ||
* Adds a new step instructions | ||
* @param {String} name | ||
* @param {Array} values | ||
* @returns {Bytecode} | ||
*/ | ||
addStep(name, values) { | ||
if (name === undefined) { | ||
throw new Error('Name is not defined'); | ||
} | ||
this.stepInstructions.push(Bytecode._generateInstruction(name, values)); | ||
return this; | ||
} | ||
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'); | ||
static _generateInstruction(name, values) { | ||
const length = (values ? values.length : 0) + 1; | ||
const instruction = new Array(length); | ||
instruction[0] = name; | ||
for (let i = 1; i < length; i++) { | ||
instruction[i] = values[i - 1]; | ||
} | ||
return instruction; | ||
} | ||
this.stepInstructions.push(this._generateInstruction(name, values)); | ||
return this; | ||
}; | ||
Bytecode.prototype._generateInstruction = function (name, values) { | ||
var length = (values ? values.length : 0) + 1; | ||
var instruction = new Array(length); | ||
instruction[0] = name; | ||
for (var i = 1; i < length; i++) { | ||
instruction[i] = this._convertToArgument(values[i - 1]); | ||
/** | ||
* Returns the JSON representation of the source and step instructions | ||
* @returns {String} | ||
*/ | ||
toString() { | ||
return ( | ||
(this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') + | ||
(this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '') | ||
); | ||
} | ||
return instruction; | ||
}; | ||
} | ||
/** | ||
* Returns the JSON representation of the source and step instructions | ||
* @returns {String} | ||
*/ | ||
Bytecode.prototype.toString = function () { | ||
return ( | ||
(this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') + | ||
(this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '') | ||
); | ||
}; | ||
Bytecode.prototype._convertToArgument = function (value) { | ||
return value; | ||
}; | ||
module.exports = Bytecode; |
@@ -19,3 +19,3 @@ /* | ||
*/ | ||
/** | ||
@@ -26,2072 +26,1241 @@ * @author Jorge Bay Gondra | ||
var t = require('./traversal.js'); | ||
var remote = require('../driver/remote-connection'); | ||
var utils = require('../utils'); | ||
var Bytecode = require('./bytecode'); | ||
var TraversalStrategies = require('./traversal-strategy').TraversalStrategies; | ||
var inherits = utils.inherits; | ||
var parseArgs = utils.parseArgs; | ||
const Traversal = require('./traversal').Traversal; | ||
const remote = require('../driver/remote-connection'); | ||
const utils = require('../utils'); | ||
const Bytecode = require('./bytecode'); | ||
const TraversalStrategies = require('./traversal-strategy').TraversalStrategies; | ||
/** | ||
* | ||
* @param {Graph} graph | ||
* @param {TraversalStrategies} traversalStrategies | ||
* @param {Bytecode} [bytecode] | ||
* @constructor | ||
*/ | ||
function GraphTraversalSource(graph, traversalStrategies, bytecode) { | ||
this.graph = graph; | ||
this.traversalStrategies = traversalStrategies; | ||
this.bytecode = bytecode || new Bytecode(); | ||
} | ||
/** | ||
* @param remoteConnection | ||
* @returns {GraphTraversalSource} | ||
* Represents the primary DSL of the Gremlin traversal machine. | ||
*/ | ||
GraphTraversalSource.prototype.withRemote = function (remoteConnection) { | ||
var traversalStrategy = new TraversalStrategies(this.traversalStrategies); | ||
traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection)); | ||
return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode)); | ||
}; | ||
class GraphTraversalSource { | ||
/** | ||
* @param {Graph} graph | ||
* @param {TraversalStrategies} traversalStrategies | ||
* @param {Bytecode} [bytecode] | ||
*/ | ||
constructor(graph, traversalStrategies, bytecode) { | ||
this.graph = graph; | ||
this.traversalStrategies = traversalStrategies; | ||
this.bytecode = bytecode || new Bytecode(); | ||
} | ||
/** | ||
* Returns the string representation of the GraphTraversalSource. | ||
* @returns {string} | ||
*/ | ||
GraphTraversalSource.prototype.toString = function () { | ||
return 'graphtraversalsource[' + this.graph.toString() + ']'; | ||
}; | ||
/** | ||
* @param remoteConnection | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
withRemote(remoteConnection) { | ||
const traversalStrategy = new TraversalStrategies(this.traversalStrategies); | ||
traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection)); | ||
return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode)); | ||
} | ||
/** | ||
* 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); | ||
}; | ||
/** | ||
* Returns the string representation of the GraphTraversalSource. | ||
* @returns {string} | ||
*/ | ||
toString() { | ||
return 'graphtraversalsource[' + this.graph.toString() + ']'; | ||
} | ||
/** | ||
* Graph Traversal Source withBulk method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
withBulk(...args) { | ||
const b = new Bytecode(this.bytecode).addSource('withBulk', args); | ||
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* Graph Traversal Source withPath method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
withPath(...args) { | ||
const b = new Bytecode(this.bytecode).addSource('withPath', args); | ||
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* Graph Traversal Source withSack method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
withSack(...args) { | ||
const b = new Bytecode(this.bytecode).addSource('withSack', args); | ||
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* Graph Traversal Source withSideEffect method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
withSideEffect(...args) { | ||
const b = new Bytecode(this.bytecode).addSource('withSideEffect', args); | ||
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* Graph Traversal Source withStrategies method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
withStrategies(...args) { | ||
const b = new Bytecode(this.bytecode).addSource('withStrategies', args); | ||
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* Graph Traversal Source withoutStrategies method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
withoutStrategies(...args) { | ||
const b = new Bytecode(this.bytecode).addSource('withoutStrategies', args); | ||
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* E GraphTraversalSource step method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
E(...args) { | ||
const b = new Bytecode(this.bytecode).addStep('E', args); | ||
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* V GraphTraversalSource step method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
V(...args) { | ||
const b = new Bytecode(this.bytecode).addStep('V', args); | ||
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* addV GraphTraversalSource step method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
addV(...args) { | ||
const b = new Bytecode(this.bytecode).addStep('addV', args); | ||
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b); | ||
} | ||
/** | ||
* inject GraphTraversalSource step method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
inject(...args) { | ||
const b = new Bytecode(this.bytecode).addStep('inject', args); | ||
return new GraphTraversal(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); | ||
class GraphTraversal extends Traversal { | ||
constructor(graph, traversalStrategies, bytecode) { | ||
super(graph, traversalStrategies, bytecode); | ||
} | ||
/** | ||
* Graph traversal V method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
V(...args) { | ||
this.bytecode.addStep('V', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal addE method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
addE(...args) { | ||
this.bytecode.addStep('addE', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal addInE method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
addInE(...args) { | ||
this.bytecode.addStep('addInE', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal addOutE method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
addOutE(...args) { | ||
this.bytecode.addStep('addOutE', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal addV method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
addV(...args) { | ||
this.bytecode.addStep('addV', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal aggregate method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
aggregate(...args) { | ||
this.bytecode.addStep('aggregate', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal and method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
and(...args) { | ||
this.bytecode.addStep('and', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal as method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
as(...args) { | ||
this.bytecode.addStep('as', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal barrier method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
barrier(...args) { | ||
this.bytecode.addStep('barrier', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal both method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
both(...args) { | ||
this.bytecode.addStep('both', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal bothE method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
bothE(...args) { | ||
this.bytecode.addStep('bothE', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal bothV method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
bothV(...args) { | ||
this.bytecode.addStep('bothV', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal branch method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
branch(...args) { | ||
this.bytecode.addStep('branch', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal by method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
by(...args) { | ||
this.bytecode.addStep('by', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal cap method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
cap(...args) { | ||
this.bytecode.addStep('cap', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal choose method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
choose(...args) { | ||
this.bytecode.addStep('choose', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal coalesce method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
coalesce(...args) { | ||
this.bytecode.addStep('coalesce', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal coin method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
coin(...args) { | ||
this.bytecode.addStep('coin', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal constant method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
constant(...args) { | ||
this.bytecode.addStep('constant', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal count method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
count(...args) { | ||
this.bytecode.addStep('count', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal cyclicPath method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
cyclicPath(...args) { | ||
this.bytecode.addStep('cyclicPath', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal dedup method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
dedup(...args) { | ||
this.bytecode.addStep('dedup', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal drop method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
drop(...args) { | ||
this.bytecode.addStep('drop', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal emit method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
emit(...args) { | ||
this.bytecode.addStep('emit', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal filter method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
filter(...args) { | ||
this.bytecode.addStep('filter', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal flatMap method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
flatMap(...args) { | ||
this.bytecode.addStep('flatMap', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal fold method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
fold(...args) { | ||
this.bytecode.addStep('fold', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal from method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
from_(...args) { | ||
this.bytecode.addStep('from', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal group method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
group(...args) { | ||
this.bytecode.addStep('group', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal groupCount method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
groupCount(...args) { | ||
this.bytecode.addStep('groupCount', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal groupV3d0 method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
groupV3d0(...args) { | ||
this.bytecode.addStep('groupV3d0', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal has method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
has(...args) { | ||
this.bytecode.addStep('has', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal hasId method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
hasId(...args) { | ||
this.bytecode.addStep('hasId', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal hasKey method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
hasKey(...args) { | ||
this.bytecode.addStep('hasKey', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal hasLabel method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
hasLabel(...args) { | ||
this.bytecode.addStep('hasLabel', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal hasNot method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
hasNot(...args) { | ||
this.bytecode.addStep('hasNot', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal hasValue method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
hasValue(...args) { | ||
this.bytecode.addStep('hasValue', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal id method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
id(...args) { | ||
this.bytecode.addStep('id', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal identity method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
identity(...args) { | ||
this.bytecode.addStep('identity', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal in method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
in_(...args) { | ||
this.bytecode.addStep('in', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal inE method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
inE(...args) { | ||
this.bytecode.addStep('inE', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal inV method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
inV(...args) { | ||
this.bytecode.addStep('inV', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal inject method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
inject(...args) { | ||
this.bytecode.addStep('inject', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal is method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
is(...args) { | ||
this.bytecode.addStep('is', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal key method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
key(...args) { | ||
this.bytecode.addStep('key', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal label method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
label(...args) { | ||
this.bytecode.addStep('label', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal limit method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
limit(...args) { | ||
this.bytecode.addStep('limit', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal local method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
local(...args) { | ||
this.bytecode.addStep('local', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal loops method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
loops(...args) { | ||
this.bytecode.addStep('loops', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal map method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
map(...args) { | ||
this.bytecode.addStep('map', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal mapKeys method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
mapKeys(...args) { | ||
this.bytecode.addStep('mapKeys', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal mapValues method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
mapValues(...args) { | ||
this.bytecode.addStep('mapValues', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal match method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
match(...args) { | ||
this.bytecode.addStep('match', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal max method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
max(...args) { | ||
this.bytecode.addStep('max', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal mean method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
mean(...args) { | ||
this.bytecode.addStep('mean', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal min method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
min(...args) { | ||
this.bytecode.addStep('min', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal not method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
not(...args) { | ||
this.bytecode.addStep('not', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal option method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
option(...args) { | ||
this.bytecode.addStep('option', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal optional method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
optional(...args) { | ||
this.bytecode.addStep('optional', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal or method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
or(...args) { | ||
this.bytecode.addStep('or', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal order method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
order(...args) { | ||
this.bytecode.addStep('order', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal otherV method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
otherV(...args) { | ||
this.bytecode.addStep('otherV', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal out method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
out(...args) { | ||
this.bytecode.addStep('out', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal outE method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
outE(...args) { | ||
this.bytecode.addStep('outE', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal outV method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
outV(...args) { | ||
this.bytecode.addStep('outV', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal pageRank method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
pageRank(...args) { | ||
this.bytecode.addStep('pageRank', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal path method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
path(...args) { | ||
this.bytecode.addStep('path', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal peerPressure method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
peerPressure(...args) { | ||
this.bytecode.addStep('peerPressure', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal profile method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
profile(...args) { | ||
this.bytecode.addStep('profile', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal program method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
program(...args) { | ||
this.bytecode.addStep('program', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal project method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
project(...args) { | ||
this.bytecode.addStep('project', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal properties method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
properties(...args) { | ||
this.bytecode.addStep('properties', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal property method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
property(...args) { | ||
this.bytecode.addStep('property', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal propertyMap method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
propertyMap(...args) { | ||
this.bytecode.addStep('propertyMap', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal range method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
range(...args) { | ||
this.bytecode.addStep('range', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal repeat method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
repeat(...args) { | ||
this.bytecode.addStep('repeat', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal sack method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
sack(...args) { | ||
this.bytecode.addStep('sack', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal sample method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
sample(...args) { | ||
this.bytecode.addStep('sample', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal select method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
select(...args) { | ||
this.bytecode.addStep('select', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal sideEffect method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
sideEffect(...args) { | ||
this.bytecode.addStep('sideEffect', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal simplePath method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
simplePath(...args) { | ||
this.bytecode.addStep('simplePath', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal store method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
store(...args) { | ||
this.bytecode.addStep('store', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal subgraph method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
subgraph(...args) { | ||
this.bytecode.addStep('subgraph', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal sum method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
sum(...args) { | ||
this.bytecode.addStep('sum', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal tail method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
tail(...args) { | ||
this.bytecode.addStep('tail', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal timeLimit method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
timeLimit(...args) { | ||
this.bytecode.addStep('timeLimit', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal times method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
times(...args) { | ||
this.bytecode.addStep('times', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal to method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
to(...args) { | ||
this.bytecode.addStep('to', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal toE method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
toE(...args) { | ||
this.bytecode.addStep('toE', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal toV method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
toV(...args) { | ||
this.bytecode.addStep('toV', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal tree method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
tree(...args) { | ||
this.bytecode.addStep('tree', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal unfold method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
unfold(...args) { | ||
this.bytecode.addStep('unfold', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal union method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
union(...args) { | ||
this.bytecode.addStep('union', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal until method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
until(...args) { | ||
this.bytecode.addStep('until', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal value method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
value(...args) { | ||
this.bytecode.addStep('value', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal valueMap method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
valueMap(...args) { | ||
this.bytecode.addStep('valueMap', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal values method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
values(...args) { | ||
this.bytecode.addStep('values', args); | ||
return this; | ||
} | ||
/** | ||
* Graph traversal where method. | ||
* @param {...Object} args | ||
* @returns {GraphTraversal} | ||
*/ | ||
where(...args) { | ||
this.bytecode.addStep('where', args); | ||
return this; | ||
} | ||
} | ||
inherits(GraphTraversal, t.Traversal); | ||
function callOnEmptyTraversal(fnName, args) { | ||
const g = new GraphTraversal(null, null, new Bytecode()); | ||
return g[fnName].apply(g, args); | ||
} | ||
/** | ||
* 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); | ||
const statics = { | ||
V: (...args) => callOnEmptyTraversal('V', args), | ||
addE: (...args) => callOnEmptyTraversal('addE', args), | ||
addInE: (...args) => callOnEmptyTraversal('addInE', args), | ||
addOutE: (...args) => callOnEmptyTraversal('addOutE', args), | ||
addV: (...args) => callOnEmptyTraversal('addV', args), | ||
aggregate: (...args) => callOnEmptyTraversal('aggregate', args), | ||
and: (...args) => callOnEmptyTraversal('and', args), | ||
as: (...args) => callOnEmptyTraversal('as', args), | ||
barrier: (...args) => callOnEmptyTraversal('barrier', args), | ||
both: (...args) => callOnEmptyTraversal('both', args), | ||
bothE: (...args) => callOnEmptyTraversal('bothE', args), | ||
bothV: (...args) => callOnEmptyTraversal('bothV', args), | ||
branch: (...args) => callOnEmptyTraversal('branch', args), | ||
cap: (...args) => callOnEmptyTraversal('cap', args), | ||
choose: (...args) => callOnEmptyTraversal('choose', args), | ||
coalesce: (...args) => callOnEmptyTraversal('coalesce', args), | ||
coin: (...args) => callOnEmptyTraversal('coin', args), | ||
constant: (...args) => callOnEmptyTraversal('constant', args), | ||
count: (...args) => callOnEmptyTraversal('count', args), | ||
cyclicPath: (...args) => callOnEmptyTraversal('cyclicPath', args), | ||
dedup: (...args) => callOnEmptyTraversal('dedup', args), | ||
drop: (...args) => callOnEmptyTraversal('drop', args), | ||
emit: (...args) => callOnEmptyTraversal('emit', args), | ||
filter: (...args) => callOnEmptyTraversal('filter', args), | ||
flatMap: (...args) => callOnEmptyTraversal('flatMap', args), | ||
fold: (...args) => callOnEmptyTraversal('fold', args), | ||
group: (...args) => callOnEmptyTraversal('group', args), | ||
groupCount: (...args) => callOnEmptyTraversal('groupCount', args), | ||
groupV3d0: (...args) => callOnEmptyTraversal('groupV3d0', args), | ||
has: (...args) => callOnEmptyTraversal('has', args), | ||
hasId: (...args) => callOnEmptyTraversal('hasId', args), | ||
hasKey: (...args) => callOnEmptyTraversal('hasKey', args), | ||
hasLabel: (...args) => callOnEmptyTraversal('hasLabel', args), | ||
hasNot: (...args) => callOnEmptyTraversal('hasNot', args), | ||
hasValue: (...args) => callOnEmptyTraversal('hasValue', args), | ||
id: (...args) => callOnEmptyTraversal('id', args), | ||
identity: (...args) => callOnEmptyTraversal('identity', args), | ||
in_: (...args) => callOnEmptyTraversal('in_', args), | ||
inE: (...args) => callOnEmptyTraversal('inE', args), | ||
inV: (...args) => callOnEmptyTraversal('inV', args), | ||
inject: (...args) => callOnEmptyTraversal('inject', args), | ||
is: (...args) => callOnEmptyTraversal('is', args), | ||
key: (...args) => callOnEmptyTraversal('key', args), | ||
label: (...args) => callOnEmptyTraversal('label', args), | ||
limit: (...args) => callOnEmptyTraversal('limit', args), | ||
local: (...args) => callOnEmptyTraversal('local', args), | ||
loops: (...args) => callOnEmptyTraversal('loops', args), | ||
map: (...args) => callOnEmptyTraversal('map', args), | ||
mapKeys: (...args) => callOnEmptyTraversal('mapKeys', args), | ||
mapValues: (...args) => callOnEmptyTraversal('mapValues', args), | ||
match: (...args) => callOnEmptyTraversal('match', args), | ||
max: (...args) => callOnEmptyTraversal('max', args), | ||
mean: (...args) => callOnEmptyTraversal('mean', args), | ||
min: (...args) => callOnEmptyTraversal('min', args), | ||
not: (...args) => callOnEmptyTraversal('not', args), | ||
optional: (...args) => callOnEmptyTraversal('optional', args), | ||
or: (...args) => callOnEmptyTraversal('or', args), | ||
order: (...args) => callOnEmptyTraversal('order', args), | ||
otherV: (...args) => callOnEmptyTraversal('otherV', args), | ||
out: (...args) => callOnEmptyTraversal('out', args), | ||
outE: (...args) => callOnEmptyTraversal('outE', args), | ||
outV: (...args) => callOnEmptyTraversal('outV', args), | ||
path: (...args) => callOnEmptyTraversal('path', args), | ||
project: (...args) => callOnEmptyTraversal('project', args), | ||
properties: (...args) => callOnEmptyTraversal('properties', args), | ||
property: (...args) => callOnEmptyTraversal('property', args), | ||
propertyMap: (...args) => callOnEmptyTraversal('propertyMap', args), | ||
range: (...args) => callOnEmptyTraversal('range', args), | ||
repeat: (...args) => callOnEmptyTraversal('repeat', args), | ||
sack: (...args) => callOnEmptyTraversal('sack', args), | ||
sample: (...args) => callOnEmptyTraversal('sample', args), | ||
select: (...args) => callOnEmptyTraversal('select', args), | ||
sideEffect: (...args) => callOnEmptyTraversal('sideEffect', args), | ||
simplePath: (...args) => callOnEmptyTraversal('simplePath', args), | ||
store: (...args) => callOnEmptyTraversal('store', args), | ||
subgraph: (...args) => callOnEmptyTraversal('subgraph', args), | ||
sum: (...args) => callOnEmptyTraversal('sum', args), | ||
tail: (...args) => callOnEmptyTraversal('tail', args), | ||
timeLimit: (...args) => callOnEmptyTraversal('timeLimit', args), | ||
times: (...args) => callOnEmptyTraversal('times', args), | ||
to: (...args) => callOnEmptyTraversal('to', args), | ||
toE: (...args) => callOnEmptyTraversal('toE', args), | ||
toV: (...args) => callOnEmptyTraversal('toV', args), | ||
tree: (...args) => callOnEmptyTraversal('tree', args), | ||
unfold: (...args) => callOnEmptyTraversal('unfold', args), | ||
union: (...args) => callOnEmptyTraversal('union', args), | ||
until: (...args) => callOnEmptyTraversal('until', args), | ||
value: (...args) => callOnEmptyTraversal('value', args), | ||
valueMap: (...args) => callOnEmptyTraversal('valueMap', args), | ||
values: (...args) => callOnEmptyTraversal('values', args), | ||
where: (...args) => callOnEmptyTraversal('where', args) | ||
}; | ||
/** | ||
* 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 | ||
}; | ||
GraphTraversal, | ||
GraphTraversalSource, | ||
statics | ||
}; |
@@ -25,62 +25,49 @@ /* | ||
var utils = require('../utils'); | ||
const utils = require('../utils'); | ||
/** | ||
* Creates a new instance of TraversalStrategies. | ||
* @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from. | ||
* @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to | ||
* create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises. | ||
* @constructor | ||
*/ | ||
function TraversalStrategies(parent, promiseFactory) { | ||
if (parent) { | ||
// Clone the strategies | ||
this.strategies = parent.strategies.slice(0); | ||
this.promiseFactory = parent.promiseFactory; | ||
class TraversalStrategies { | ||
/** | ||
* Creates a new instance of TraversalStrategies. | ||
* @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from. | ||
* @constructor | ||
*/ | ||
constructor(parent) { | ||
if (parent) { | ||
// Clone the strategies | ||
this.strategies = [...parent.strategies]; | ||
} | ||
else { | ||
this.strategies = []; | ||
} | ||
} | ||
else { | ||
this.strategies = []; | ||
/** @param {TraversalStrategy} strategy */ | ||
addStrategy(strategy) { | ||
this.strategies.push(strategy); | ||
} | ||
if (promiseFactory) { | ||
this.promiseFactory = promiseFactory; | ||
/** | ||
* @param {Traversal} traversal | ||
* @returns {Promise} | ||
*/ | ||
applyStrategies(traversal) { | ||
// Apply all strategies serially | ||
return this.strategies.reduce((promise, strategy) => { | ||
return promise.then(() => strategy.apply(traversal)); | ||
}, Promise.resolve()); | ||
} | ||
} | ||
/** @param {TraversalStrategy} strategy */ | ||
TraversalStrategies.prototype.addStrategy = function (strategy) { | ||
this.strategies.push(strategy); | ||
}; | ||
/** @abstract */ | ||
class TraversalStrategy { | ||
/** | ||
* @abstract | ||
* @param {Traversal} traversal | ||
* @returns {Promise} | ||
*/ | ||
apply(traversal) { | ||
/** | ||
* @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 = { | ||
@@ -87,0 +74,0 @@ TraversalStrategies: TraversalStrategies, |
@@ -25,184 +25,208 @@ /* | ||
var utils = require('../utils'); | ||
var parseArgs = utils.parseArgs; | ||
var itemDone = Object.freeze({ value: null, done: true }); | ||
var emptyArray = Object.freeze([]); | ||
const utils = require('../utils'); | ||
const itemDone = Object.freeze({ value: null, done: true }); | ||
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; | ||
} | ||
class Traversal { | ||
constructor(graph, traversalStrategies, bytecode) { | ||
this.graph = graph; | ||
this.traversalStrategies = traversalStrategies; | ||
this.bytecode = bytecode; | ||
/** @type {Array<Traverser>} */ | ||
this.traversers = null; | ||
this.sideEffects = null; | ||
this._traversalStrategiesPromise = null; | ||
this._traversersIteratorIndex = 0; | ||
} | ||
/** @returns {Bytecode} */ | ||
Traversal.prototype.getBytecode = function () { | ||
return this.bytecode; | ||
}; | ||
/** @returns {Bytecode} */ | ||
getBytecode() { | ||
return this.bytecode; | ||
} | ||
/** | ||
* Returns an Array containing the traverser objects. | ||
* @returns {Promise.<Array>} | ||
*/ | ||
Traversal.prototype.toList = function () { | ||
var self = this; | ||
return this._applyStrategies().then(function () { | ||
if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) { | ||
return emptyArray; | ||
/** | ||
* Returns an Array containing the traverser objects. | ||
* @returns {Promise.<Array>} | ||
*/ | ||
toList() { | ||
return this._applyStrategies().then(() => { | ||
const result = []; | ||
let it; | ||
while ((it = this._getNext()) && !it.done) { | ||
result.push(it.value); | ||
} | ||
return result; | ||
}); | ||
}; | ||
/** | ||
* Iterates all Traverser instances in the traversal. | ||
* @returns {Promise} | ||
*/ | ||
iterate() { | ||
return this._applyStrategies().then(() => { | ||
let it; | ||
while ((it = this._getNext()) && !it.done) { | ||
} | ||
}); | ||
} | ||
/** | ||
* Async iterator method implementation. | ||
* Returns a promise containing an iterator item. | ||
* @returns {Promise.<{value, done}>} | ||
*/ | ||
next() { | ||
return this._applyStrategies().then(() => this._getNext()); | ||
} | ||
/** | ||
* Synchronous iterator of traversers including | ||
* @private | ||
*/ | ||
_getNext() { | ||
while (this.traversers && this._traversersIteratorIndex < this.traversers.length) { | ||
let traverser = this.traversers[this._traversersIteratorIndex]; | ||
if (traverser.bulk > 0) { | ||
traverser.bulk--; | ||
return { value: traverser.object, done: false }; | ||
} | ||
this._traversersIteratorIndex++; | ||
} | ||
var arr = new Array(self.traversers.length - self._traversersIteratorIndex); | ||
for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) { | ||
arr[i] = self.traversers[i].object; | ||
} | ||
self._traversersIteratorIndex = self.traversers.length; | ||
return arr; | ||
}); | ||
}; | ||
return itemDone; | ||
} | ||
/** | ||
* 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; | ||
_applyStrategies() { | ||
if (this._traversalStrategiesPromise) { | ||
// Apply strategies only once | ||
return this._traversalStrategiesPromise; | ||
} | ||
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); | ||
} | ||
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 Bytecode JSON representation of the traversal | ||
* @returns {String} | ||
*/ | ||
toString() { | ||
return this.bytecode.toString(); | ||
}; | ||
} | ||
/** | ||
* Returns the string representation of the instance. | ||
* @returns {string} | ||
*/ | ||
P.prototype.toString = function () { | ||
if (this.other === undefined) { | ||
return this.operator + '(' + this.value + ')'; | ||
class P { | ||
/** | ||
* Represents an operation. | ||
* @constructor | ||
*/ | ||
constructor(operator, value, other) { | ||
this.operator = operator; | ||
this.value = value; | ||
this.other = other; | ||
} | ||
return this.operator + '(' + this.value + ', ' + this.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} | ||
*/ | ||
toString() { | ||
if (this.other === undefined) { | ||
return this.operator + '(' + this.value + ')'; | ||
} | ||
return this.operator + '(' + this.value + ', ' + this.other + ')'; | ||
} | ||
/** @param {...Object} args */ | ||
P.between = function (args) { | ||
return createP('between', parseArgs.apply(null, arguments)); | ||
}; | ||
and(arg) { | ||
return new P('and', this, arg); | ||
} | ||
/** @param {...Object} args */ | ||
P.eq = function (args) { | ||
return createP('eq', parseArgs.apply(null, arguments)); | ||
}; | ||
or(arg) { | ||
return new P('or', this, arg); | ||
} | ||
/** @param {...Object} args */ | ||
P.gt = function (args) { | ||
return createP('gt', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static between(...args) { | ||
return createP('between', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.gte = function (args) { | ||
return createP('gte', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static eq(...args) { | ||
return createP('eq', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.inside = function (args) { | ||
return createP('inside', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static gt(...args) { | ||
return createP('gt', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.lt = function (args) { | ||
return createP('lt', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static gte(...args) { | ||
return createP('gte', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.lte = function (args) { | ||
return createP('lte', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static inside(...args) { | ||
return createP('inside', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.neq = function (args) { | ||
return createP('neq', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static lt(...args) { | ||
return createP('lt', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.not = function (args) { | ||
return createP('not', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static lte(...args) { | ||
return createP('lte', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.outside = function (args) { | ||
return createP('outside', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static neq(...args) { | ||
return createP('neq', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.test = function (args) { | ||
return createP('test', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static not(...args) { | ||
return createP('not', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.within = function (args) { | ||
return createP('within', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static outside(...args) { | ||
return createP('outside', args); | ||
} | ||
/** @param {...Object} args */ | ||
P.without = function (args) { | ||
return createP('without', parseArgs.apply(null, arguments)); | ||
}; | ||
/** @param {...Object} args */ | ||
static test(...args) { | ||
return createP('test', args); | ||
} | ||
P.prototype.and = function (arg) { | ||
return new P('and', this, arg); | ||
}; | ||
/** @param {...Object} args */ | ||
static within(...args) { | ||
return createP('within', args); | ||
} | ||
P.prototype.or = function (arg) { | ||
return new P('or', this, arg); | ||
}; | ||
/** @param {...Object} args */ | ||
static without(...args) { | ||
return createP('without', args); | ||
} | ||
function Traverser(object, bulk) { | ||
this.object = object; | ||
this.bulk = bulk == undefined ? 1 : bulk; | ||
} | ||
function TraversalSideEffects() { | ||
function createP(operator, args) { | ||
args.unshift(null, operator); | ||
return new (Function.prototype.bind.apply(P, args)); | ||
} | ||
class Traverser { | ||
constructor(object, bulk) { | ||
this.object = object; | ||
this.bulk = bulk || 1; | ||
} | ||
} | ||
class TraversalSideEffects { | ||
} | ||
function toEnum(typeName, keys) { | ||
var result = {}; | ||
keys.split(' ').forEach(function (k) { | ||
var jsKey = k; | ||
const result = {}; | ||
keys.split(' ').forEach(k => { | ||
let jsKey = k; | ||
if (jsKey === jsKey.toUpperCase()) { | ||
@@ -216,13 +240,19 @@ jsKey = jsKey.toLowerCase(); | ||
function EnumValue(typeName, elementName) { | ||
this.typeName = typeName; | ||
this.elementName = elementName; | ||
class EnumValue { | ||
constructor(typeName, elementName) { | ||
this.typeName = typeName; | ||
this.elementName = elementName; | ||
} | ||
toString() { | ||
return this.elementName; | ||
} | ||
} | ||
module.exports = { | ||
EnumValue: EnumValue, | ||
P: P, | ||
Traversal: Traversal, | ||
TraversalSideEffects: TraversalSideEffects, | ||
Traverser: Traverser, | ||
EnumValue, | ||
P, | ||
Traversal, | ||
TraversalSideEffects, | ||
Traverser, | ||
barrier: toEnum('Barrier', 'normSack'), | ||
@@ -232,2 +262,4 @@ cardinality: toEnum('Cardinality', 'list set single'), | ||
direction: toEnum('Direction', 'BOTH IN OUT'), | ||
graphSONVersion: toEnum('GraphSONVersion', 'V1_0 V2_0'), | ||
gryoVersion: toEnum('GryoVersion', 'V1_0'), | ||
operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'), | ||
@@ -239,2 +271,2 @@ order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'), | ||
t: toEnum('T', 'id key label value') | ||
}; | ||
}; |
@@ -25,106 +25,136 @@ /* | ||
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; | ||
const gt = require('../process/graph-traversal'); | ||
const TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies; | ||
function Graph() { | ||
class Graph { | ||
/** | ||
* Returns the graph traversal source. | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
traversal() { | ||
return new gt.GraphTraversalSource(this, new TraversalStrategies()); | ||
} | ||
toString() { | ||
return 'graph[empty]'; | ||
} | ||
} | ||
/** | ||
* Returns the graph traversal source. | ||
* @returns {GraphTraversalSource} | ||
*/ | ||
Graph.prototype.traversal = function () { | ||
return new gt.GraphTraversalSource(this, new TraversalStrategies()); | ||
}; | ||
class Element { | ||
constructor(id, label) { | ||
this.id = id; | ||
this.label = label; | ||
} | ||
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} | ||
*/ | ||
equals(other) { | ||
return (other instanceof Element) && this.id === other.id; | ||
} | ||
} | ||
/** | ||
* Compares this instance to another and determines if they can be considered as equal. | ||
* @param {Element} other | ||
* @returns {boolean} | ||
*/ | ||
Element.prototype.equals = function (other) { | ||
return (other instanceof Element) && this.id === other.id; | ||
}; | ||
class Vertex extends Element { | ||
constructor(id, label, properties) { | ||
super(id, label); | ||
this.properties = properties; | ||
} | ||
function Vertex(id, label, properties) { | ||
Element.call(this, id, label); | ||
this.properties = properties; | ||
toString() { | ||
return 'v[' + this.id + ']'; | ||
} | ||
} | ||
Vertex.prototype.toString = function () { | ||
return 'v[' + this.id + ']'; | ||
}; | ||
inherits(Vertex, Element); | ||
function Edge(id, outV, label, inV, properties) { | ||
Element.call(this, id, label); | ||
this.outV = outV; | ||
this.inV = inV; | ||
this.properties = {}; | ||
(function adaptProperties(self) { | ||
class Edge extends Element { | ||
constructor(id, outV, label, inV, properties) { | ||
super(id, label); | ||
this.outV = outV; | ||
this.inV = inV; | ||
this.properties = {}; | ||
if (properties) { | ||
var keys = Object.keys(properties); | ||
for (var i = 0; i < keys.length; i++) { | ||
var k = keys[i]; | ||
self.properties[k] = properties[k].value; | ||
const keys = Object.keys(properties); | ||
for (let i = 0; i < keys.length; i++) { | ||
const k = keys[i]; | ||
this.properties[k] = properties[k].value; | ||
} | ||
} | ||
})(this); | ||
} | ||
toString() { | ||
return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']'; | ||
} | ||
} | ||
inherits(Edge, Element); | ||
class VertexProperty extends Element { | ||
constructor(id, label, value, properties) { | ||
super(id, label); | ||
this.value = value; | ||
this.key = this.label; | ||
this.properties = properties; | ||
} | ||
Edge.prototype.toString = function () { | ||
return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']'; | ||
}; | ||
function VertexProperty(id, label, value, properties) { | ||
Element.call(this, id, label); | ||
this.value = value; | ||
this.key = this.label; | ||
this.properties = properties; | ||
toString() { | ||
return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']'; | ||
} | ||
} | ||
inherits(VertexProperty, Element); | ||
class Property { | ||
constructor(key, value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
VertexProperty.prototype.toString = function () { | ||
return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']'; | ||
}; | ||
toString() { | ||
return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']'; | ||
} | ||
function Property(key, value) { | ||
this.key = key; | ||
this.value = value; | ||
equals(other) { | ||
return (other instanceof Property) && this.key === other.key && this.value === other.value; | ||
} | ||
} | ||
Property.prototype.toString = function () { | ||
return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']'; | ||
}; | ||
class Path { | ||
/** | ||
* Represents a walk through a graph as defined by a traversal. | ||
* @param {Array} labels | ||
* @param {Array} objects | ||
* @constructor | ||
*/ | ||
constructor(labels, objects) { | ||
this.labels = labels; | ||
this.objects = objects; | ||
} | ||
Property.prototype.equals = function (other) { | ||
return (other instanceof Property) && this.key === other.key && this.value === other.value; | ||
}; | ||
equals(other) { | ||
if (!(other instanceof Path)) { | ||
return false; | ||
} | ||
if (other === this) { | ||
return true; | ||
} | ||
return areEqual(this.objects, other.objects) && areEqual(this.labels, other.labels); | ||
} | ||
} | ||
/** | ||
* 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 areEqual(obj1, obj2) { | ||
if (obj1 === obj2) { | ||
return true; | ||
} | ||
if (typeof obj1.equals === 'function') { | ||
return obj1.equals(obj2); | ||
} | ||
if (Array.isArray(obj1) && Array.isArray(obj2)) { | ||
if (obj1.length !== obj2.length) { | ||
return false; | ||
} | ||
for (let i = 0; i < obj1.length; i++) { | ||
if (!areEqual(obj1[i], obj2[i])){ | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
@@ -131,0 +161,0 @@ |
@@ -25,375 +25,158 @@ /* | ||
var t = require('../../process/traversal'); | ||
var Bytecode = require('../../process/bytecode'); | ||
var g = require('../graph.js'); | ||
const typeSerializers = require('./type-serializers'); | ||
/** | ||
* 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) { | ||
class GraphSONWriter { | ||
/** | ||
* @param {Object} [options] | ||
* @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and | ||
* serializer instances as values, ie: { 'g:Int64': longSerializer }. | ||
* @constructor | ||
*/ | ||
constructor(options) { | ||
this._options = options || {}; | ||
// Create instance of the default serializers | ||
this._serializers = serializers.map(serializerConstructor => { | ||
const s = new serializerConstructor(); | ||
s.writer = this; | ||
return s; | ||
}); | ||
const customSerializers = this._options.serializers || {}; | ||
Object.keys(customSerializers).forEach(key => { | ||
const s = customSerializers[key]; | ||
if (!s.serialize) { | ||
return; | ||
} | ||
s.reader = this; | ||
this._deserializers[key] = s; | ||
}, this); | ||
s.writer = this; | ||
// Insert custom serializers first | ||
this._serializers.unshift(s); | ||
}); | ||
} | ||
} | ||
GraphSONReader.prototype.read = function (obj) { | ||
if (obj === undefined) { | ||
return undefined; | ||
} | ||
if (obj === null) { | ||
return null; | ||
} | ||
if (Array.isArray(obj)) { | ||
return obj.map(function mapEach(item) { | ||
return this.read(item); | ||
}, this); | ||
} | ||
var type = obj[typeKey]; | ||
if (type) { | ||
var d = this._deserializers[type]; | ||
if (d) { | ||
// Use type serializer | ||
return d.deserialize(obj); | ||
adaptObject(value) { | ||
let s; | ||
if (Array.isArray(value)) { | ||
return value.map(item => this.adaptObject(item)); | ||
} | ||
return obj[valueKey]; | ||
for (let i = 0; i < this._serializers.length; i++) { | ||
const currentSerializer = this._serializers[i]; | ||
if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) { | ||
s = currentSerializer; | ||
break; | ||
} | ||
} | ||
if (s) { | ||
return s.serialize(value); | ||
} | ||
// Default (strings / objects / ...) | ||
return value; | ||
} | ||
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]]); | ||
/** | ||
* Returns the GraphSON representation of the provided object instance. | ||
* @param {Object} obj | ||
* @returns {String} | ||
*/ | ||
write(obj) { | ||
return JSON.stringify(this.adaptObject(obj)); | ||
} | ||
return result; | ||
}; | ||
function NumberSerializer() { | ||
} | ||
NumberSerializer.prototype.serialize = function (item) { | ||
return item; | ||
}; | ||
NumberSerializer.prototype.deserialize = function (obj) { | ||
var value = obj[valueKey]; | ||
return parseFloat(value); | ||
}; | ||
NumberSerializer.prototype.canBeUsedFor = function (value) { | ||
return (typeof value === 'number'); | ||
}; | ||
function BytecodeSerializer() { | ||
} | ||
BytecodeSerializer.prototype.serialize = function (item) { | ||
var bytecode = item; | ||
if (item instanceof t.Traversal) { | ||
bytecode = item.getBytecode(); | ||
class GraphSONReader { | ||
/** | ||
* GraphSON Reader | ||
* @param {Object} [options] | ||
* @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and | ||
* deserializer instances as values, ie: { 'g:Int64': longSerializer }. | ||
* @constructor | ||
*/ | ||
constructor(options) { | ||
this._options = options || {}; | ||
this._deserializers = {}; | ||
Object.keys(deserializers).forEach(typeName => { | ||
const serializerConstructor = deserializers[typeName]; | ||
const s = new serializerConstructor(); | ||
s.reader = this; | ||
this._deserializers[typeName] = s; | ||
}); | ||
if (this._options.serializers) { | ||
const customSerializers = this._options.serializers || {}; | ||
Object.keys(customSerializers).forEach(key => { | ||
const s = customSerializers[key]; | ||
if (!s.deserialize) { | ||
return; | ||
} | ||
s.reader = this; | ||
this._deserializers[key] = s; | ||
}); | ||
} | ||
} | ||
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; | ||
read(obj) { | ||
if (obj === undefined) { | ||
return undefined; | ||
} | ||
if (obj === null) { | ||
return null; | ||
} | ||
if (Array.isArray(obj)) { | ||
return obj.map(item => this.read(item)); | ||
} | ||
const type = obj[typeSerializers.typeKey]; | ||
if (type) { | ||
const d = this._deserializers[type]; | ||
if (d) { | ||
// Use type serializer | ||
return d.deserialize(obj); | ||
} | ||
return obj[typeSerializers.valueKey]; | ||
} | ||
if (obj && typeof obj === 'object' && obj.constructor === Object) { | ||
return this._deserializeObject(obj); | ||
} | ||
// Default (for boolean, number and other scalars) | ||
return obj; | ||
} | ||
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); | ||
_deserializeObject(obj) { | ||
const keys = Object.keys(obj); | ||
const result = {}; | ||
for (let i = 0; i < keys.length; i++) { | ||
result[keys[i]] = this.read(obj[keys[i]]); | ||
} | ||
return result; | ||
} | ||
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; | ||
const deserializers = { | ||
'g:Traverser': typeSerializers.TraverserSerializer, | ||
'g:Int32': typeSerializers.NumberSerializer, | ||
'g:Int64': typeSerializers.NumberSerializer, | ||
'g:Float': typeSerializers.NumberSerializer, | ||
'g:Double': typeSerializers.NumberSerializer, | ||
'g:Vertex': typeSerializers.VertexSerializer, | ||
'g:Edge': typeSerializers.EdgeSerializer, | ||
'g:VertexProperty': typeSerializers.VertexPropertySerializer, | ||
'g:Property': typeSerializers.PropertySerializer, | ||
'g:Path': typeSerializers.PathSerializer, | ||
'g:T': typeSerializers.TSerializer | ||
}; | ||
LambdaSerializer.prototype.canBeUsedFor = function (value) { | ||
return (typeof value === 'function'); | ||
}; | ||
const serializers = [ | ||
typeSerializers.NumberSerializer, | ||
typeSerializers.BytecodeSerializer, | ||
typeSerializers.TraverserSerializer, | ||
typeSerializers.PSerializer, | ||
typeSerializers.LambdaSerializer, | ||
typeSerializers.EnumSerializer, | ||
typeSerializers.VertexSerializer, | ||
typeSerializers.EdgeSerializer, | ||
typeSerializers.LongSerializer | ||
]; | ||
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 | ||
GraphSONWriter, | ||
GraphSONReader | ||
}; |
@@ -25,39 +25,12 @@ /* | ||
'use strict'; | ||
var util = require('util'); | ||
exports.inherits = util.inherits; | ||
exports.parseArgs = function parseArgs() { | ||
return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments)); | ||
exports.toLong = function toLong(value) { | ||
return new Long(value); | ||
}; | ||
/** | ||
* @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); | ||
const Long = exports.Long = function Long(value) { | ||
if (typeof value !== 'string' && typeof value !== 'number') { | ||
throw new TypeError('Ty') | ||
} | ||
this.value = value.toString(); | ||
}; |
{ | ||
"name": "gremlin-javascript", | ||
"version": "0.1.0-alpha1", | ||
"version": "3.2.8", | ||
"description": "JavaScript Gremlin Language Variant", | ||
@@ -20,3 +20,5 @@ "author": "Apache TinkerPop team", | ||
"devDependencies": { | ||
"mocha": ">= 1.14.0" | ||
"mocha": "~4.0.1", | ||
"cucumber": "~3.1.0", | ||
"chai": "~4.1.2" | ||
}, | ||
@@ -27,2 +29,3 @@ "repository": { | ||
}, | ||
"homepage": "https://tinkerpop.apache.org/", | ||
"bugs": { | ||
@@ -32,8 +35,9 @@ "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" | ||
"test": "mocha test/unit test/integration -t 5000", | ||
"features": "cucumber.js --require test/cucumber ../../../../../gremlin-test/features/", | ||
"unit-test": "mocha test/unit" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=6" | ||
} | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
14
0
74316
3
2489
1