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

follow

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

follow - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

browser/eventemitter2.js

4

api.js

@@ -17,3 +17,4 @@ // The changes_couchdb API

var feed = require('./feed');
var feed = require('./lib/feed')
, stream = require('./lib/stream')

@@ -35,1 +36,2 @@ function follow_feed(opts, cb) {

module.exports.Feed = feed.Feed;
module.exports.Changes = stream.Changes
{ "name": "follow"
, "version": "0.6.1"
, "version": "0.7.0"
, "author": { "name": "Jason Smith"

@@ -4,0 +4,0 @@ , "email": "jhs@iriscouch.com" }

@@ -125,3 +125,3 @@ # Follow: CouchDB changes notifier for NodeJS

* **change** | `function(change)` | A change occured; passed the change object from CouchDB
* **catchup** | `function(seq_id)` | The feed has reached the latest change the database had when it was confirmed (i.e. its `update_seq`). Assuming no changes since the confirmation step, this means you have seen the entire database.
* **catchup** | `function(seq_id)` | The feed has caught up to the *update_seq* from the confirm step. Assuming no subsequent changes, you have seen all the data. *Always fires before the final **change** event.*
* **wait** | Follow is idle, waiting for the next data chunk from CouchDB

@@ -153,5 +153,6 @@ * **timeout** | `function(info)` | Follow did not receive a heartbeat from couch in time. The passed object has `.elapsed_ms` set to the elapsed time

ok test/couch.js ...................................... 10/10
ok test/follow.js ..................................... 38/38
ok test/follow.js ..................................... 43/43
ok test/issues.js ..................................... 43/43
total ................................................. 94/94
ok test/stream.js ................................... 275/275
total ............................................... 375/375

@@ -158,0 +159,0 @@ ok

@@ -19,2 +19,3 @@ // CouchDB tests

, 'setup': setup_test
, 'make_data': make_data
}

@@ -88,3 +89,67 @@

function make_data(minimum_size, callback) {
var payload = {'docs':[]}
, size = 0
// TODO: Make document number 20 really large, at least over 9kb.
while(size < minimum_size) {
var doc = {}
, key_count = rndint(0, 25)
while(key_count-- > 0)
doc[rndstr(8)] = rndstr(20)
// The 20th document has one really large string value.
if(payload.docs.length == 19) {
var big_str = rndstr(9000, 15000)
doc.big = {'length':big_str.length, 'value':big_str}
}
size += JSON.stringify(doc).length // This is an underestimate because an _id and _rev will be added.
payload.docs.push(doc)
}
request.post({'uri':DB+'/_bulk_docs', 'json':payload}, function(er, res) {
if(er) throw er
if(res.statusCode != 201)
throw new Error('Bad bulk_docs update: ' + util.inspect(res.body))
if(res.body.length != payload.docs.length)
throw new Error('Should have results for '+payload.docs.length+' doc insertions')
if(res.body.length < 1500)
throw new Error('Seems like at least 1,500 docs should have been added: ' + res.body.length)
res.body.forEach(function(result) {
if(!result || !result.id || !result.rev)
throw new Error('Bad bulk_docs response: ' + util.inspect(result))
})
return callback(payload.docs.length)
})
function rndstr(minlen, maxlen) {
if(!maxlen) {
maxlen = minlen
minlen = 1
}
var str = ""
, length = rndint(minlen, maxlen)
while(length-- > 0)
str += String.fromCharCode(rndint(97, 122))
return str
}
function rndint(min, max) {
return min + Math.floor(Math.random() * (max - min + 1))
}
}
if(require.main === module)
setup_test(tap.test)

@@ -64,2 +64,32 @@ var tap = require('tap')

test('Heartbeats', function(t) {
t.ok(couch.rtt(), 'The couch RTT is known')
var check_time = couch.rtt() * 3.5 // Enough time for 3 heartbeats.
var beats = 0
, retries = 0
var feed = follow(couch.DB, function() {})
feed.heartbeat = couch.rtt()
feed.on('response', function() { feed.retry_delay = 1 })
feed.on('heartbeat', function() { beats += 1 })
feed.on('retry', function() { retries += 1 })
feed.on('catchup', function() {
t.equal(beats, 0, 'Still 0 heartbeats after receiving changes')
t.equal(retries, 0, 'Still 0 retries after receiving changes')
//console.error('Waiting ' + couch.rtt() + ' * 3 = ' + check_time + ' to check stuff')
setTimeout(check_counters, check_time)
function check_counters() {
t.equal(beats, 3, 'Three heartbeats ('+couch.rtt()+') fired after '+check_time+' ms')
t.equal(retries, 0, 'No retries after '+check_time+' ms')
feed.stop()
t.end()
}
})
})
test('Events for DB confirmation and hitting the original seq', function(t) {

@@ -66,0 +96,0 @@ var feed = follow(couch.DB, on_change)

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