mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 19:24:03 +00:00
Finalize Typescript restructure
This commit is contained in:
@@ -25,6 +25,26 @@ export function get<T>(key: string): T | null {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a boolean from localStorage while tolerating legacy string values.
|
||||
*
|
||||
* @param key - The localStorage key
|
||||
* @returns True only when the stored value represents a truthy boolean
|
||||
*/
|
||||
export function getBoolean(key: string): boolean {
|
||||
const value = get<boolean | string>(key)
|
||||
|
||||
if (typeof value === 'boolean') {
|
||||
return value
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return value.toLowerCase() === 'true'
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a value in localStorage as JSON.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user