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

data-cache

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-cache - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

18

cache-spec.js

@@ -69,2 +69,20 @@ var Cache = require('./cache');

it('should be called everytime when data is filled into the cache, even ', function(done) {
var callback = sinon.spy();
cache.subscribe('spaceships').on('data', function() {
callback();
});
cache.fill([spaceship]);
cache.fill([spaceship]);
cache.fill([spaceship], function() {
try {
expect(callback).toHaveBeenCalledThrice();
done();
} catch(e) {
done(e);
}
});
});
it('should be possible to get a model from the cache by its id', function() {

@@ -71,0 +89,0 @@ cache.fill([spaceship]);

6

cache.js

@@ -63,4 +63,5 @@ var asap = require('asap');

* @param {Array|Object} dataArr
* @param {Function} cb - Callback
*/
fill: function(dataArr) {
fill: function(dataArr, cb) {
var models = [];

@@ -72,6 +73,6 @@ if(!Array.isArray(dataArr)) dataArr = [dataArr];

if(existingModel) {
models.push(existingModel);
return existingModel.setData(data);
}
var model = this._createModel(data);
if(!model) return;
if(!this.getCollection(collectionName)) {

@@ -84,2 +85,3 @@ this._cache[collectionName] = new Collection();

this._callSubscribers(models);
asap(cb);
},

@@ -86,0 +88,0 @@ /**

{
"name": "data-cache",
"version": "0.0.6",
"version": "0.0.7",
"description": "",

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

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