build
This commit is contained in:
parent
691387ff9a
commit
7a6d79fe12
16 changed files with 72 additions and 21 deletions
|
|
@ -2,11 +2,18 @@
|
|||
* LocalStorage Tipado
|
||||
* Lê 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue