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

multifeed

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multifeed - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

25

index.js

@@ -17,2 +17,3 @@ var raf = require('random-access-file')

this._feeds = {}
this._feedKeyToFeed = {}

@@ -48,2 +49,8 @@ this._hypercore = hypercore

Multicore.prototype._addFeed = function (feed, name) {
this._feeds[name] = feed
this._feedKeyToFeed[feed.key.toString('hex')] = feed
this.emit('feed', feed, name)
}
Multicore.prototype.ready = function (cb) {

@@ -66,5 +73,5 @@ this._ready(cb)

if (!err && name) {
self._feeds[name] = feed
self._addFeed(feed, name)
} else {
self._feeds[''+n] = feed
self._addFeed(feed, String(n))
}

@@ -109,4 +116,3 @@ })

feed.ready(function () {
self._feeds[idx] = feed
self.emit('feed', feed, idx)
self._addFeed(feed, String(idx))
release(function () {

@@ -126,7 +132,5 @@ cb(null, feed, idx)

Multicore.prototype.feed = function (key) {
var feeds = Object.values(this._feeds)
for (var i = 0; i < feeds.length; i++) {
if (feeds[i].key.equals(key)) return feeds[i]
}
return null
if (Buffer.isBuffer(key)) key = key.toString('hex')
if (typeof key === 'string') return this._feedKeyToFeed[key]
else return null
}

@@ -153,4 +157,3 @@

var feed = self._hypercore(storage, key, self._opts)
self._feeds[numFeeds] = feed
self.emit('feed', feed, String(numFeeds))
self._addFeed(feed, String(numFeeds))
replicate()

@@ -157,0 +160,0 @@ }

@@ -5,3 +5,3 @@ {

"author": "Stephen Whitmore <sww@eight.net>",
"version": "1.2.0",
"version": "1.3.0",
"repository": {

@@ -8,0 +8,0 @@ "url": "git://github.com/noffle/multifeed.git"

@@ -92,3 +92,3 @@ # multifeed

Fetch a feed by its key `key` (a `Buffer`).
Fetch a feed by its key `key` (a `Buffer` or hex string).

@@ -95,0 +95,0 @@ ### var stream = multi.replicate([opts])

@@ -33,3 +33,3 @@ var test = require('tape')

test('get feed by key', function (t) {
t.plan(2)
t.plan(3)

@@ -41,3 +41,5 @@ var multi = multicore(hypercore, ram, { valueEncoding: 'json' })

var feed = multi.feed(w.key)
t.deepEquals(feed, w, 'writer is the same as retrieved feed')
t.deepEquals(feed, w, 'writer is the same as retrieved feed (buffer key)')
feed = multi.feed(w.key.toString('hex'))
t.deepEquals(feed, w, 'writer is the same as retrieved feed (hex key)')
})

@@ -44,0 +46,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