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

manager-local-storage

v1.1.0

Published

A simple tool to manage localStorage!

Downloads

9

Readme

localStorage Manager

How it works?

This function runs JSON.stringify every time it sets a new key in your localStorage, and runs JSON.parse every time it gets a key from localStorage. It also enables multiple operations with just one call. For example, you can get multiple keys from your localStorage, with just one line and without worrying about JSON.parse for each one.

const lS = require('lS');

The lS object has 3 functions: set, get, remove:

set:

The set function has two ways to be executed:

  1. Individual:

In this case, the name of the key to save in localStorage will be mandatory a string or a number and the the value to save in your key will be mandatory.

Example:

lS.set('email', '[email protected]');

This will save in localStorage a key called "email" with the value being "[email protected]".

  1. Multiple:

In this case, the function must receive only an object, containing at least two keys with their respective values.

Example:

lS.set({
	name: 'Gabriel',
	age: 20,
});

This will save 2 different keys to your localStorage. The first with the key "name" and the value "Gabriel", and the second the key "age" with the value 20.


get

The get function has two ways to be executed:

  1. Individual:

In this case, the function must receive only a string or a number with the key of the localStorage you want to get.

Example:

lS.get('email');

This will return the value of the "email" key stored in your localStorage. For example "[email protected]".

  1. Multiple:

In this case, the function must receive only an array, containing at least two keys.

Example:

lS.get(['name', 'age']);

This will return an object with at least two keys, each key being a key from the array you passed and their respective values.

Example:

{
	name: "Gabriel",
	age: 20,
}

remove

The remove function has two ways to be executed:

  1. Individual:

In this case, the function must receive only a string or a number being the key of the localStorage you want to remove.

Example:

lS.remove('email');

This will remove the "email" key from your localStorage.

  1. Multiple:

In this case, the function must receive only an array, containing at least two keys.

Example:

lS.remove(['name', 'age']);

This will remove the "name" and "age" keys from your localStorage.




🇧🇷 Gerenciador do localStorage

Como funciona?

Essa função executa JSON.stringify toda vez que for definir uma nova chave no seu localStorage e executa JSON.parse toda vez que obtém uma chave de localStorage. Também possibilita várias operações com apenas uma chamada. Por exemplo, você pode pegar várias chaves do seu localStorage, com apenas uma linha e sem se preocupar com JSON.parse de cada uma.


O objeto lS possue 3 funções: set, get, remove:

set:

A função set tem duas maneiras de ser executada:

  1. Individual:

Neste caso, a função receberá o nome da chave para salvar no localStorage que será obrigatoriamente uma string ou um número e o valor a ser salvo em sua chave será obrigatório.

Exemplo:

lS.set('email', '[email protected]');

Isso salvará no localStorage uma chave chamada "email" com o valor "[email protected]".

  1. Vários:

Neste caso, o primeiro parâmetro é obrigatóriamente um objeto, contendo pelo menos duas chaves com seus respectivos valores, e o segundo parâmetro não é utilizado.

Exemplo:

lS.set({
	nome: 'Gabriel',
	idade: 20,
});

Isso irá salvar 2 chaves diferentes no seu localStorage. a primeira com a chave "nome" e o valor "Gabriel", e a segunda com a chave "idade" e o valor 20.


get

A função get tem duas maneiras de ser executada:

  1. Individual:

Nesse caso, a função receberá obrigatoriamente uma string ou um número sendo a chave do localStorage que você deseja obter.

Exemplo:

lS.get('email');

Isso retornará o valor da chave "email" armazenada em seu localStorage. Por exemplo "[email protected]".

  1. Vários:

Nesse caso, a função receberá obrigatoriamente um array contendo pelo menos duas chaves.

Exemplo:

lS.get(['name', 'age']);

Isso retornará um objeto com pelo menos duas chaves, sendo cada chave uma chave do array que você passou e seus respectivos valores.

Exemplo:

{
	nome: "Gabriel",
	idade: 20,
}

remove

A função remove tem duas maneiras de ser executada:

  1. Individual:

Nesse caso, a função receberá obrigatoriamente uma string ou um número sendo a chave do localStorage que você deseja remover.

Example:

lS.remove('email');

Isso removerá a chave "email" do seu localStorage.

  1. Vários:

Nesse caso, a função receberá obrigatoriamente um array, contendo pelo menos duas chaves.

Exemplo:

lS.remove(['nome', 'idade']);

Isso removerá as chaves "nome" e "idade" do seu localStorage.