Skip to content

Commit

Permalink
Use new* in naming
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Mar 7, 2024
1 parent 18ebe0b commit b44cbec
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,19 @@ export const openStore = (

document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") {
getEntries(config).tapOk((entries) => {
const keys = entries.map(([key]) => key);

for (const [key, value] of entries) {
if (typeof key === "string") {
store.set(key, value);
}
}
getEntries(config).tapOk((newEntries) => {
const newKeys = newEntries.map(([key]) => key);

for (const key of store.keys()) {
if (!keys.includes(key)) {
if (!newKeys.includes(key)) {
store.delete(key);
}
}
for (const [key, value] of newEntries) {
if (typeof key === "string") {
store.set(key, value);
}
}
});
}
});
Expand Down

0 comments on commit b44cbec

Please sign in to comment.