Comparing version 1.2.0 to 1.2.1
1.2.1 / 2018-07-11 | ||
================== | ||
**others** | ||
* [[`475abb0`](http://github.com/node-modules/ylru/commit/475abb0e9c787fd65d7c3dd3d2d74d67560b0bec)] - perf: only call Date.now() when necessary (#3) (Yiyu He <<dead_horse@qq.com>>) | ||
1.2.0 / 2017-07-18 | ||
@@ -3,0 +9,0 @@ ================== |
17
index.js
@@ -14,6 +14,11 @@ 'use strict'; | ||
const maxAge = options && options.maxAge; | ||
// only call Date.now() when necessary | ||
let now; | ||
function getNow() { | ||
now = now || Date.now(); | ||
return now; | ||
} | ||
if (item) { | ||
const now = Date.now(); | ||
// check expired | ||
if (item.expired && now > item.expired) { | ||
if (item.expired && getNow() > item.expired) { | ||
item.expired = 0; | ||
@@ -24,3 +29,3 @@ item.value = undefined; | ||
if (maxAge !== undefined) { | ||
const expired = maxAge ? now + maxAge : 0; | ||
const expired = maxAge ? getNow() + maxAge : 0; | ||
item.expired = expired; | ||
@@ -35,5 +40,4 @@ } | ||
if (item) { | ||
const now = Date.now(); | ||
// check expired | ||
if (item.expired && now > item.expired) { | ||
if (item.expired && getNow() > item.expired) { | ||
item.expired = 0; | ||
@@ -46,3 +50,3 @@ item.value = undefined; | ||
if (maxAge !== undefined) { | ||
const expired = maxAge ? now + maxAge : 0; | ||
const expired = maxAge ? getNow() + maxAge : 0; | ||
item.expired = expired; | ||
@@ -106,1 +110,2 @@ } | ||
module.exports = LRU; | ||
{ | ||
"name": "ylru", | ||
"description": "Extends LRU base on hashlru", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"homepage": "https://github.com/node-modules/ylru", | ||
@@ -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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7446
94
0