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

@accuweather/data_manager

v1.1.12

Published

AccuWeather Data Manager

Downloads

46

Readme

AccuWeather Data Manager

Each website uses a DataManager to set and get cookies and data from localStorage/sessionStorage (if available).

CAUTION: DataManager internally caches and serializes/unserializes data. If you instantiate multiple DataManagers, there could be confusion if you try to retrieve data from one that was set using the other. Because of this, you should only instantiate one DataManager per site, at a high level, and pass it to other modules/functions as necessary.

Instantiate like so:

var DManagerCtor = require('@accuweather/data_manager');
var DManager = new DManagerCtor();

Uses the following methods:

saveData(name, value, expires, path, storageSystem)

name and value should be strings. CAUTION when setting/getting non-string data: behavior may be unexpected. expires is measured in days -- typically we use 365 (one non-leap year). expires defaults to 30 minutes.

path defaults to '/' and probably shouldn't be set to anything other than that. storageSystem, if given, should be either the string 'localStorage' or 'sessionStorage' (this is to ensure that it doesn't fail when undefined in browsers that don't support it).

DManager.saveData('myData', 'example', 365, '/', 'localStorage');

getData(name, storageSystem)

As above, storageSystem (if given) should be the string 'localStorage' or 'sessionStorage'.

var x = DManager.getData('myData', 'localStorage'); // "example"

To reduce the number of cookies we set, we can use "chips" -- serialized key-value pairs within a single cookie value.

saveChip(name, chip, value, expires)

name is the name of the cookie, while chip is the name of the chip within the cookie. Other parameters as above.

DManager.saveChip('foo', 'chip1', 'value1', 365);
DManager.saveChip('foo', 'chip2', 'value2', 365);

getChip(name, chip)

DManager.getChip('foo', 'chip1'); // "value1"
DManager.getChip('foo', 'chip2'); // "value2"

// serialized:
DManager.getData('foo'); // "chip1=value1&chip2=value2"