-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update readme add new method for check key exist
- Loading branch information
1 parent
42354c0
commit e0b4408
Showing
2 changed files
with
60 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
# Node Disk Storage (NDS) | ||
|
||
[![Build Status](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/badges/build.png?b=main)](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/build-status/main) [![Coverage Status](https://coveralls.io/repos/github/restuwahyu13/node-disk-storage/badge.svg?branch=main)](https://coveralls.io/github/restuwahyu13/node-disk-storage?branch=main) [![CodeFactor](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage/badge)](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage) [![codebeat badge](https://codebeat.co/badges/5611b53e-e00a-40c1-bab2-b9a8f5592b33)](https://codebeat.co/projects/github-com-restuwahyu13-node-disk-storage-main) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d74af409b71641fb96484df3dc582365)](https://www.codacy.com/gh/restuwahyu13/node-disk-storage/dashboard?utm_source=github.com&utm_medium=referral&utm_content=restuwahyu13/node-disk-storage&utm_campaign=Badge_Grade)![node-current](https://img.shields.io/node/v/node-disk-storage?style=flat-square) ![npm](https://img.shields.io/npm/dm/node-disk-storage) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) | ||
[![Build Status](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/badges/build.png?b=main)](https://scrutinizer-ci.com/g/restuwahyu13/node-disk-storage/build-status/main) | ||
[![Coverage Status](https://coveralls.io/repos/github/restuwahyu13/node-disk-storage/badge.svg?branch=main)](https://coveralls.io/github/restuwahyu13/node-disk-storage?branch=main) | ||
[![CodeFactor](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage/badge)](https://www.codefactor.io/repository/github/restuwahyu13/node-disk-storage) | ||
[![codebeat badge](https://codebeat.co/badges/5611b53e-e00a-40c1-bab2-b9a8f5592b33)](https://codebeat.co/projects/github-com-restuwahyu13-node-disk-storage-main) | ||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d74af409b71641fb96484df3dc582365)](https://www.codacy.com/gh/restuwahyu13/node-disk-storage/dashboard?utm_source=github.com&utm_medium=referral&utm_content=restuwahyu13/node-disk-storage&utm_campaign=Badge_Grade)![node-current](https://img.shields.io/node/v/node-disk-storage?style=flat-square) | ||
![npm](https://img.shields.io/npm/dm/node-disk-storage) | ||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) | ||
|
||
**node-disk-storage** a simple fast and secure `local storage` for `nodejs`, you can store any data using key and value, and then your data will be **encrypt** to be like this `�+�)data|ZGF0YXxqb2huK2RvZV5eXiQwfDFd^^^$0|1`. | ||
**node-disk-storage** a simple fast and secure `local storage` for `nodejs`, you can store any data using key and value, and then your data will be **encrypt** | ||
to be like this `�+�)data|ZGF0YXxqb2huK2RvZV5eXiQwfDFd^^^$0|1`. | ||
|
||
<img src="images/nds-work.png" alt="example-nds-work"/> | ||
|
||
|
@@ -20,23 +27,32 @@ | |
```bash | ||
$ npm install node-disk-storage -S or yarn add node-disk-storage -S | ||
``` | ||
|
||
## API Reference | ||
|
||
- #### Node Disk Storage Options Property | ||
|
||
+ **minSize** limit data size, before saving into disk, default value to **1MB** | ||
+ **maxSize** limit data size, before saving into disk, default value to **25MB** | ||
- **minSize** limit data size, before saving into disk, default value to **1MB** | ||
- **maxSize** limit data size, before saving into disk, default value to **25MB** | ||
|
||
- #### set(key: string, value: any): Promise<boolean | undefined> | ||
|
||
set data using key and value, into disk | ||
|
||
- #### get(key: string): Promise<any | undefined> | ||
|
||
get specific data using key, after saving data into disk | ||
|
||
- #### key(key: string): Promise<boolean | undefined> | ||
|
||
get specific key, after saving data into disk | ||
|
||
- #### remove(key: string): Promise<boolean | undefined> | ||
|
||
remove specific data already exist using key, after saving data into disk | ||
|
||
- #### clear(): Promise<boolean | undefined> | ||
|
||
clear all keys exist, after saving data into disk | ||
|
||
- #### keys(): Promise<string[] | undefined> | ||
|
@@ -47,37 +63,39 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S | |
- ##### Example Usage Using CommonJs With JavaScript | ||
|
||
```javascript | ||
const { NodeDiskStorage } = require('node-disk-storage') | ||
|
||
const nds = new NodeDiskStorage() | ||
|
||
;(async () => { | ||
await nds.set("user", { | ||
id: 1, | ||
name: 'Leanne Graham', | ||
username: 'Bret', | ||
email: '[email protected]', | ||
address: { | ||
street: 'Kulas Light', | ||
suite: 'Apt. 556', | ||
city: 'Gwenborough', | ||
zipcode: '92998-3874', | ||
geo: { lat: '-37.3159', lng: '81.1496' } | ||
}, | ||
phone: '1-770-736-8031 x56442', | ||
website: 'hildegard.org', | ||
company: { | ||
name: 'Romaguera-Crona', | ||
catchPhrase: 'Multi-layered client-server neural-net', | ||
bs: 'harness real-time e-markets' | ||
} | ||
}) | ||
await nds.get("user") | ||
await nds.keys() | ||
await nds.remove("user") | ||
await nds.clear() | ||
})() | ||
const { NodeDiskStorage } = require('node-disk-storage') | ||
|
||
const nds = new NodeDiskStorage() | ||
|
||
;(async () => { | ||
await nds.set('user', { | ||
id: 1, | ||
name: 'Leanne Graham', | ||
username: 'Bret', | ||
email: '[email protected]', | ||
address: { | ||
street: 'Kulas Light', | ||
suite: 'Apt. 556', | ||
city: 'Gwenborough', | ||
zipcode: '92998-3874', | ||
geo: { lat: '-37.3159', lng: '81.1496' } | ||
}, | ||
phone: '1-770-736-8031 x56442', | ||
website: 'hildegard.org', | ||
company: { | ||
name: 'Romaguera-Crona', | ||
catchPhrase: 'Multi-layered client-server neural-net', | ||
bs: 'harness real-time e-markets' | ||
} | ||
}) | ||
await nds.get('user') | ||
await nds.key('user') | ||
await nds.keys() | ||
await nds.remove('user') | ||
await nds.clear() | ||
})() | ||
``` | ||
|
||
- ##### Example Usage Using CommonJs With JavaScript And Options | ||
|
||
```javascript | ||
|
@@ -107,6 +125,7 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S | |
} | ||
}) | ||
await nds.get("user") | ||
await nds.key('user') | ||
await nds.keys() | ||
await nds.remove("user") | ||
await nds.clear() | ||
|
@@ -141,6 +160,7 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S | |
} | ||
}) | ||
await nds.get("user") | ||
await nds.key('user') | ||
await nds.keys() | ||
await nds.remove("user") | ||
await nds.clear() | ||
|
@@ -175,6 +195,7 @@ $ npm install node-disk-storage -S or yarn add node-disk-storage -S | |
} | ||
}) | ||
await nds.get("user") | ||
await nds.key('user') | ||
await nds.keys() | ||
await nds.remove("user") | ||
await nds.clear() | ||
|
@@ -206,7 +227,8 @@ For information on bugs related to package libraries, please visit [here](https: | |
## Contributing | ||
Want to make **node-disk-storage** more perfect ? Let's contribute and follow the [contribution guide.](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) | ||
Want to make **node-disk-storage** more perfect ? Let's contribute and follow the | ||
[contribution guide.](https://github.com/restuwahyu13/node-disk-storage/blob/main/CONTRIBUTING.md) | ||
## License | ||
|