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

node-kv-storage

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-kv-storage - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

5

index.js
const path = require('path');
const crypto = require('crypto');
const storage = require('node-persist');
const md5 = key => crypto.createHash('md5').update(key).digest('hex');
function coerceKey (key) {

@@ -71,3 +74,3 @@ const coercedKey = coerceKeyInner(key);

const baseDir = process.env.NODE_KV_STORAGE_DIR || global.NODE_KV_STORAGE_DIR || process.cwd();
const dirName = name === DEFAULT_STORAGE_AREA_NAME ? 'storage' : name;
const dirName = name === DEFAULT_STORAGE_AREA_NAME ? 'storage' : md5(name);
const db = storage.create({

@@ -74,0 +77,0 @@ dir: path.resolve(baseDir, '.node-persist', dirName),

2

package.json
{
"name": "node-kv-storage",
"version": "1.1.1",
"version": "2.0.0",
"description": "Wrapper around node-persist that conforms to the std:kv-storage interface",

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

@@ -21,7 +21,9 @@ # Node KV Storage

// Compatible with node-persist for string and binary keys
await require('node-persist').init()
await require('node-persist').setItem('foo', { b: 4 })
// Note that this only works for the default storage area
const nodePersist = require('node-persist')
await nodePersist.init()
await nodePersist.setItem('foo', { b: 4 })
console.log(await storage.get('foo'))
await require('node-persist').setItem(Buffer.from([0x1, 0x2]), { d: 6 })
await nodePersist.setItem(Buffer.from([0x1, 0x2]), { d: 6 })
console.log(await storage.get(Buffer.from([0x1, 0x2])))

@@ -55,3 +57,2 @@

* Using typed arrays as keys works, but when using `keys()` or `entries()` they will be returned in the form `JSON.parse(JSON.stringify(yourTypedArray))`. Typically this will look like `{ '0': 255, '1': 255, ... }`.
* Storage areas with the name `default` and `storage` will both map to the directory `storage`.

@@ -58,0 +59,0 @@ ## Questions

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