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

easy-use-storage

v1.0.2

Published

New storage API that can help user set expired time and no need to use JSON.parse in most scenarios.

Downloads

2

Readme

Easy-use-storage v1.0.0

New storage API that can help user set expired time and no need to use JSON.parse in most scenarios.

GitHub

https://github.com/kamesan012/EasyUseStorage

Installation

npm i easy-use-storage

Usage

import { cusLocalStorageInstance, cusSessionStorageInstance, CusLocalStorage, CusSessionStorage } from 'easy-use-storage'
// Add it to window (optional).
window.cusLocalStorage = cusLocalStorageInstance
window.cusSessionStorage = cusSessionStorageInstance
// You can also create instance by yourself.
const myLocalStorage = new CusLocalStorage() // pass nothing to use default timeout (7 days)
const anotherLocalStorage = new CusLocalStorage(1000 * 60) // pass millisecond
// Usage of cusSessionStorage is the same as cusLocalStorage's.
// You can use it's basic feature as the original localStorage API.
cusLocalStorage.setItem('userId', '135568')
console.log(cusLocalStorage.getItem('userId')) // '135568'
// Original localStorage API only return string type, but our API return any type or result you pass in.
cusLocalStorage.setItem('number', 123)
console.log(cusLocalStorage.getItem('number')) // 123 || our API returns 123 and localStorage API returns '123'
cusLocalStorage.setItem('boolean', true)
console.log(cusLocalStorage.getItem('number')) // true || our API returns true and localStorage API returns 'true'
// You can pass an Object without JSON.parse by using our API.
cusLocalStorage.setItem('commonObj', {
    name: 'test-user',
    age: 18,
    job: ['Frontend Engineer', 'Backend Engineer']
})
// Of course you can get the Object directly.
console.log(cusLocalStorage.getItem('commonObj')) // { name: 'test-user', age: 18, job: ['Frontend Engineer', 'Backend Engineer'] }
// You can pass extra parameter expireTimeout(defalut 7 days) to make it support expiration.
cusLocalStorage.setItem('expired', 'someValue', -1000)
console.log(cusLocalStorage.getItem('expired')) // null
// use default
cusLocalStorage.setItem('stillCanUse', 'someValue', null)
console.log(cusLocalStorage.getItem('stillCanUse')) // 'someValue'
// ⚠ Some object like Date and RegExp may work incorrectly.
cusLocalStorage.setItem('info', {
    name: 'test',
    timestamp: new Date()
});
console.log(cusLocalStorage.getItem('info')) // { name: 'test', timestamp: '2023-02-06T09:12:19.498Z' } Date will be converted to string.