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

local-js

v0.0.6

Published

Simple local storage tool

Readme

local-js

Simple local storage tools.

Installing

npm i local-js

Basic example

    const { setOneWithTTL, getOneWithTTL } = require('local-js');
   
    const key = 'your_key'; 
    const data = [ 'your', 'data' ];
    const ttl = 3000;
   
    setOneWithTTL(key, data, ttl); // Sets data with an expiry time

    const item = getOneWithTTL(key);
    console.log(item) // [ 'your', 'data '];

Documentation

setOne(key, data)

Info: Sets a single item into localStorage, accepts nested structures.

    const { setOne } = require('local-js');
    
    const key = 'your_key'; 
    const data = [ 'your', 'data' ];
    
    setOne(key, data);

getOne(key)

Info: Gets a single item from localStorage, return null if item does not exist.

    const { getOne } = require('local-js');
    
    const key = 'your_key'; 
    
    getOne(key); // Returns data if key exists, null if it doesnt.

setOneWithTTL(key, data, ttl)

Info: Sets a single item into localStorage with an expiry time(ttl), accepts nested structures.

    const { setOneWithTTL } = require('local-js');
    
    const key = 'your_key'; 
    const data = [ 'your', 'data' ];
    const ttl = 3000;
    
    setOneWithTTL(key, data, ttl);

getOneWithTTL(key)

Info: Get a single item with an expiry time, if the token is expired it will be removed and return null.

    const { getOneWithTTL } = require('local-js');
    
    const key = 'your_key'; 
    
    getOneWithTTL(key); // Return data if key exists and isnt expired, else return null

setMany(array)

Info: Sets many items into localStorage, array of objects containing the keys, key and value.

    const { setMany } = require('local-js');

    const array = [
                    { key: 'first_key', value: 'first_value' }, 
                    { key: 'second_key', value: [ 'second', 'value' ]},
                    ...
                  ];

    setMany(array);

getMany(array)

Info: Gets many items from localStorage.

    const { getMany } = require('local-js');
    
    const array = [ 'first_key', 'second_key', ...];
    
    getMany(array); // [ 'first_value', [ 'second', 'value' ], ...];

setManyWithTTL(array)

Info: Sets many items into localStorage with ttl, array of objects containing the keys, key, value, ttl.

    const { setManyWithTTL } = require('local-js');

    const array = [
                    { key: 'first_key', value: 'first_value', ttl: 1000 }, 
                    { key: 'second_key', value: [ 'second', 'value' ], ttl: 2000 },
                    ...
                  ];

    setManyWithTTL(array);

getManyWithTTL(array)

Info: Gets many items into localStorage with ttl, if the item is expired or does not exist it will be returned as null.

    const { getManyWithTTL } = require('local-js');

    const array = [ 'first_key', 'second_key', ...];

    getManyWithTTL(array); // [ 'first_value', [ 'second', 'value' ], ...];

deleteOne(key)

Info: Removes a single item from localStorage.

    const { deleteOne } = require('local-js');

    const key = 'my_key';
    deleteOne(key);

deleteAll()

Info: Clears all data from localStorage.

    const { deleteAll } = require('local-js');

    deleteAll();

pruneExpired()

Info: Clears all keys with TTL that have expired.

    const { pruneExpired } = require('local-js');

    pruneExpired();

getAll()

Info: Get all items from local storage.

    const { getAll } = require('local-js');

    getAll(); // [ { key: 'your_key', data: [ 'your', 'data' ] }, ...];