Comparing version 1.0.0 to 1.0.2
43
index.js
@@ -1,7 +0,14 @@ | ||
module.exports = function (max) { | ||
var size = 0, cache = {}, _cache = {} | ||
function update (key, value) { | ||
cache[key] = value | ||
size ++ | ||
if(size >= max) { | ||
size = 0 | ||
_cache = cache | ||
cache = {} | ||
} | ||
} | ||
return { | ||
@@ -11,24 +18,7 @@ get: function (key) { | ||
if(v) return v | ||
if(v = _cache[key]) { | ||
cache[key] = v | ||
size ++ | ||
if(size >= max) { | ||
size = 0 | ||
_cache = cache | ||
cache = {} | ||
} | ||
} | ||
if(v = _cache[key]) update(key, v) | ||
}, | ||
set: function (key, value) { | ||
if(cache[key]) { | ||
cache[key] = value | ||
} else { | ||
cache[key] = value | ||
size ++ | ||
if(size >= max) { | ||
size = 0 | ||
_cache = cache | ||
cache = {} | ||
} | ||
} | ||
if(cache[key]) cache[key] = value | ||
else update(key, value) | ||
} | ||
@@ -41,1 +31,8 @@ } | ||
{ | ||
"name": "hashlru", | ||
"description": "", | ||
"version": "1.0.0", | ||
"description": "simpler faster substitute for LRU", | ||
"version": "1.0.2", | ||
"homepage": "https://github.com/dominictarr/hashlru", | ||
@@ -6,0 +6,0 @@ "repository": { |
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
5641
23