memo-cache
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -261,3 +261,3 @@ 'use strict'; | ||
function (accumulator, cacheName) { | ||
return accumulator + _.keys(caches[cacheName].cache).length | ||
return accumulator + _.keys(caches[cacheName].cache).length; | ||
}, 0); | ||
@@ -264,0 +264,0 @@ } else { |
@@ -5,3 +5,3 @@ { | ||
"description": "A memoization and caching library for NodeJS", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"repository": { | ||
@@ -25,7 +25,7 @@ "type": "git", | ||
"dependencies": { | ||
"underscore": "1.6.0" | ||
"underscore": "~1.8.3" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.14.0", | ||
"should": "~2.0.2" | ||
"mocha": "~2.3.3", | ||
"should": "~7.1.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "engines": { |
@@ -7,2 +7,3 @@ # Node Memoization/Caching Library | ||
[![NPM version](https://img.shields.io/npm/v/memo-cache.svg)](https://www.npmjs.org/package/memo-cache) | ||
[![bitHound Score](https://www.bithound.io/github/mrodrig/memo-cache/badges/score.svg)](https://www.bithound.io/github/mrodrig/memo-cache) | ||
@@ -9,0 +10,0 @@ A memoization and caching library for NodeJS. |
@@ -167,3 +167,3 @@ var should = require('should'), | ||
// When not cloning, the cache can be modified: | ||
var tmp = memoCache.cache.set('testCache', 'testKey', {test:'value'}); | ||
tmp = memoCache.cache.set('testCache', 'testKey', {test:'value'}); | ||
JSON.stringify(tmp).should.equal(JSON.stringify({test:'value'})); | ||
@@ -186,3 +186,3 @@ tmp.badValue = 'fail'; // try modifying the cached object | ||
// When not cloning, the cache can be modified: | ||
var tmp = testCache.set('testKey', {test:'value'}); | ||
tmp = testCache.set('testKey', {test:'value'}); | ||
JSON.stringify(tmp).should.equal(JSON.stringify({test:'value'})); | ||
@@ -338,3 +338,3 @@ tmp.badValue = 'fail'; // try modifying the cached object | ||
done(); | ||
}) | ||
}); | ||
}); | ||
@@ -341,0 +341,0 @@ |
@@ -23,15 +23,3 @@ var should = require('should'), | ||
var defaultOptions = { | ||
cloneValues : false, // Should values be cloned before storing and before returning them to the caller | ||
maxSize : null, // The maximum number of keys that should be kept in the cache | ||
/** | ||
* Function which maps the input arguments for memoization to a unique string for storing the result in the cache | ||
* @param args Array argument array | ||
* @returns {string} key to be used to store the result in the function cache | ||
*/ | ||
memoHashFunction: function (args) { | ||
return args.length ? args[0].toString() : '__noArgs'; | ||
} | ||
}, | ||
customSingleOptions = { | ||
var customSingleOptions = { | ||
cloneValues : true, // Should values be cloned before storing and before returning them to the caller | ||
@@ -131,3 +119,3 @@ maxSize : 5, // The maximum number of keys that should be kept in the cache | ||
testFunctionSingleParamDefaultMemoized.clear(); | ||
var tmp = testFunctionSingleParamDefaultMemoized.size(); | ||
tmp = testFunctionSingleParamDefaultMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -145,3 +133,3 @@ cacheMissCounter.should.equal(0); | ||
testFunctionSingleParamDefaultMemoized.clear(); | ||
var tmp = testFunctionSingleParamDefaultMemoized.size(); | ||
tmp = testFunctionSingleParamDefaultMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -215,3 +203,3 @@ cacheMissCounter.should.equal(1); | ||
testFunctionSingleParamCustomMemoized.clear(); | ||
var tmp = testFunctionSingleParamCustomMemoized.size(); | ||
tmp = testFunctionSingleParamCustomMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -229,3 +217,3 @@ cacheMissCounter.should.equal(0); | ||
testFunctionSingleParamCustomMemoized.clear(); | ||
var tmp = testFunctionSingleParamCustomMemoized.size(); | ||
tmp = testFunctionSingleParamCustomMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -299,3 +287,3 @@ cacheMissCounter.should.equal(1); | ||
testFunctionObjectParamDefaultMemoized.clear(); | ||
var tmp = testFunctionObjectParamDefaultMemoized.size(); | ||
tmp = testFunctionObjectParamDefaultMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -313,3 +301,3 @@ cacheMissCounter.should.equal(0); | ||
testFunctionObjectParamDefaultMemoized.clear(); | ||
var tmp = testFunctionObjectParamDefaultMemoized.size(); | ||
tmp = testFunctionObjectParamDefaultMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -324,3 +312,2 @@ cacheMissCounter.should.equal(1); | ||
_.each(_.range(NUM_ITERATIONS), function (num) { | ||
var tmp = cacheMissCounter; | ||
testFunctionObjectParamDefaultMemoized({val: num.toString()}); | ||
@@ -339,3 +326,2 @@ cacheMissCounter.should.equal(1); // Default toString returns [object Object] for hash | ||
_.each(_.range(NUM_ITERATIONS), function (num) { | ||
var tmp = cacheMissCounter; | ||
sleep(1); // sleep 1 millisecond | ||
@@ -385,3 +371,3 @@ testFunctionObjectParamDefaultMemoized({val: num.toString()}); | ||
testFunctionObjectParamCustomMemoized.clear(); | ||
var tmp = testFunctionObjectParamCustomMemoized.size(); | ||
tmp = testFunctionObjectParamCustomMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -399,3 +385,3 @@ cacheMissCounter.should.equal(0); | ||
testFunctionObjectParamCustomMemoized.clear(); | ||
var tmp = testFunctionObjectParamCustomMemoized.size(); | ||
tmp = testFunctionObjectParamCustomMemoized.size(); | ||
tmp.should.equal(0); | ||
@@ -402,0 +388,0 @@ cacheMissCounter.should.equal(1); |
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
173
61310
1125
+ Addedunderscore@1.8.3(transitive)
- Removedunderscore@1.6.0(transitive)
Updatedunderscore@~1.8.3