From 37327d168d0bccdf4390ccec467812de11b6b992 Mon Sep 17 00:00:00 2001 From: cs8425 Date: Fri, 6 Nov 2020 16:16:09 +0800 Subject: [PATCH] fix get item without hit will return undefined --- lib/simple_lru.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/simple_lru.js b/lib/simple_lru.js index 82787b9..9fa3555 100644 --- a/lib/simple_lru.js +++ b/lib/simple_lru.js @@ -43,10 +43,8 @@ Cache.prototype.get = function(key,hit){ * it to the head of linked list */ hit = hit != undefined && hit != null ? hit : true; - if(cacheVal && hit) - this.hit(cacheVal) - else - return undefined + if(!cacheVal) return undefined + if(hit) this.hit(cacheVal) return cacheVal.value }