File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# fastore - v1.0.5 (under MIT)
22A light-weight package of ` localStorage ` and ` sessionStorage `
33
4- 一个封装 localStorage 及 sessionStorage 的轻量级、快速易用的库。
5-
64![ Build] ( https://img.shields.io/badge/build-passing-green.svg )
75![ Unit Tests] ( https://img.shields.io/badge/tests-51%20passed-green )
86![ npm bundle size] ( https://img.shields.io/bundlephobia/minzip/fastore )
@@ -15,7 +13,7 @@ A light-weight package of `localStorage` and `sessionStorage`
1513
1614## Install
1715
18- #### npm
16+ #### NPM
1917
2018``` javascript
2119$ npm install -- save- dev fastore
@@ -58,6 +56,13 @@ No arguments provided.
5856import { store } from ' fastore'
5957
6058let all = store () // return all key-value pairs using store()
59+
60+ // {
61+ // userid: 'meishan001',
62+ // firstname: '苏',
63+ // ...
64+ // "works.hua": '["潇湘竹石图", "枯木怪石图", "偃松图卷"]'
65+ // }
6166```
6267
6368In the case of ` sessionStorage ` , just use ` session() ` function:
Original file line number Diff line number Diff line change 1212[ English] ( ./README.md ) | [ 简体中文] ( ./zh-CN.md )
1313
1414## 安装
15- ### npm
15+
16+ ### NPM
17+
1618``` cmd
1719$ npm install --save-dev fastore
1820```
1921
2022### CDN
23+
2124``` cmd
2225[unpkg] https://unpkg.com/fastore
2326```
@@ -49,13 +52,6 @@ fastore 即 fast store 之意,顾名思义,目的是提供一个快速使用
4952import { store } from ' fastore'
5053
5154let all = store () // 获得全部键值对
52- ```
53-
54- 对于 ` sessionStorage ` 而言,唯一不同仅仅是使用时的名称:
55- ``` javascript
56- import { store } from ' fastore'
57-
58- let all = store () // 获得全部键值对,以对象形式返回
5955
6056// {
6157// userid: 'meishan001',
@@ -65,6 +61,13 @@ let all = store() // 获得全部键值对,以对象形式返回
6561// }
6662```
6763
64+ 对于 ` sessionStorage ` 而言,唯一不同仅仅是使用时的名称:
65+ ``` javascript
66+ import { session } from ' fastore'
67+
68+ let all = session () // 获得全部键值对,以对象形式返回
69+ ```
70+
6871> ` store ` 及 ` session ` 两者拥有相同的 API 方法,后续示例中,将 ` store ` 替换为 ` session ` 即代表使用的是 ` sessionStorage ` 。
6972
7073### 2. 获取一个值
@@ -244,7 +247,7 @@ let others = store.ns('works.others')
244247others (' kongfu' )
245248```
246249
247- ### Storage 事件
250+ ### 11. Storage 事件
248251
249252你可以通过监听 ` Storage ` 事件,以知悉 ` store ` 中数据项已发生变化。创建、更新或删除数据项时,均能收到通知(但对已存在的键进行赋值则不会触发此事件)。
250253
You can’t perform that action at this time.
0 commit comments