16 lines
No EOL
437 B
TypeScript
16 lines
No EOL
437 B
TypeScript
// getLocalStorageData.ts
|
|
|
|
export const getAllLocalStorageItems = (): Record<string, string | null> => {
|
|
const allData: Record<string, string | null> = {};
|
|
if (typeof localStorage !== 'undefined') {
|
|
for (let i = 0; i < localStorage.length; i++) {
|
|
const key = localStorage.key(i);
|
|
if (key) {
|
|
const value = localStorage.getItem(key);
|
|
allData[key] = value;
|
|
}
|
|
}
|
|
}
|
|
return allData;
|
|
};
|
|
|