Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

key-file-storage

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

key-file-storage - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

package.json
{
"name": "key-file-storage",
"version": "1.1.1",
"version": "1.1.2",
"description": "Simple cached key-value Node.js storage directly on file system, maps each key to JSON contents of a file.",

@@ -5,0 +5,0 @@ "main": "index.js",

# key-file-storage
Simple key-value Node.js storage directly on file system, maps each key to JSON contents of a file.
### I'll soon make a detailed readme for this module, but for now I just show you some examples :
#### I'll soon make a detailed readme for this module, but for now I just show you some examples :
```
+ Initializing key-file storage :
```javascript
var keyFileStorage = require("key-file-storage");

@@ -14,3 +15,6 @@

var kfs = keyFileStorage();
```
+ Setting a new value to a key :
```javascript
var value = ... // Any JSON-able object

@@ -29,3 +33,6 @@

});
```
+ Getting value of a key : (*Value of a not existing key will be* `null`)
```javascript
// Callback form :

@@ -43,3 +50,6 @@ kfs.get('key', function(err, value) {

});
```
+ Removing a key-file pair :
```javascript
// Callback form :

@@ -56,3 +66,6 @@ kfs.remove('key', function(err) {

});
```
+ Clearing anything in the database folder :
```javascript
// Callback form :

@@ -71,2 +84,6 @@ kfs.clear(function(err) {

NOTE: `undefined` is not supported as a savable value, but `null` is. Saving a key with value `undefined` is equivalent to remove it.
NOTE: `undefined` is not supported as a savable value, but `null` is. Saving a key with value `undefined` is equivalent to remove it.
NOTE: Each key will map to a separate file (*using the key itself as its relative path*) so there is no need to load all the database file for any key access. Also, keys can be relative paths, e.g: `data.json`, `/my/key/01` or `any/other/relative/path/to/a/file`.
NOTE: There is a built-in implemented **cache**, so accessing a certain key once again won't require file-system level operations.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc