File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -164,17 +164,21 @@ function Cache () {
164
164
165
165
var record = cacheToImport [ key ] ;
166
166
167
- // This could possibly be `'NaN'` if there's no expiry set.
167
+ // record.expire could be `'NaN'` if no expiry was set.
168
+ // Try to subtract from it; a string minus a number is `NaN`, which is perfectly fine here.
168
169
var remainingTime = record . expire - currTime ;
169
170
170
171
if ( remainingTime <= 0 ) {
171
- // Delete any record that might exist with the same key.
172
+ // Delete any record that might exist with the same key, since this key is expired .
172
173
this . del ( key ) ;
173
174
continue ;
174
175
}
175
176
176
- // Remaining time is either positive, or `'NaN'`.
177
- this . put ( key , record . value , remainingTime > 0 ? remainingTime : undefined ) ;
177
+ // Remaining time must now be either positive or `NaN`,
178
+ // but `put` will throw an error if we try to give it `NaN`.
179
+ remainingTime = remainingTime > 0 ? remainingTime : undefined ;
180
+
181
+ this . put ( key , record . value , remainingTime ) ;
178
182
}
179
183
}
180
184
You can’t perform that action at this time.
0 commit comments