memo-cache
Advanced tools
Comparing version 0.0.2 to 1.0.0
{ | ||
"name": "memo-cache", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/mrodrig/memo-cache", | ||
@@ -5,0 +5,0 @@ "moduleType": [ |
@@ -185,3 +185,3 @@ 'use strict'; | ||
}; | ||
return caches[cacheName].cache[key].value; | ||
return caches[cacheName].options.cloneValues ? clone(value) : value; | ||
} | ||
@@ -214,3 +214,2 @@ return null; | ||
if (cacheName && key && caches[cacheName] && caches[cacheName].cache && caches[cacheName].cache[key]) { | ||
console.log('removing ' + key + ' in ' + cacheName); | ||
var value = caches[cacheName].cache[key].value; | ||
@@ -217,0 +216,0 @@ delete caches[cacheName].cache[key]; |
@@ -5,3 +5,3 @@ { | ||
"description": "A memoization and caching library for NodeJS", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"repository": { | ||
@@ -29,4 +29,3 @@ "type": "git", | ||
"mocha": "~1.14.0", | ||
"should": "~2.0.2", | ||
"async": "~0.2.9" | ||
"should": "~2.0.2" | ||
}, | ||
@@ -33,0 +32,0 @@ "engines": { |
@@ -140,6 +140,21 @@ # Node Memoization/Caching Library | ||
####Memoization: | ||
#####memoCache.memoize(function, options) | ||
* ```cacheName``` String - name of the cache | ||
* ```options``` Object - options for the cache, specifying any of the following: | ||
* ```cloneValues``` Boolean - should returned values be clones of the original? [Default: false] | ||
* ```maxSize``` Integer - maximum number of keys to store in this cache; if null, then unlimited [Default: null] | ||
* ```memoHashFunction``` Function - used to map the input arguments to a String. The result of this function becomes the key for the function result value | ||
```javascript | ||
require memoCache = require('memo-cache'); | ||
var myFunction = function (aString) { console.log('cache miss!'); return aString; }; | ||
var myFunctionMemoized = memoCache.memoize(myFunction, {maxSize: 10}); | ||
myFunctionMemoized('testing'); // => 'testing' (Prints 'cache miss!' to the console) | ||
myFunctionMemoized('testing'); // => 'testing' (Does not print 'cache miss!') | ||
``` | ||
## Tests | ||
*No tests are currently implemented while this module is in development* | ||
```bash | ||
@@ -146,0 +161,0 @@ $ npm test |
@@ -1,3 +0,7 @@ | ||
describe('tag-cloud Module', function() { | ||
return true; | ||
var cacheTests = require('./testCache'); | ||
memoTests = require('./testMemoize'); | ||
describe('memo-cache Module', function() { | ||
cacheTests.runTests(); | ||
memoTests.runTests(); | ||
}); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
60313
2
9
1101
1
171