cache-manager 2.8.0 → 2.9.0

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 CHANGED
@@ -1,3 +1,6 @@
1
+ - 2.9.0 2018-03-26
2
+ - Fix store's this context for isCacheableValue method (#119). -@alexandrusavin
3
+
1
4
  - 2.8.0 2018-02-28
2
5
  - Added link to node-cache-manager-fs-hash - @rolandstarke
3
6
  - Bugfix for options object in multiCache.set (#115) - @sebelga
package/lib/caching.js CHANGED
@@ -38,7 +38,7 @@ var caching = function(args) {
38
38
  if (typeof args.isCacheableValue === 'function') {
39
39
  self._isCacheableValue = args.isCacheableValue;
40
40
  } else if (typeof self.store.isCacheableValue === 'function') {
41
- self._isCacheableValue = self.store.isCacheableValue;
41
+ self._isCacheableValue = self.store.isCacheableValue.bind(self.store);
42
42
  } else {
43
43
  self._isCacheableValue = function(value) {
44
44
  return value !== undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cache-manager",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "Cache module for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1234,4 +1234,22 @@ describe("caching", function() {
1234
1234
  });
1235
1235
  });
1236
1236
  });
1237
+
1238
+ describe("when using store's isCacheableValue method", function() {
1239
+ it("should not break its' context", function() {
1240
+ var store = {
1241
+ isCacheableValue: function() {
1242
+ if (this !== store) {
1243
+ throw new Error("Broken store context");
1244
+ }
1245
+ },
1246
+ get: function() {},
1247
+ set: function() {},
1248
+ };
1249
+
1250
+ cache = caching({store: store});
1251
+
1252
+ assert.doesNotThrow(cache._isCacheableValue);
1253
+ });
1254
+ });
1237
1255
  });