Skip to content

Commit

Permalink
+support multiple keys in api
Browse files Browse the repository at this point in the history
  • Loading branch information
maanimis committed Aug 28, 2024
1 parent ddef7aa commit 417ad67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/models/inMemoryStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export default class InMemoryStorage {
return this.storage;
}

removeItem(key) {
delete this.storage[key];
removeItem(...keys) {
for (const key of keys) {
delete this.storage[key];
}
}

clear() {
Expand Down
14 changes: 10 additions & 4 deletions src/models/localStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ class LocalStorage {
this.storage.setItem(key, value);
}

getItem(key) {
return this.storage.getItem(key) || null;
getItem(...keys) {
const result = {};
for (const key of keys) {
result[key] = this.storage.getItem(keys) || null;
}
return result;
}

removeItem(key) {
this.storage.removeItem(key);
removeItem(...keys) {
for (const key of keys) {
this.storage.removeItem(key);
}
}

clear() {
Expand Down

0 comments on commit 417ad67

Please sign in to comment.