New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dht-keyvalue

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dht-keyvalue

Key-value store powered by bittorrent-dht

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

dht-keyvalue

Store key-value pairs on the mainline bittorrent DHT network, and retreive them by key lookup.

This is a work in progress. This version is a minimal viable iteration of this project.

It takes a little bit of time (seconds) to announce to DHT and retrieve the values.

It probably should not be used in production at this time. More work is required for handling updates to the DHT objects. Improvements to usability and security are also needed.

Install

npm i dht-keyvalue

Usage

Example

const dhtKv = require('dht-kv')

let opts = {
 keep: true, // default = true. Keep the DHT object alive in the mainline bittorrent network
 keepalive: 3600000 // default = 3600000. Interval to refresh the DHT object (milliseconds)
}

const dkv = new dhtKv(opts)

let items = [{key: "first key", value: "first value"}, {key: "second key", value: "second value"}]

// log any errors
dkv.on('error', err => {
 console.log(err)
})

// Store the key/value pair(s) on DHT
dkv.put(items)

// Handle responses and do work
for(item in items){
 let key = items[item].key

 dkv.on(key, hash => {

  // Lookup the key
  dkv.lookup(key)
 
  // Found the key 
  dkv.on(hash, value => {
   console.log(value)
 
   // Update the key value
   let updated = Math.random()
   dkv.update(key, updated)
  })
 
 })
}

Keywords

FAQs

Package last updated on 17 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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