-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some sample files so linting can be tested
- Loading branch information
Showing
4 changed files
with
60 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module 'loglevel' { | ||
function debug(message: string | Record<string, unknown>): void; | ||
const log = { debug }; | ||
export default log; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import localforage from 'localforage'; | ||
|
||
type SerializableValue = Record<string, unknown>; | ||
|
||
export async function getStorageItem( | ||
key: string, | ||
): Promise<SerializableValue | undefined> { | ||
try { | ||
const serializedData = await localforage.getItem<string | null>(key); | ||
if (serializedData === null) { | ||
return undefined; | ||
} | ||
|
||
return JSON.parse(serializedData) as SerializableValue; | ||
} catch (err) { | ||
return undefined; | ||
} | ||
} | ||
|
||
export async function setStorageItem( | ||
key: string, | ||
value: SerializableValue, | ||
): Promise<void> { | ||
try { | ||
const serializedData = JSON.stringify(value); | ||
await localforage.setItem(key, serializedData); | ||
} catch (err) { | ||
console.warn(err); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters