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

localstorage-helpr

v1.0.5

Published

Handle window.localStorage more securely through this Helper, which applies some object validations and object parse to string (and vice versa).

Downloads

31

Readme

Local Storage Helper

NPM: https://www.npmjs.com/package/localstorage-helpr

  • 🇧🇷 Lide de forma mais segura com o window.localStorage através deste Helper, que aplica algumas validações de objeto e parse de objetos para string (e vice-versa).

  • 🇬🇧 Handle window.localStorage more securely through this Helper, which applies some object validations and object parse to string (and vice versa).

  • GitHub

  • Stackblitz - Live Demo [JS vanilla]

  • Stackblitz - Live Demo [React Web]


🇧🇷 Como usar | 🇬🇧 How to use

  • 🇧🇷 Rode npm i --save localstorage-helpr ou yarn add localstorage-helpr

  • 🇬🇧 Run npm i --save localstorage-helpr or yarn add localstorage-helpr

const { create, update, remove, read, clear } = require('localstorage-helpr')

const KEY = 'CHAVE'
const VALUE = 'VALOR'

// 🇧🇷 Cria um item no LocalStorage | 🇬🇧 Creates an item in LocalStorage
create(KEY, VALUE)

// 🇧🇷 Atualiza um item no LocalStorage | 🇬🇧 Updates an item in LocalStorage
update(KEY, VALUE)

// 🇧🇷 Remove um item no LocalStorage | 🇬🇧 Removes an item in LocalStorage
remove(KEY, VALUE)

// 🇧🇷 Lê o valor de um item no LocalStorage | 🇬🇧 Reads the value of an item in LocalStorage
read(KEY)

// 🇧🇷 Limpa o LocalStorage | 🇬🇧 Clean LocalStorage
clear()

// -----------------------------------------------------

// > BONUS

// 🇧🇷 Você tem acesso aos métodos usados internamente para manipular os dados
// 🇬🇧 You have access to the methods used internally to manipulate the data

const { isObject, objectDeserialize, objectSerialize, } = require('localstorage-helper')

let obj = { a: 1, b: 2 }
let arrayIsObj = [ 1, 3, 5, 7, 9]
let number = 33

isObject(obj) // true
isObject(number) // false
isObject(arrayIsObj) // true

objectSerialize(obj) // "{"a":1,"b":2}"
objectSerialize(arrayIsObj) // "[ 1, 3, 5, 7, 9]"

objectDeserialize(obj) // { a: 1, b: 2 }
objectDeserialize(arrayIsObj) // [ 1, 3, 5, 7, 9]
  • Imagem de demonstração/Demo image

🇧🇷 Detalhes | 🇬🇧 Details

  • 🇧🇷 Por baixo dos panos ao criar ou atualizar um item, se for um objeto ele irá serializar para string, assim não corremos o risco de perder os dados ou corrompe-los, e na hora de recuperar com o read ele irá desserializar para que você tenha seu objeto intacto.

  • 🇬🇧 Under the hood when creating or updating an item, if it is an object it will serialize to string, so we don't run the risk of losing data or corrupting it, and when recovering with read it will deserialize for you to have your object intact.

  • 🇧🇷 Caso sinta necessidade de entender melhor sobre os métodos, você pode conferir os testes de unidade aqui dentro de cada pasta tem seu respectivo arquivo de teste.

  • 🇬🇧 If you feel the need to better understand the methods, you can check the unit tests here inside each folder has its respective test file.