Skip to content

Commit

Permalink
Replace WeakMap with a WeakSet
Browse files Browse the repository at this point in the history
  • Loading branch information
qti3e committed Jul 7, 2019
1 parent 192a1c9 commit 6efea53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions index.d.ts
Expand Up @@ -24,14 +24,14 @@ declare namespace elementReady {
readonly stopOnDomReady?: boolean;
}

type Stoppable = {
/**
Stop checking for new elements.
Calling it multiple times does nothing.
*/
stop(): void;
};
type Stoppable = {
/**
Stop checking for new elements.
Calling it multiple times does nothing.
*/
stop(): void;
};

type StoppablePromise<T> = Promise<T> & {
/**
Expand Down
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -59,7 +59,7 @@ elementReady.subscribe = (selector, cb, {
stopOnDomReady = true,
timeout = Infinity
} = {}) => {
const seen = new WeakMap();
const seen = new WeakSet();

let rafId;
let checkFrame = true;
Expand Down Expand Up @@ -91,7 +91,7 @@ elementReady.subscribe = (selector, cb, {
}

cb(element);
seen.set(element, true);
seen.add(element);
}
}

Expand Down

0 comments on commit 6efea53

Please sign in to comment.