This commit is contained in:
Luiz Silva 2026-04-15 12:24:38 -03:00
parent 7a6d79fe12
commit f5c4db0701
15 changed files with 21 additions and 72 deletions

View file

@ -2,18 +2,11 @@
* LocalStorage Tipado
* ou grava um valor no localStorage, mantendo o tipo genérico <T>.
*/
export const localValor = <T>(
chave_: string | any,
valor?: T | null,
): T | null => {
const localStorage =
"localStorage" in globalThis ? (globalThis as any).localStorage : undefined
export const localValor = <T>(chave_: string | any, valor?: T | null): T | null => {
const localStorage = "localStorage" in globalThis ? (globalThis as any).localStorage : undefined
if (typeof localStorage == "undefined") return null
const chave =
typeof chave_ === "string"
? chave_
: encodeURIComponent(JSON.stringify(chave_))
const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_))
try {
// Grava valor se fornecido