This commit is contained in:
Luiz Silva 2026-04-15 11:55:17 -03:00
parent 691387ff9a
commit 7a6d79fe12
16 changed files with 72 additions and 21 deletions

View file

@ -2,11 +2,18 @@
* 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