cache-manager 2.11.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +3 -0
- package/lib/stores/memory.js +2 -2
- package/package.json +2 -2
- package/test/stores/memory.unit.js +30 -0
package/History.md
CHANGED
package/lib/stores/memory.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*eslint no-unused-vars:0*/
|
|
2
2
|
var Lru = require("lru-cache");
|
|
3
|
-
var
|
|
3
|
+
var cloneDeep = require('lodash.clonedeep');
|
|
4
4
|
var utils = require('../utils');
|
|
5
5
|
var isObject = utils.isObject;
|
|
6
6
|
|
|
7
7
|
function clone(object) {
|
|
8
8
|
if (typeof object === 'object' && object !== null) {
|
|
9
|
-
return
|
|
9
|
+
return cloneDeep(object);
|
|
10
10
|
}
|
|
11
11
|
return object;
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cache-manager",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.1",
|
|
4
4
|
"description": "Cache module for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"author": "Bryan Donovan",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"lodash.clonedeep": "4.5.0",
|
|
23
24
|
"async": "1.5.2",
|
|
24
|
-
"deepmerge": "4.2.2",
|
|
25
25
|
"lru-cache": "4.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -79,6 +79,23 @@ describe("memory store", function() {
|
|
|
79
79
|
}, opts, cb);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
function getCachedObjectWithPrototype(name, cb) {
|
|
83
|
+
function Thing() {}
|
|
84
|
+
Thing.prototype.f = function() {
|
|
85
|
+
return 'foo';
|
|
86
|
+
};
|
|
87
|
+
cache.wrap(key, function(cacheCb) {
|
|
88
|
+
cacheCb(null, new Thing());
|
|
89
|
+
}, opts, cb);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function assertCachedObjectWithPrototype(result) {
|
|
93
|
+
assert.equal(typeof result, 'object');
|
|
94
|
+
var prototype = Object.getPrototypeOf(result);
|
|
95
|
+
assert.equal(typeof prototype.f, 'function', 'prototype does not have function f');
|
|
96
|
+
assert.equal(result.f(), 'foo', 'prototype function f does not return expected value');
|
|
97
|
+
}
|
|
98
|
+
|
|
82
99
|
beforeEach(function() {
|
|
83
100
|
cache = caching({store: 'memory', ttl: opts.ttl, ignoreCacheErrors: false});
|
|
84
101
|
});
|
|
@@ -150,6 +167,19 @@ describe("memory store", function() {
|
|
|
150
167
|
});
|
|
151
168
|
});
|
|
152
169
|
});
|
|
170
|
+
|
|
171
|
+
it("preserves object prototype", function(done) {
|
|
172
|
+
getCachedObjectWithPrototype('foo', function(err, result) {
|
|
173
|
+
checkErr(err);
|
|
174
|
+
assertCachedObjectWithPrototype(result);
|
|
175
|
+
|
|
176
|
+
getCachedObjectWithPrototype('foo', function(err, result) {
|
|
177
|
+
checkErr(err);
|
|
178
|
+
assertCachedObjectWithPrototype(result);
|
|
179
|
+
done();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
153
183
|
});
|
|
154
184
|
});
|
|
155
185
|
});
|