current() returns current element of collection. If collection is
empty, then undefined value is returned.
moveNext() tries to move current element to next position. If
moved successfuly this method returns true. Otherwise false
Each child of BasePipe should provide concrete implementation
of _moveNext.
This is how we tell current pipe where to read data from.
Parameters:
moveNext() and current() methods)When we want other pipe object to read data from this pipe we call
this.pipe(other)
Parameters:
setSourcePipe method)To get chainable syntax return destinationPipe
Pipes will not immediately start iterating over source data, unless
we ask them to do so. This allows efficiently delay computation up to the
point where it is absolutely necessary. Calling pipe.forEach begins data
flow.
callback should be a function which will be called for each element of
this pipe.
Example:
g.V() // creates pipe of graph's vertices
// No iteration will start until we call:
.forEach(function(vertex) {
console.log(v.id); // print all vertices
});
When traversing a graph it is very important to know where we came from
to current node. Each pipe object has ability to inspect all chain of
pipes through which traversal algorithm went.
To do so clients should use a PathPipe.
Build array of current objects in the chain of source pipes up to this point.
And add current object of this pipe to the end of the array
Base Pipe
Graph traversal operations in Shremlin are achieved by pipes. Pipes accept input data, and emit transformed data. E.g.
VerticesToVerticesPipeaccepts a vertex as an input and emits adjacent vertices (neighbors). Since each emitted object is also a vertex, it can be used as an input to nextVerticesToVerticesPipe, forming a Pipeline.BasePipeserves as an abstract base class for all pipes in ShremlinNB: If you are familiar with concept of Enumerators in .NET this should be familiar. Like
EnumeratorsPipes havecurrent()andmoveNext()methods. On top of this Pipes are chained into each other thus one pipe serves as a data source to another