Socket
Socket
Sign inDemoInstall

cache-manager

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-manager - npm Package Compare versions

Comparing version 2.10.1 to 2.10.2

3

History.md

@@ -0,1 +1,4 @@

- 2.10.2 2020-01-30
- Disallow mutation of values in memory store (#103).
- 2.10.1 2019-11-06

@@ -2,0 +5,0 @@ - Add .js to module path to fix compilers (#131). -@imjohnbo

var Lru = require("lru-cache");
var cloneDeep = require('lodash.clonedeep');
var utils = require('../utils');

@@ -34,2 +35,4 @@ var isObject = utils.isObject;

self.set = function(key, value, options, cb) {
value = cloneDeep(value);
if (typeof options === 'function') {

@@ -36,0 +39,0 @@ cb = options;

3

package.json
{
"name": "cache-manager",
"version": "2.10.1",
"version": "2.10.2",
"description": "Cache module for Node.js",

@@ -24,2 +24,3 @@ "main": "index.js",

"async": "1.5.2",
"lodash.clonedeep": "4.5.0",
"lru-cache": "4.0.0"

@@ -26,0 +27,0 @@ },

var assert = require('assert');
var support = require('../support');
var checkErr = support.checkErr;
var caching = require('../../index').caching;
var memoryStore = require('../../lib/stores/memory');

@@ -37,2 +39,94 @@

});
describe("when used with wrap() function", function() {
var cache;
var key;
var opts = {};
beforeEach(function() {
key = support.random.string(20);
});
context("when cache misses", function() {
function getCachedObject(name, cb) {
cache.wrap(key, function(cacheCb) {
cacheCb(null, {foo: 'bar'});
}, opts, cb);
}
function getCachedString(name, cb) {
cache.wrap(key, function(cacheCb) {
cacheCb(null, 'bar');
}, opts, cb);
}
function getCachedArray(name, cb) {
cache.wrap(key, function(cacheCb) {
cacheCb(null, [1, 2, 3]);
}, opts, cb);
}
function getCachedNumber(name, cb) {
cache.wrap(key, function(cacheCb) {
cacheCb(null, 34);
}, opts, cb);
}
beforeEach(function() {
cache = caching({store: 'memory', safeClone: true, ttl: opts.ttl, ignoreCacheErrors: false});
});
it("does not allow mutation of objects", function(done) {
getCachedObject('foo', function(err, result) {
checkErr(err);
result.foo = 'buzz';
getCachedObject('foo', function(err, result) {
checkErr(err);
assert.equal(result.foo, 'bar');
done();
});
});
});
it("does not allow mutation of arrays", function(done) {
getCachedArray('foo', function(err, result) {
checkErr(err);
result = ['a', 'b', 'c'];
getCachedArray('foo', function(err, result) {
checkErr(err);
assert.deepEqual(result, [1, 2, 3]);
done();
});
});
});
it("does not allow mutation of strings", function(done) {
getCachedString('foo', function(err, result) {
checkErr(err);
result = 'buzz';
getCachedString('foo', function(err, result) {
checkErr(err);
assert.equal(result, 'bar');
done();
});
});
});
it("does not allow mutation of numbers", function(done) {
getCachedNumber('foo', function(err, result) {
checkErr(err);
result = 12;
getCachedNumber('foo', function(err, result) {
checkErr(err);
assert.equal(result, 34);
done();
});
});
});
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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