Skip to content

localStorage util, support version upgrade & data expire. Getting will get the data exactly what set saved

Notifications You must be signed in to change notification settings

gaokun/localstorage-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

localstorage-util

CN

localStorage 的读写操作, 支持版本更新与过期

get操作返回数据类型与set时的数据类型一致

EN

localStorage util, support version upgrade & data expire

get will get the data exactly what set saved

How to use

webpack:

import LocalStorageUtil from 'localstorage-util';

const LS = new LocalStorageUtil({ prefix: 'my_project_' });

LS.set('user', { name: 'Ken' });

const user = LS.get('user');

Browser:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="https://unpkg.com/localstorage-util"></script>
</head>
<body>

<script>
  const myLocalStorage = new LocalStorageUtil({prefix: 'abc'});

  myLocalStorage.set('user', {name: 'zhang', age: 30});

  const user = myLocalStorage.get('user');

  console.log(user);
</script>
</body>
</html>

Contact

Feel free to contact me if you have any questions.

Email: [email protected]

About

localStorage util, support version upgrade & data expire. Getting will get the data exactly what set saved

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published