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 🙏

© 2024 – Pkg Stats / Ryan Hefner

html5-store

v1.0.14

Published

A more user-friendly way to interact with various HTML5 storage libraries

Downloads

5

Readme

html5-store

Browser storage API's are a great way to store local state when you don't need to persist to a database, however they are more verbose than they need to be. LocalStorage and SessionStorage can only store strings, so storing objects requires manual JOSN.stringify() / JSON.parse() when setting and getting data. It would be great if this was done automatically.

Well now it is! With a more streamlined wrapper around these browser API's, html5-store is able to automatically handle things like JSON stringify/parse when setting and getting data, as well as provide handy utilities like clear key formatting so you can tell what utility set your local state.

Cookie storage has always been unnecessarily verbose, and html5-store cleans up the Cookie API to behave as a developer would expect with simple .get(), .set() and .remove() methods.

Installation

npm install html5-store
yarn add html5-store

Local Storage Example

import { Local } from 'html5-store';

const settings = {
  volume: 54,
  currentTrack: '0h141983h8dhwq712873g34-Az',
  position: '1:34'
};

Local.set('settings', settings);

. . .

Local.get('settings');
/**
 * returns:
 * {
 *   volume: 54,
 *   currentTrack: '0h141983h8dhwq712873g34-Az',
 *   position: '1:34'
 * }
 */

 . . .

 Local.remove('settings');
 Local.get('settings'); // returns: false

Session Storage Example

import { Session } from 'html5-store';

const settings = {
  volume: 54,
  currentTrack: '0h141983h8dhwq712873g34-Az',
  position: '1:34'
};

Session.set('settings', settings);

. . .

Session.get('settings');
/**
 * returns:
 * {
 *   volume: 54,
 *   currentTrack: '0h141983h8dhwq712873g34-Az',
 *   position: '1:34'
 * }
 */

 . . .

 Session.remove('settings');
 Session.get('settings'); // returns: false

Cookie Storage Example

import { Cookie } from 'html5-store';

const token = '0h141983h8dhwq712873g34-Az';

Cookie.set('token', token);

. . .

Cookie.get('token');
/**
 * returns:
 * '0h141983h8dhwq712873g34-Az'
 */

 . . .

 Cookie.remove('settings');
 Cookie.get('settings'); // returns: null