You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this.K = typeof Keys === 'function' ? new Keys(capacity) : new Array(capacity); ^RangeError: Invalid array length at new LRUCache (/Users/trivikr/workspace/lru-cache/node_modules/mnemonist/lru-cache.js:47:62) at Object.<anonymous> (/Users/trivikr/workspace/lru-cache/index.js:3:15) at Module._compile (internal/modules/cjs/loader.js:1068:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10) at Module.load (internal/modules/cjs/loader.js:933:32) at Function.Module._load (internal/modules/cjs/loader.js:774:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47
Expected behavior
A custom error can be thrown on this line instead after adding a check for integer:
if(typeofthis.capacity!=='number'||this.capacity<=0)if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)thrownewError('mnemonist/lru-cache: capacity should be a finite positive integer.');thrownewError('mnemonist/lru-cache: capacity should be positive number.');
Describe the issue
LRUCache throws "Invalid array length" as an error if float value is passed to it.
Steps to reproduce
Run the following code with
mnemonist@0.38.3
Observed behavior
The following error is thrown:
Expected behavior
A custom error can be thrown on this line instead after adding a check for integer:
mnemonist/lru-cache.js
Lines 40 to 41 in 825538a
The text was updated successfully, but these errors were encountered: