rafa
Version:
Rafa.js is a Javascript framework for building concurrent applications.
23 lines (20 loc) • 701 B
JavaScript
// # constructor(value: A): DoneMessage
// The last message sent though a stream that didn"t error out and contains
// the last value.
function DoneMessage(value) {
this.value = value;
if (value === undefined) {
this.isValue = false;
this.map = this.contextid;
}
}
inherit(DoneMessage, Message, {
isDone: true,
// # filter(predicate: A => Bool): DoneMessage
// Unlike the normal filter on a message, the done message must never return
// `undefined` since it should still continue walking the tree, so if the
// predicate does not match, return a new done message without a value.
filter(predicate) {
return predicate(this.value) ? this : new DoneMessage();
}
});