npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

simplify-storage

v1.0.1

Published

A library for working with different types of storage (localStorage, sessionStorage, cookieStorage)

Readme

Simplify Storage

Simplify Storage is a JavaScript library for easily managing different types of web storage. It provides a unified interface to work with localStorage, sessionStorage, and cookieStorage with added features such as serialization and deserialization of data.

Features

  • Supports localStorage, sessionStorage, and cookieStorage.
  • Automatic serialization and deserialization of arrays and objects.
  • Easy-to-use API for storing, retrieving, and removing data.
  • Supports querying and clearing the storage.

Installation

You can install simplify-storage using npm:

npm install simplify-storage
Or you can add it to your project directly via a <script> tag in the HTML:

html

<script src="path-to-your-library/script.js"></script>
API
setInStorage(key, data, type = "local")
Stores data in the specified storage type (localStorage, sessionStorage, or cookieStorage).

Parameters

key: The key under which the data will be stored.
data: The data to be stored. Can be a string, number, boolean, array, or object.
type: The type of storage to use. Defaults to localStorage.
Example

javascript

setInStorage("username", "JohnDoe", "local");
getFromStorage(key, type)
Retrieves the data stored under the specified key from the specified storage type.

Parameters

key: The key of the data to retrieve.
type: The type of storage to use. Defaults to localStorage.
Returns: The stored data, or null if the key does not exist.

Example

javascript

const username = getFromStorage("username", "local");
console.log(username); // Outputs: "JohnDoe"
removeFromStorage(key, type = "local")
Removes the data stored under the specified key from the specified storage type.

Parameters

key: The key of the data to remove.
type: The type of storage to use. Defaults to localStorage.
Example

javascript

removeFromStorage("username", "local");
clearStorage(type = "local")
Clears all data from the specified storage type.

Parameters

type: The type of storage to clear. Defaults to localStorage.
Example

javascript

clearStorage("local");
getAllStorageItems(type = "local")
Returns all items stored in the specified storage type.

Parameters

type: The type of storage to query. Defaults to localStorage.
Returns: An array of objects, each containing a key and value.

Example

javascript

const items = getAllStorageItems("local");
console.log(items); // Outputs an array of stored items
hasItemInStorage(key, type = "local")
Checks if a specific key exists in the specified storage type.

Parameters

key: The key to check.
type: The type of storage to check. Defaults to localStorage.
Returns: true if the key exists, false otherwise.

Example

javascript

const hasUsername = hasItemInStorage("username", "local");
console.log(hasUsername); // Outputs: true or false
CookieStorage
CookieStorage is a class that mimics the behavior of localStorage and sessionStorage, but stores data in cookies. It provides the same methods: setItem, getItem, removeItem, clear, key, and getAllItems.

Example
javascript

const cookieStorage = new CookieStorage();
cookieStorage.setItem("user", "JaneDoe");
console.log(cookieStorage.getItem("user")); // Outputs: "JaneDoe"
License
This project is licensed under the MIT License - see the LICENSE file for details.

Contributing
If you have any ideas or improvements for this library, feel free to fork it and create a pull request. Contributions are always welcome!

Contact
For any issues or suggestions, please open an issue or contact ITSawa.


### Explanation:
- The `README.md` explains the key features and functionality of the `simplify-storage` library.
- The **API** section outlines how to use the library, with examples for storing, retrieving, and managing data in different storage types.
- The `CookieStorage` class and its methods are described in detail, showcasing how it can be used as an alternative to other storage types.
- The **Installation** and **License** sections provide basic setup instructions and licensing information.