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

orbit-db-pubsub

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orbit-db-pubsub - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

2

package.json
{
"name": "orbit-db-pubsub",
"version": "0.1.5",
"version": "0.1.6",
"description": "Message propagation module for orbit-db",

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

@@ -20,17 +20,4 @@ 'use strict'

if (this._ipfs.pubsub) {
this._ipfs.pubsub.subscribe(hash, { discover: true }, (err, stream) => {
if (err)
logger.error(err)
logger.debug(`Subscribed to '${hash}'`)
if (stream && this._subscriptions[hash]) {
this._subscriptions[hash].stream = stream
stream.on('data', this._handleMessage.bind(this))
// TODO: handle end of stream
// stream.on('end', () => console.log("Disconnected from pubsub"))
}
})
}
if (this._ipfs.pubsub)
this._ipfs.pubsub.subscribe(hash, { discover: true }, this._handleMessage.bind(this))
}

@@ -41,5 +28,3 @@ }

if(this._subscriptions[hash]) {
if (this._subscriptions[hash].stream)
this._subscriptions[hash].stream.cancel()
this._ipfs.pubsub.unsubscribe(hash, this._handleMessage)
delete this._subscriptions[hash]

@@ -52,3 +37,3 @@ logger.debug(`Unsubscribed from '${hash}'`)

if(this._subscriptions[hash] && this._ipfs.pubsub)
this._ipfs.pubsub.publish(hash, message)
this._ipfs.pubsub.publish(hash, new Buffer(message))
}

@@ -62,9 +47,8 @@

_handleMessage(message) {
const hash = message.topicIDs[0]
const hash = message.topicCIDs[0]
const data = message.data.toString()
const subscription = this._subscriptions[hash]
if(subscription && subscription.onMessage && data) {
if(subscription && subscription.onMessage && data)
subscription.onMessage(hash, data)
}
}

@@ -71,0 +55,0 @@ }

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