Socket
Socket
Sign inDemoInstall

follow

Package Overview
Dependencies
59
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.11.4 to 0.12.0

2

api.js
// The changes_couchdb API
//
// Copyright 2011 Iris Couch
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors
//

@@ -5,0 +5,0 @@ // Licensed under the Apache License, Version 2.0 (the "License");

#!/usr/bin/env node
// Export Follow in browser-friendly format.
//
// Copyright 2011 Iris Couch
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors
//

@@ -6,0 +6,0 @@ // Licensed under the Apache License, Version 2.0 (the "License");

#!/usr/bin/env node
// The follow command-line interface.
//
// Copyright 2011 Iris Couch
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors
//

@@ -6,0 +6,0 @@ // Licensed under the Apache License, Version 2.0 (the "License");

// Core routines for event emitters
//
// Copyright 2011 Iris Couch
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors
//

@@ -47,5 +47,7 @@ // Licensed under the Apache License, Version 2.0 (the "License");

self.feed = 'continuous';
self.heartbeat = DEFAULT_HEARTBEAT;
self.max_retry_seconds = DEFAULT_MAX_RETRY_SECONDS;
self.heartbeat = opts.heartbeat || DEFAULT_HEARTBEAT;
self.max_retry_seconds = opts.max_retry_seconds || DEFAULT_MAX_RETRY_SECONDS;
self.inactivity_ms = null;
self.initial_retry_delay = opts.initial_retry_delay || INITIAL_RETRY_DELAY;
self.response_grace_time = opts.response_grace_time || RESPONSE_GRACE_TIME;

@@ -58,3 +60,3 @@ self.headers = {};

self.caught_up = false
self.retry_delay = INITIAL_RETRY_DELAY; // ms
self.retry_delay = self.initial_retry_delay;

@@ -67,3 +69,4 @@ self.query_params = {}; // Extra `req.query` values for filter functions

Object.keys(opts).forEach(function(key) {
self[key] = opts[key];
if (typeof self[key] !== 'function')
self[key] = opts[key];
})

@@ -238,3 +241,3 @@

// The response headers must arrive within one heartbeat.
var response_timer = setTimeout(response_timed_out, self.heartbeat + RESPONSE_GRACE_TIME)
var response_timer = setTimeout(response_timed_out, self.heartbeat + self.response_grace_time)
, timed_out = false

@@ -274,3 +277,3 @@

self.log.debug('Good response: ' + feed_id);
self.retry_delay = INITIAL_RETRY_DELAY;
self.retry_delay = self.initial_retry_delay;

@@ -463,2 +466,5 @@ self.emit('response', resp);

var self = this;
if (self.dead)
return self.log.debug('No timeout: change listener stopped this feed');
self.log.debug('Timeout')

@@ -565,12 +571,20 @@

