cache-manager 3.2.1 → 3.3.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
+ - 3.3.0 2020-04-30
2
+ - Use full lodash lib instead of lodash.clonedeep npm (#141)
3
+
1
4
  - 3.2.1 2020-03-20
2
5
  - Background refresh fixes (#139). -@marcoreni
3
6
 
@@ -1,6 +1,6 @@
1
1
  /*eslint no-unused-vars:0*/
2
2
  var Lru = require("lru-cache");
3
- var cloneDeep = require('lodash.clonedeep');
3
+ var cloneDeep = require('lodash/cloneDeep');
4
4
  var utils = require('../utils');
5
5
  var isObject = utils.isObject;
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cache-manager",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
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",
24
23
  "async": "1.5.2",
24
+ "lodash": "^4.17.15",
25
25
  "lru-cache": "4.0.0"
26
26
  },
27
27
  "devDependencies": {
@@ -1462,11 +1462,10 @@ describe("caching", function() {
1462
1462
  it("should be able to chain with simple promise", function(done) {
1463
1463
  cache.wrap('key', function() {
1464
1464
  return 'OK';
1465
- })
1466
- .then(function(res) {
1467
- assert.equal(res, 'OK');
1468
- done();
1469
- });
1465
+ }).then(function(res) {
1466
+ assert.equal(res, 'OK');
1467
+ done();
1468
+ });
1470
1469
  });
1471
1470
 
1472
1471
  it("should be able to chain with cache function as a promise", function(done) {
@@ -1474,11 +1473,21 @@ describe("caching", function() {
1474
1473
  return new Promise(function(resolve) {
1475
1474
  resolve('OK');
1476
1475
  });
1477
- })
1478
- .then(function(res) {
1479
- assert.equal(res, 'OK');
1480
- done();
1476
+ }).then(function(res) {
1477
+ assert.equal(res, 'OK');
1478
+ done();
1479
+ });
1480
+ });
1481
+
1482
+ it("should be able use a ttl while chaining cache function as a promise", function(done) {
1483
+ cache.wrap('key', function() {
1484
+ return new Promise(function(resolve) {
1485
+ resolve('OK');
1481
1486
  });
1487
+ }, {ttl: 10}).then(function(res) {
1488
+ assert.equal(res, 'OK');
1489
+ done();
1490
+ });
1482
1491
  });
1483
1492
 
1484
1493
  it("should be able to catch errors in cache function as a promise", function(done) {
@@ -1486,23 +1495,20 @@ describe("caching", function() {
1486
1495
  return new Promise(function(resolve, reject) {
1487
1496
  reject('NOK');
1488
1497
  });
1489
- })
1490
- .then(function() {
1491
- done(new Error('It should not call then since there is an error in the cache function!'));
1492
- })
1493
- .catch(function() {
1494
- done();
1495
- });
1498
+ }).then(function() {
1499
+ done(new Error('It should not call "then" since there is an error in the cache function!'));
1500
+ }).catch(function() {
1501
+ done();
1502
+ });
1496
1503
  });
1497
1504
 
1498
1505
  it("should be able to chain with non-cacheable value", function(done) {
1499
1506
  cache.wrap('key', function() {
1500
1507
  return;
1501
- })
1502
- .then(function(res) {
1503
- assert.equal(res, undefined);
1504
- done();
1505
- });
1508
+ }).then(function(res) {
1509
+ assert.equal(res, undefined);
1510
+ done();
1511
+ });
1506
1512
  });
1507
1513
  });
1508
1514
  });
@@ -49,7 +49,7 @@ describe("memory store", function() {
49
49
  context("when cache misses", function() {
50
50
  function getCachedObject(name, cb) {
51
51
  cache.wrap(key, function(cacheCb) {
52
- cacheCb(null, {foo: 'bar'});
52
+ cacheCb(null, {foo: 'bar', arr: [1, 2, 3]});
53
53
  }, opts, cb);
54
54
  }
55
55
 
@@ -110,6 +110,7 @@ describe("memory store", function() {
110
110
  getCachedObject('foo', function(err, result) {
111
111
  checkErr(err);
112
112
  assert.equal(result.foo, 'bar');
113
+ assert.deepEqual(result.arr, [1, 2, 3]);
113
114
  done();
114
115
  });
115
116
  });