cached-lookup
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -9,4 +9,3 @@ class CachedLookup { | ||
// Ensure lookup is a function type | ||
if (typeof lookup !== 'function') | ||
throw new Error('new CachedLookup(lookup) -> lookup must be a Function'); | ||
if (typeof lookup !== 'function') throw new Error('new CachedLookup(lookup) -> lookup must be a Function'); | ||
this.#lookup = lookup; | ||
@@ -44,2 +43,6 @@ } | ||
cached(max_age) { | ||
// Ensure max_age is a valid greater than zero number | ||
if (typeof max_age !== 'number' || max_age < 0) | ||
throw new Error('CachedLookup.cached(max_age) -> max_age must be a number that is greater than zero.'); | ||
// Return value from cache if it is still valid | ||
@@ -91,3 +94,3 @@ if (this._is_cache_valid(max_age)) return Promise.resolve(this.#value); | ||
/** | ||
* Expires current cached value by setting its timestamp to 0 | ||
* Expires the current cached value. | ||
*/ | ||
@@ -94,0 +97,0 @@ expire() { |
{ | ||
"name": "cached-lookup", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "A Simple Package To Cache And Save On Expensive Lookups & Operations.", | ||
"main": "index.js", | ||
"types": "./types/index.d.ts", | ||
"scripts": { | ||
@@ -20,4 +21,5 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
"intermittent", | ||
"expensive", | ||
"efficient" | ||
"efficient", | ||
"async", | ||
"fast" | ||
], | ||
@@ -24,0 +26,0 @@ "author": "kartikk221", |
@@ -19,5 +19,8 @@ # CachedLookup: A Simple Package To Cache And Save On Expensive Lookups & Operations. | ||
- Simple-to-use API | ||
- TypeScript Support | ||
- Asynchronous By Nature | ||
- Customizable Cache Lifetime | ||
- Dynamic Cache Consumption | ||
- Extremely Lightweight | ||
- Customizable Cache Lifetime | ||
- No Dependencies | ||
@@ -24,0 +27,0 @@ ## Installation |
10938
5
144
86