Skip to content

fs-localstorage是一个基于fs文件存储的、提供localstorage api风格的存储库

Notifications You must be signed in to change notification settings

Liang5757/fs-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fs-localstorage

fs-localstorage是一个基于fs文件存储的、提供localstorage api风格的存储库

安装

npm i fs-localstorage -save

使用方式

1.创建实例,第一个参数是存储路径,第二个参数设置仓库容量大小(bytes)默认为5MB

const Localstorage = require('fs-localstorage');

const localstorage = new Localstorage('./store', 50000);

2.可以使用如下localstorage的api

  • length
  • setItem(key, value)
  • getItem(key)
  • removeItem(key)
  • key(n)
  • clear()

在存取时,用JSON.stringifyJSON.parse对数据进行处理

3.利用proxy对localstorage的get、set操作转发到getItemsetItem

About

fs-localstorage是一个基于fs文件存储的、提供localstorage api风格的存储库

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published