Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Set method support: Pending support in FireFox, Opera, and Node #23

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ import {
type Storage,
} from "./-private/util.ts";

// many of these do not exist yet
const NEWING_METHODS = [
'difference',
'symmetricDifference',
'intersection',
'union',
];

const QUERYING_METHODS = [
'isDisjointFrom',
'isSubsetOf',
'isSupersetOf',
];

export class SignalSet<T = unknown> implements Set<T> {
private collection = createStorage();

private storages: StorageMap<T> = new Map();

private vals: Set<T>;

private storageFor(key: T): Storage {
Expand Down Expand Up @@ -36,6 +48,20 @@ export class SignalSet<T = unknown> implements Set<T> {
constructor(iterable: Iterable<T>);
constructor(existing?: readonly T[] | Iterable<T> | null | undefined) {
this.vals = new Set(existing);
let self = this;

return new Proxy(self, {
get(target, property, receiver) {
if (!(property in this)) {
if (QUERYING_METHODS.includes(property)) {

}

}

return Reflect.get(target, property, receiver);
}
});
}

// **** KEY GETTERS ****
Expand Down
Loading
Loading