* Decodes a storage key back to its original form. * This is the inverse of encodeStorageKey. * * @param encodedKey - The encoded key from storage * @returns The original key (string or number)
(encodedKey: string)
| 180 | * @returns The original key (string or number) |
| 181 | */ |
| 182 | function decodeStorageKey(encodedKey: string): string | number { |
| 183 | if (encodedKey.startsWith(`n:`)) { |
| 184 | return Number(encodedKey.slice(2)) |
| 185 | } |
| 186 | if (encodedKey.startsWith(`s:`)) { |
| 187 | return encodedKey.slice(2) |
| 188 | } |
| 189 | // Fallback for legacy data without encoding |
| 190 | return encodedKey |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Creates an in-memory storage implementation that mimics the StorageApi interface |