Comparing version 0.6.1 to 0.7.0
@@ -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) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212804
24
2674
165
2
23
2