scats
Version:
Useful scala classes in typescript
31 lines (30 loc) • 747 B
JavaScript
import { ArrayIterable } from './array-iterable.js';
import { ArrayBuffer, Collection } from './collection.js';
export class AbstractSet extends ArrayIterable {
items;
constructor(items) {
super();
this.items = items;
}
contains(item) {
return this.items.has(item);
}
get toArray() {
return Array.from(this.items.keys());
}
get toCollection() {
return new Collection(Array.from(this.items.keys()));
}
get toSet() {
return new Set(this.items);
}
get isEmpty() {
return this.items.size <= 0;
}
get size() {
return this.items.size;
}
get toBuffer() {
return new ArrayBuffer(Array.from(this.items.keys()));
}
}