UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

17 lines (16 loc) 610 B
/** Sequence of values designed to be extended that implements the full async generator protocol. */ export class AbstractSequence { [Symbol.toStringTag] = "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` [Symbol.asyncIterator]() { return this; } }