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

ft-poller

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ft-poller - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

.idea/ft-poller.iml

5

package.json
{
"name": "ft-poller",
"version": "2.6.0",
"version": "2.7.0",
"repository": {

@@ -20,4 +20,5 @@ "type": "git",

"chai": "^3.3.0",
"eslint": "^2.9.0",
"lintspaces-cli": "^0.1.1",
"mocha": "^2.3.3",
"next-build-tools": "^5.1.0",
"nock": "^2.13.0",

@@ -24,0 +25,0 @@ "sinon": "^1.10.3",

10

src/poller.js

@@ -65,4 +65,11 @@ 'use strict';

Poller.prototype.retry = function(){
this.fetch();
clearInterval(this.poller);
this.poller = setInterval(function () {
self.fetch();
}, this.refreshInterval);
};
Poller.prototype.fetch = function () {
var time = new Date();

@@ -86,2 +93,3 @@ var self = this;

self.data = self.parseData(s);
self.emit('data', self.data);
})

@@ -88,0 +96,0 @@ .catch(function (err) {

@@ -183,3 +183,3 @@ /* global it, describe, xit */

expect(ft.isDone()).to.be.true; // ensure Nock has been used
expect(eventEmitterStub.calledOnce).to.be.true;
expect(eventEmitterStub.called).to.be.true;
expect(eventEmitterStub.getCall(0).args[0]).to.equal('ok');

@@ -210,3 +210,3 @@ expect(eventEmitterStub.getCall(0).args[2]).to.match(/^\d+$/);

expect(ft.isDone()).to.be.true; // ensure Nock has been used
expect(eventEmitterStub.calledOnce).to.be.true;
expect(eventEmitterStub.called).to.be.true;
expect(eventEmitterStub.getCall(0).args[0]).to.equal('ok');

@@ -287,3 +287,3 @@ expect(eventEmitterStub.getCall(0).args[2]).to.match(/^\d+$/);

sinon.stub(Poller.prototype, 'start');
const stub = sinon.stub(Poller.prototype, 'start');

@@ -297,3 +297,4 @@ var p = new Poller( {

expect(p.start.calledOnce).to.be.true;
expect(p.start.args[0][0]).to.deep.equal({initialRequest: true})
expect(p.start.args[0][0]).to.deep.equal({initialRequest: true});
stub.restore();
});

@@ -304,2 +305,52 @@

it('Should fire a "data" event when new data is received and parsed', (done) => {
const stub = { 'foo': 1 };
nock('http://example.com')
.get('/json')
.reply(200, stub);
var p = new Poller( {
url: 'http://example.com/json',
defaultData: 0
});
p.start({initialRequest:true});
p.once('data', data => {
expect(data).to.deep.equal(stub);
done();
})
});
it('Should have the ability to manually retry', done => {
const stub1 = { 'foo': 1 };
nock('http://example.com')
.get('/json')
.reply(200, stub1)
var p = new Poller( {
url: 'http://example.com/json',
defaultData: 0
});
const onSecond = data => {
try{
console.log('onSecond', data);
expect(data).to.deep.equal(stub1);
done();
}catch(e){
done(e);
}
};
const onFirst = () => {
p.once('data', onSecond);
p.retry();
};
p.once('data', onFirst);
p.start({initialRequest:true});
})
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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