Store

Overview

This document provides a comprehensive list of all available store functions in the dphelper library along with their descriptions and examples.

Based on Memorio by Dario Passariello to manage STATE, STORE, SESSION and OBSERVER. You can use Memorio is you need only state management. DpHelper is indicate when you use a complete suite of tools.

Functions

store.get([store.name])

  • Description: Retrieve an item from local storage.

  • Parameters:

    • name (string): The name of the item to retrieve.

  • Example:

    const value = store.get('itemName');
    console.log(value);

store.set([name, value])

  • Description: Set an item in local storage.

  • Parameters:

    • name (string): The name of the item to set.

    • value (any): The value of the item to set.

  • Example:

    store.set('itemName', value);

store.remove([store.name])

  • Description: Delete an item from local storage.

  • Parameters:

    • name (string): The name of the item to delete.

  • Example:

    store.remove('itemName');

store.removeAll()

  • Description: Remove all items from local storage.

  • Parameters: None

  • Example:

    store.removeAll();

store.quota()

  • Description: Estimate the storage quota and usage.

  • Parameters: None

  • Example:

    const quota = store.quota();
    console.log(quota);

store.size()

  • Description: Calculate the total size of all items in local storage.

  • Parameters: None

  • Example:

    const totalSize = store.size();
    console.log(totalSize);

License

This project is licensed under the MIT License.

Last updated