File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33ℹ file | line % | branch % | funcs % | uncovered lines
44ℹ ----------------------------------------------------------
55ℹ src | | | |
6- ℹ lru.js | 100.00 | 98.54 | 100.00 |
6+ ℹ lru.js | 99.70 | 98.54 | 100.00 | 534-535
77ℹ ----------------------------------------------------------
8- ℹ all files | 100.00 | 98.54 | 100.00 |
8+ ℹ all files | 99.70 | 98.54 | 100.00 |
99ℹ ----------------------------------------------------------
1010ℹ end of coverage report
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ export class LRU {
126126
127127 item . prev = null ;
128128 item . next = null ;
129- if ( typeof this . #onEvict === "function" ) {
129+ if ( this . #onEvict !== null ) {
130130 this . #onEvict( {
131131 key : item . key ,
132132 value : item . value ,
@@ -530,7 +530,11 @@ export class LRU {
530530 * @returns {LRU } The LRU instance for method chaining.
531531 */
532532 onEvict ( callback ) {
533- this . #onEvict = typeof callback === "function" ? callback : null ;
533+ if ( typeof callback !== "function" ) {
534+ throw new TypeError ( "onEvict callback must be a function" ) ;
535+ }
536+
537+ this . #onEvict = callback ;
534538
535539 return this ;
536540 }
You can’t perform that action at this time.
0 commit comments