cache-manager
Advanced tools
Comparing version 2.11.0 to 2.11.1
@@ -0,1 +1,4 @@ | ||
- 2.11.1 2020-02-03 | ||
- Bugfix: Preserve function prototypes in memory store (#133). -@ryanbecker | ||
- 2.11.0 2020-01-31 | ||
@@ -2,0 +5,0 @@ - Use eslint instead of jshint/jscs; use nyc instead of istanbul; mocha/coveralls upgrades. |
/*eslint no-unused-vars:0*/ | ||
var Lru = require("lru-cache"); | ||
var deepmerge = require('deepmerge'); | ||
var cloneDeep = require('lodash.clonedeep'); | ||
var utils = require('../utils'); | ||
@@ -9,3 +9,3 @@ var isObject = utils.isObject; | ||
if (typeof object === 'object' && object !== null) { | ||
return deepmerge({}, object, {clone: true}); | ||
return cloneDeep(object); | ||
} | ||
@@ -12,0 +12,0 @@ return object; |
{ | ||
"name": "cache-manager", | ||
"version": "2.11.0", | ||
"version": "2.11.1", | ||
"description": "Cache module for Node.js", | ||
@@ -23,4 +23,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"lodash.clonedeep": "4.5.0", | ||
"async": "1.5.2", | ||
"deepmerge": "4.2.2", | ||
"lru-cache": "4.0.0" | ||
@@ -27,0 +27,0 @@ }, |
@@ -82,2 +82,19 @@ var assert = require('assert'); | ||
function getCachedObjectWithPrototype(name, cb) { | ||
function Thing() {} | ||
Thing.prototype.f = function() { | ||
return 'foo'; | ||
}; | ||
cache.wrap(key, function(cacheCb) { | ||
cacheCb(null, new Thing()); | ||
}, opts, cb); | ||
} | ||
function assertCachedObjectWithPrototype(result) { | ||
assert.equal(typeof result, 'object'); | ||
var prototype = Object.getPrototypeOf(result); | ||
assert.equal(typeof prototype.f, 'function', 'prototype does not have function f'); | ||
assert.equal(result.f(), 'foo', 'prototype function f does not return expected value'); | ||
} | ||
beforeEach(function() { | ||
@@ -154,4 +171,17 @@ cache = caching({store: 'memory', ttl: opts.ttl, ignoreCacheErrors: false}); | ||
}); | ||
it("preserves object prototype", function(done) { | ||
getCachedObjectWithPrototype('foo', function(err, result) { | ||
checkErr(err); | ||
assertCachedObjectWithPrototype(result); | ||
getCachedObjectWithPrototype('foo', function(err, result) { | ||
checkErr(err); | ||
assertCachedObjectWithPrototype(result); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212093
4549
+ Addedlodash.clonedeep@4.5.0
+ Addedlodash.clonedeep@4.5.0(transitive)
- Removeddeepmerge@4.2.2
- Removeddeepmerge@4.2.2(transitive)