The next
and yield
methods are equivalent.
By convention, next
is used to consume, and yield
to produce,
but both methods have the same signature and behavior.
They return a promise for the next iteration from the other side of the
connection, and send an iteration with the given value to the other.
Stream.prototype.next = function (value, index) {
return this.yield(value, index);
};
Stream.prototype.yield = function (value, index) {
var dual = duals.get(this);
var incoming = queues.get(this);
var outgoing = queues.get(dual);
outgoing.put(new this.Iteration(value, false, index));
return incoming.get();
};