0.0.4 • Published 3 years ago

@tomekf/storage-ttl v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@tomekf/storage-ttl

Custom storage with JSON, TTL and protection against DOM exception when local storage is blocked

Installation

npm i @tomekf/storage-ttl # or yarn add @tomekf/storage-ttl

Usage

import { sessionStorage }, localStorage from '@tomekf/storage-ttl';

const ttlInMiliseconds = 1000;

localStorage.setJsonWithTtl('pikok', { longTail: true }, ttlInMiliseconds);

const { longTail } = sessionStorage.getJsonWithTtl('sparrow');

Methods/props

length
support
originalStorage
setJson
getJson
setJsonWithTtl
getJsonWithTtl
setItem
getItem
removeItem
key
clear

Test

git clone git@github.com:tomek-f/storage-ttl.git
cd ./storage-ttl
npm i # or yarn
npm test # or yarn test
npm run eslint-src # or yarn (run) eslint-src

Versions

  • ES5 CommonJs @tomekf/storage-ttl/dist/…
  • ES6+ with ESM @tomekf/storage-ttl/src/…

Changelog

View on github.

0.0.4

3 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

6 years ago

0.0.0

6 years ago