if(!change.doc)
return self.die(new Error('Internal filter needs .doc in change ' + change.seq));
// Don't let the filter mutate the real data.
var doc = lib.JDUP(change.doc);
var req = lib.JDUP({'query': self.pending.request.changes_query});
var filter_args;
if (self.is_db_updates) {
if(!change.db_name || !change.type)
return self.die(new Error('Internal _db_updates filter needs .db_name and .type in change ', change));
filter_args = [change.db_name, change.type, req];
} else {
if(!change.doc)
return self.die(new Error('Internal filter needs .doc in change ' + change.seq));
// Don't let the filter mutate the real data.
var doc = lib.JDUP(change.doc);
filter_args = [doc, req];
}
var result = false;
try {
result = self.filter.apply(null, [doc, req]);
result = self.filter.apply(null, filter_args);
} catch (er) {

@@ -577,0 +591,0 @@ self.log.debug('Filter error', er);

@@ -1,2 +0,2 @@

// Copyright 2011 Iris Couch
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors
//

@@ -3,0 +3,0 @@ // Licensed under the Apache License, Version 2.0 (the "License");

// Changes stream
//
// Copyright 2011 Iris Couch
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors
//

@@ -5,0 +5,0 @@ // Licensed under the Apache License, Version 2.0 (the "License");

{ "name": "follow"
, "version": "0.11.4"
, "version": "0.12.0"
, "author": { "name": "Jason Smith"

@@ -12,6 +12,6 @@ , "email": "jhs@iriscouch.com" }

, "url": "git://github.com/iriscouch/follow" }
, "engines": { "node": "0.10.x || 0.8.x" }
, "dependencies" : { "request" : "^2.44.0"
, "engines": { "node": "0.12.x || 0.10.x || 0.8.x" }
, "dependencies" : { "request" : "~2.55.0"
, "browser-request" : "~0.3.0"
, "debug": "~0.7.2"
, "debug": "^2.1.0"
}

@@ -18,0 +18,0 @@ , "devDependencies": { "tap": "~0.4.0"

@@ -53,2 +53,8 @@ # Follow: CouchDB changes and db updates notifier for NodeJS

For each change, Follow will emit a `change` event containing:
* `type`: `created`, `updated` or `deleted`.
* `db_name`: Name of the database where the change occoured.
* `ok`: Event operation status (boolean).
Note that this feature is available as of CouchDB 1.4.

@@ -84,2 +90,5 @@

* `inactivity_ms` | Maximum time to wait between **changes**. Omitting this means no maximum.
* `max_retry_seconds` | Maximum time to wait between retries (default: 360 seconds)
* `initial_retry_delay` | Time to wait before the first retry, in milliseconds (default 1000 milliseconds)
* `response_grace_time` | Extra time to wait before timing out, in milliseconds (default 5000 milliseconds)

@@ -86,0 +95,0 @@ ## Object API

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

, DB = process.env.db || 'http://localhost:5984/follow_test'
, DB_UPDATES = process.env.db_updates || 'http://localhost:5984/_db_updates'
, RTT = null

@@ -17,2 +18,3 @@

module.exports = { 'DB': DB
, 'DB_UPDATES': DB_UPDATES
, 'rtt' : get_rtt

@@ -22,2 +24,3 @@ , 'redo': redo_couch

, 'make_data': make_data
, 'create_and_delete_db': create_and_delete_db
}

@@ -91,3 +94,14 @@

function create_and_delete_db(t, callback) {
request.put({ uri: DB + 1, json: true}, function (er, res) {
t.false(er, 'create test db');
request.del({uri: DB +1, json: true}, function (er, res) {
t.false(er, 'Clear old test DB: ' + DB)
t.ok(!res.body.error);
callback();
});
});
}
function make_data(minimum_size, callback) {

@@ -115,3 +129,3 @@ var payload = {'docs':[]}

request.post({'uri':DB+'/_bulk_docs', 'json':payload}, function(er, res) {
request.post({'uri':DB+'/_bulk_docs', 'json':payload}, function(er, res, body) {
if(er) throw er

@@ -125,6 +139,3 @@

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) {
body.forEach(function(result) {
if(!result || !result.id || !result.rev)

@@ -131,0 +142,0 @@ throw new Error('Bad bulk_docs response: ' + util.inspect(result))

@@ -248,1 +248,24 @@ var tap = require('tap')

})
test('Follow _db_updates', function (t) {
t.plan(4);
var count = 0;
var types = ['created'];
var db_name = couch.DB.split('/').slice(-1)[0];
var feed = new follow.Feed({db: couch.DB_UPDATES});
feed.on('error', function (error) {
t.false(error, 'Error in feed ' + error);
});
feed.on('change', function (change) {
t.ok(change, 'Received a change ' + JSON.stringify(change));
t.equal(change.type, types[count], 'Change should be of type "' + types[count] + '"');
t.equal(change.db_name, db_name + 1, 'Change should have db_name with the name of the db where the change occoured.');
feed.stop();
});
feed.start();
couch.create_and_delete_db(t, function () {
t.ok(true, 'things happened');
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc