@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
25 lines • 805 B
JavaScript
/**
* @module Collection
*/
import {} from "../../../../collection/contracts/_module-exports.js";
import {} from "../../../../utilities/_module-exports.js";
/**
* @internal
*/
export class AsyncReverseIterable {
collection;
chunkSize;
makeCollection;
constructor(collection, chunkSize, makeCollection) {
this.collection = collection;
this.chunkSize = chunkSize;
this.makeCollection = makeCollection;
}
async *[Symbol.asyncIterator]() {
yield* await this.collection
.chunk(this.chunkSize)
.map(async (item) => this.makeCollection([...(await item.toArray())].reverse()))
.reduce((collection, item) => collection.prepend(item), this.makeCollection([]));
}
}
//# sourceMappingURL=async-reverse-iterable.js.map