@alwatr/session-storage
v1.0.0
Published
A modern, simple, and robust solution for managing versioned JSON objects in the browser's `sessionStorage`. This package provides a clean, class-based API with a factory function to ensure your application's data persistence is safe, maintainable, and fu
Maintainers
Readme
Alwatr Session Storage Provider
A modern, simple, and robust solution for managing JSON objects in the browser's sessionStorage. This package provides a clean, class-based API with a factory function to ensure your application's data persistence is safe and maintainable within a single browser tab or window.
Core Concepts
This library is built upon a few simple but powerful concepts:
Provider Pattern: Instead of using static functions, you create an instance of a
SessionStorageProviderfor each unique data item you want to manage. This instance is configured once with a name and then used to interact with that specific item.Static Existence Check: The static method
SessionStorageProvider.has()allows you to check if data exists before creating a provider instance. This is highly efficient for scenarios where you only need to know if the data is present, without needing the data itself.Facade Factory Function: The
createSessionStorageProviderfunction acts as a clean entry point (Facade) to the library. This simplifies the API and decouples your code from the internal class implementation.
Installation
# Using yarn
yarn add @alwatr/session-storage
# Using npm
npm install @alwatr/session-storage