Skip to content

Commit

Permalink
fix: Fix getAllKeys on web (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis authored Dec 20, 2023
1 parent de2bde2 commit 6fa83b5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/createMMKV.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const createMMKV = (config: MMKVConfiguration): NativeMMKV => {
if (config.path != null) {
throw new Error("MMKV: 'path' is not supported on Web!");
}

// canUseDOM check prevents spam in Node server environments, such as Next.js server side props.
if (!hasAccessToLocalStorage() && canUseDOM) {
console.warn(
Expand Down Expand Up @@ -110,7 +110,9 @@ export const createMMKV = (config: MMKVConfiguration): NativeMMKV => {
},
getAllKeys: () => {
const keys = Object.keys(storage());
return keys.filter((key) => key.startsWith(keyPrefix));
return keys
.filter((key) => key.startsWith(keyPrefix))
.map((key) => key.slice(keyPrefix.length));
},
contains: (key) => storage().getItem(prefixedKey(key)) != null,
recrypt: () => {
Expand Down

0 comments on commit 6fa83b5

Please sign in to comment.