Skip to content

Commit c10c5e9

Browse files
authored
Merge pull request #2 from artmakarov/dev
Update README.md
2 parents a9e7aef + 6d14ab2 commit c10c5e9

File tree

1 file changed

+68
-5
lines changed

1 file changed

+68
-5
lines changed

README.md

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,82 @@
1-
# Welcome to simple-data-storage
1+
# SData.js
22
![Version](https://img.shields.io/badge/version-0.1.0-blue.svg?cacheSeconds=2592000)
33
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/artmakarov/simple-data-storage/graphs/commit-activity)
44
[![License: MIT](https://img.shields.io/github/license/artmakarov/simple-data-storage)](https://github.com/artmakarov/simple-data-storage/blob/master/LICENSE)
55

6-
> Simple key-value storage
6+
> Simple key-value storage in the browser or node
7+
8+
9+
## Install
10+
11+
```shell script
12+
npm i simple-data-storage
13+
```
14+
15+
in browser:
16+
17+
```
18+
<script src="//unpkg.com/[email protected]/dist/sdata.min.js"></script>
19+
```
20+
21+
22+
## Usage example
23+
24+
```js
25+
const sdata = require('simple-data-storage');
26+
27+
sdata('one_key', 'one_value');
28+
console.log(sdata('one_key')); //=> one_value
29+
30+
sdata(321, 963);
31+
sdata('other key', { abc: 'boom!' });
32+
console.log(sdata(321)); //=> 963
33+
console.log(sdata('321')); //=> 963
34+
console.log(sdata('other key')); //=> { abc: 'boom!' }
35+
console.log(sdata('other key').abc); //=> boom!
36+
37+
// clear one item
38+
sdata.clear('other key');
39+
console.log(sdata('other key')); //=> undefined
40+
console.log(sdata('one_key')); //=> one_value
41+
42+
// clear all items
43+
sdata(123, ['test', 4]);
44+
sdata.clear();
45+
console.log(sdata(123)); //=> undefined
46+
console.log(sdata('one_key')); //=> undefined
47+
```
48+
49+
In the browser, use the global function **SData()**
50+
51+
```html
52+
<script>
53+
SData('key', { data: [1, 'two', { other: 3 }] });
54+
alert(SData('key').data[2].other); //=> 3
55+
</script>
56+
```
57+
58+
## Development
59+
60+
```shell script
61+
git clone [email protected]:artmakarov/simple-data-storage.git
62+
cd simple-data-storage
63+
npm install
64+
npm run build
65+
```
66+
67+
#### Tests
68+
69+
```shell script
70+
npm run test
71+
```
72+
773

874
## Contributing
975

1076
Contributions, issues and feature requests are welcome!
1177

1278
Feel free to check [issues page](https://github.com/artmakarov/simple-data-storage/issues).
1379

14-
## Show your support
15-
16-
Give a ⭐️ if this project helped you!
1780

1881
## License
1982

0 commit comments

Comments
 (0)