mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
Readable.from accepts any iterable or async iterable of strings or Buffers, following from.js: the iterator is taken when the stream is built, before the options are read, next() is looked up and called on each pull, a sync iterator's promise values are awaited, and destroy calls the iterator's throw() and return() only when it has them, reading each method when close() runs. A close() that fails with a second error passes an AggregateError of both to the destroy callback, as aggregateTwoErrors does. In typed code this covers Sets of strings, Map and Set iterators, classes whose [Symbol.iterator]() or [Symbol.asyncIterator]() is a generator method, iterator classes, and async iterator classes, whose return() runs at the end of the stream and on destroy. In JavaScript it covers every iterable; an object whose iterator method is a generator method throws a not-supported error when the stream is built.