shelving
Version:
Toolkit for using data in JavaScript.
17 lines (16 loc) • 610 B
JavaScript
/** Sequence of values designed to be extended that implements the full async generator protocol. */
export class AbstractSequence {
[] = "Sequence";
async return(returnValue) {
// Default behaviour for a generator is to return `done: true` and the input value.
return { done: true, value: await returnValue };
}
throw(reason) {
// Default behaviour for a generator is to throw the error back out of the iterator and not continue.
throw reason;
}
// Implement `AsyncIterable`
[]() {
return this;
}
}