New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

version-service

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

version-service - npm Package Compare versions

Comparing version

to
1.2.1

11

build/version.js

@@ -32,2 +32,5 @@ 'use strict';

_createClass(Version, [{
key: 'stop',
value: function stop() {}
}, {
key: 'getVersion',

@@ -70,3 +73,3 @@ value: function getVersion() {

var timeouId = setTimeout(function () {
var timeoutId = setTimeout(function () {
_this2.checkVersion().then(function (version) {

@@ -84,6 +87,4 @@ if (version.isCurrent) {

}, this._timeout);
return {
cancel: function cancel() {
clearTimeout(timeouId);
}
this.stop = function () {
clearTimeout(timeoutId);
};

@@ -90,0 +91,0 @@ }

{
"name": "version-service",
"version": "1.1.2",
"version": "1.2.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "./build/version.js",

@@ -13,3 +13,2 @@ # Version Service

## Use
```js

@@ -35,2 +34,8 @@ var Version = require('version-service');

});
// to run periodic checks
versionService.start();
// to cancel the periodic checks
versionService.stop();
```

@@ -12,2 +12,6 @@ import Promise from 'es6-promise';

stop() {
}
get url() {

@@ -69,3 +73,3 @@ return this._url;

start() {
var timeouId = setTimeout(() => {
var timeoutId = setTimeout(() => {
this.checkVersion().then((version) => {

@@ -83,8 +87,7 @@ if(version.isCurrent) {

}, this._timeout)
return {
cancel: function() {
clearTimeout(timeouId);
}
}
this.stop = function() {
clearTimeout(timeoutId);
};
}
}

@@ -65,5 +65,5 @@ import {expect} from 'chai';

it('should check version over an interval', () => {
it('should periodically check version over an interval', (done) => {
const url = 'http://localhost:3000/version.json';
const timeout = 100;
const timeout = 5;
const callback = function(localVersion, responseVersion) {

@@ -94,2 +94,32 @@ expect(localVersion).to.not.equal(responseVersion);

it('should cancel periodic check', () => {
const url = 'http://localhost:3000/version.json';
const timeout = 5;
var test_bool = true;
const callback = function(localVersion, responseVersion) {
test_bool = false;
};
const versionNumber = '1.0.0'
const myVersion = new Version(url, versionNumber, timeout, callback);
const versionRequest = nock('http://localhost:3000')
.get('/version.json')
.times(4)
.reply(200, {
status: 'success',
data: {
version: '1.0.0'
}
})
.get('/version.json')
.reply(200, {
status: 'success',
data: {
version: '1.0.1'
}
});
myVersion.start();
myVersion.stop();
expect(test_bool).to.equal(true);
});
});