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

hmpo-cached-model

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmpo-cached-model - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

14

lib/index.js

@@ -17,3 +17,3 @@ 'use strict';

if (!this.options.store) throw new Error('store must be supplied in options');
if (!this.options.store || typeof this.options.store.getClient !== 'function') throw new Error('store.getClient function must be supplied in options');
}

@@ -24,3 +24,3 @@

debug('Checking store last modified time', this.options.key);
this.options.store.get(
this.options.store.getClient().get(
this.keyLastModified,

@@ -39,3 +39,3 @@ (err, data) => {

debug('Getting store data', this.options.key);
this.options.store.get(
this.options.store.getClient().get(
this.keyData,

@@ -60,3 +60,3 @@ (err, data) => {

debug('Checking API next check time', this.options.key);
this.options.store.get(
this.options.store.getClient().get(
this.keyNextCheck,

@@ -74,3 +74,3 @@ (err, data) => {

debug('Store next check time', this.options.key);
this.options.store.set(
this.options.store.getClient().set(
this.keyNextCheck,

@@ -101,3 +101,3 @@ Date.now() + this.options.apiInterval,

debug('Store data', this.options.key);
this.options.store.set(
this.options.store.getClient().set(
this.keyData,

@@ -111,3 +111,3 @@ JSON.stringify(this.toJSON()),

debug('Store modified time', this.options.key);
this.options.store.set(
this.options.store.getClient().set(
this.keyLastModified,

@@ -114,0 +114,0 @@ this.lastModified,

{
"name": "hmpo-cached-model",
"version": "1.0.6",
"version": "1.1.0",
"description": "Cached polling model",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,4 +9,10 @@ # hmpo-cached-model

```
const HmpoCachedModel = require('hmpo-caches-model');
const HmpoCachedModel = require('hmpo-cached-model');
let redisFactory = {
getClient() {
return redisInstance;
}
}
let model = new HmpoCachedModel(

@@ -20,3 +26,3 @@ { // optional seed data

key: 'root-key',
store: redisInstance,
store: redisFactory,
storeInterval: 1000,

@@ -23,0 +29,0 @@ apiInterval: 2000

@@ -13,3 +13,3 @@ 'use strict';

describe('HmpoCachedModel', () => {
let clock, instance, storeStub, options, cb;
let clock, instance, storeFactory, storeStub, options, cb;

@@ -22,2 +22,3 @@ beforeEach(() => {

sinon.stub(HmpoModel.prototype, 'emit');
storeStub = {

@@ -27,6 +28,11 @@ get: sinon.stub(),

};
storeFactory = {
getClient: sinon.stub().returns(storeStub)
};
options = {
url: 'http://example.com/api',
key: 'root-key',
store: storeStub,
store: storeFactory,
storeInterval: 1000,

@@ -72,2 +78,7 @@ apiInterval: 2000

});
it('should throw an error if no store getClient function is supplied', () => {
options.store = {};
expect( () => new HmpoCachedModel(null, options) ).to.throw();
});
});

@@ -143,3 +154,3 @@

it('should call callback with JSON vaidation error', () => {
it('should call callback with JSON validation error', () => {
storeStub.get.yields(null, '{{{');

@@ -416,3 +427,3 @@ instance.getStoreData(cb);

it('should run the two loding functions', () => {
it('should run the two loading functions', () => {
instance.start();

@@ -419,0 +430,0 @@ HmpoCachedModel.prototype.loadFromStore.should.have.been.called;

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