@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.
32 lines • 834 B
JavaScript
/**
* @module Collection
*/
import {} from "../../../../collection/contracts/_module-exports.js";
/**
* @internal
*/
export class AsyncSlidingIteralbe {
collection;
chunkSize;
step;
constructor(collection, chunkSize, step) {
this.collection = collection;
this.chunkSize = chunkSize;
this.step = step;
}
async *[Symbol.asyncIterator]() {
if (this.step <= 0) {
return;
}
const size = await this.collection.size();
for (let index = 0; index < size; index += this.step) {
const start = index;
const end = index + this.chunkSize;
yield this.collection.slice(start, end);
if (end >= size) {
break;
}
}
}
}
//# sourceMappingURL=async-sliding-iterable.js.map