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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lockerjs

v2.0.0

Published

Extremely light library that makes HTML5 storage usage easier to the edge. No dependencies, no configuration.

Readme

LockerJS - HTML5 Storage Wrapper

Extremely light library that makes HTML5 storage usage easier to the edge. No dependencies, no configuration.

Installation

NPM

npm install --save lockerjs

Yarn

yarn add lockerjs

Usage

import Locker from 'lockerjs';

const locker = new Locker(window.localStorage);
// or
const locker = new Locker(window.sessionStorage);

Features

add

setItem does the job, although it is quite limited as it accepts only String - String values. By using LockerJS you are no longer limited by value types! Saving object with key 1 is as easy as:

const myObj = {
    'name': 'John',
    'surname': 'Test',
};
locker.add(1, myObj);

Isn't that easy? You can use any parameter type as your key and value;

addSafely

Only adds value to specific key if a given key is not already used. Otherwise throws an error.

locker.addSafely('Key 1', 1); //OK
locker.addSafely('Key 1', 123); //ReferenceError: 'Provided key is already in use'

get

getItem allows you to retrieve text value from storage by passing key, but wouldn't that be great just to pass any parameter type? Consider this snippet:

locker.get(123);

Isn't that as easy as one-two-three? There's more! Locker will return you an original value type!

const myArr = [1, 2, 3];
locker.add(1, myArr);
const retrievedArr = locker.get(1);
typeof retrievedArr; // "array"
console.log(retrievedArr); // [1, 2, 3]

Of course, same goes for numbers, objects, ES6 Maps etc.

keyExists

Simply returns true if a given key has been already used, otherwise false

locker.add(2, 1234);
locker.keyExists(2) // True
locker.keyExists({'name': 'John'}) // False

valueExists

Simply returns true if a given value has been already used, otherwise false.

const mySet = new Set();
mySet.set("Some array", [1, 2, 3]);
locker.add(mySet);
locker.valueExists(mySet); // True

clear

Clear the whole storage

locker.add(1, [1, 2]);
locker.clear(); //Empty

size

Returns the size of the storage

locker.add(12, [1,2]);
locker.size(); //2

clearSpecified

Pass an array of keys that shall be removed and Locker will remove only those entries

const testObj = {
    'name': 'John',
}
locker.add(testObj, "We like this customer!");
locker.add(1, 123);
const keysToRemove = ['1', testObj];
locker.clearSpecified(keysToRemove); // Empty

As you have noticed you can mix & match all value types to your preferences.

saveMap

Convert & copy keys and values from ES6 Map into storage.

const sampleMap = new Map();
map.set(1, 'First entry');
map.set(2, 'Second entry');
locker.clear();
locker.saveMap(sampleMap);
locker.get(1); // 'First entry'
locker.get(2); // 'Second entry'

getMap

If you would like to get a 'backup' of client's storage you can do so by invoking saveMap(). It will construct ES6 Map from storage.

locker.add(1, [1, 2, 3]);
const backup = locker.getMap();

Contributing

Issues

Please raise any issues using a template inside ./github folder.

Pull requests

All PRs are more than welcome! Please run

npm test

before submitting a merge request.

License

MIT