@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.
27 lines • 773 B
JavaScript
/**
* @module Collection
*/
import {} from "../../../../collection/contracts/_module-exports.js";
import { resolveInvokable } from "../../../../utilities/_module-exports.js";
/**
* @internal
*/
export class UniqueIterable {
collection;
callback;
constructor(collection, callback = (item) => item) {
this.collection = collection;
this.callback = callback;
}
*[Symbol.iterator]() {
const set = new Set([]);
for (const [index, item] of this.collection.entries()) {
const item_ = resolveInvokable(this.callback)(item, index, this.collection);
if (!set.has(item_)) {
yield item;
}
set.add(item_);
}
}
}
//# sourceMappingURL=unique-iterable.js.map