From f1e76ce64323ce590a12db35dc30bd8c83703730 Mon Sep 17 00:00:00 2001 From: Lukas Siemon Date: Tue, 3 May 2022 09:24:32 -0700 Subject: [PATCH 1/3] fix: now erroring when bad params --- src/index.js | 7 ++++++- test/index.spec.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 5c43667..e9b2c3f 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,12 @@ import LRU from 'lru-cache'; export default class LRUe extends LRU { constructor({ cacheNull = true, ...options }) { - super(options); + super({ + max: 10000, + options + }); + assert(!('maxAge' in options), 'Please use "ttl" instead of "maxAge"'); + assert('max' in options, 'Please add a "max" value'); this.cacheNull = cacheNull; } diff --git a/test/index.spec.js b/test/index.spec.js index 0269938..fa53376 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -27,8 +27,8 @@ describe('Testing LRUe', () => { let cache; let cacheNoNull; beforeEach(() => { - cache = new LRU({ maxAge: 5 * 60 * 1000 }); - cacheNoNull = new LRU({ maxAge: 5 * 60 * 1000, cacheNull: false }); + cache = new LRU({ max: 10000, ttl: 5 * 60 * 1000 }); + cacheNoNull = new LRU({ max: 10000, ttl: 5 * 60 * 1000, cacheNull: false }); }); describe('Testing memoize', () => { From 93088b52791d1482c9bb49149b11916d404e2d82 Mon Sep 17 00:00:00 2001 From: Lukas Siemon Date: Tue, 3 May 2022 09:25:20 -0700 Subject: [PATCH 2/3] amend: minor --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index e9b2c3f..e000aaf 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,7 @@ export default class LRUe extends LRU { constructor({ cacheNull = true, ...options }) { super({ max: 10000, - options + ...options }); assert(!('maxAge' in options), 'Please use "ttl" instead of "maxAge"'); assert('max' in options, 'Please add a "max" value'); From 0276238270cd7a5ff84d23cc8cd59bebeaa40676 Mon Sep 17 00:00:00 2001 From: Lukas Siemon Date: Tue, 3 May 2022 09:25:48 -0700 Subject: [PATCH 3/3] amend: minor --- src/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index e000aaf..c170d9f 100644 --- a/src/index.js +++ b/src/index.js @@ -3,10 +3,7 @@ import LRU from 'lru-cache'; export default class LRUe extends LRU { constructor({ cacheNull = true, ...options }) { - super({ - max: 10000, - ...options - }); + super(options); assert(!('maxAge' in options), 'Please use "ttl" instead of "maxAge"'); assert('max' in options, 'Please add a "max" value'); this.cacheNull = cacheNull;