Skip to main content
Module

x/storage_helpers/mod.ts

A set of tools to manage localStorage, sessionStorage and more that run on browsers, node and deno. 💾
Latest
import * as storageHelpers from "https://deno.land/x/storage_helpers@v0.5.0/mod.ts";

Variables

A dummy storage that does not store values:

  • length is always 0.
  • setItem and removeItem and clear have no effect.
  • getItem and key always return null.

Functions

Erases all items inside the storage provided by an optional StorageConfig.getStorage | config.getStorage or uses getLocalStorage.

Returns localStorage if present in the current environment or a dummy storage.

Returns sessionStorage if present in the current environment or a dummy storage.

Retrieves a value indexed by the input key to an optional StorageConfig.getStorage | config.getStorage or uses getLocalStorage.

Given an input n returns the nth key of the storage provided in StorageConfig.getStorage | config.getStorage or uses getLocalStorage.

Returns key, optionally enhanced with version and namespace, that is used to index storage values.

Removes an item indexed by key inside the storage provided by an optional StorageConfig.getStorage | config.getStorage or uses getLocalStorage.

Adds the entry key -> config.serialize(value) inside a storage provided by an optional StorageConfig.getStorage | config.getStorage or getLocalStorage.

Interfaces

An optional configuration argument of all the helper functions of storage-helpers that enables to set:

  1. The way data is serialized and hydrated.
  2. Which storage is used.
  3. key version and namespace.
  4. How to handle exceptions.
  5. Validation for hydrated data.

An equivalent to lib.dom.d.ts Storage