UNPKG

414 BJavaScriptView Raw
1// Retrieve the expiration date when caching a file
2const getExpires = function(ttl) {
3 if (!Number.isInteger(ttl) || ttl < 1) {
4 return
5 }
6
7 return Date.now() + ttl * SECS_TO_MSECS
8}
9
10const SECS_TO_MSECS = 1e3
11
12// Check if a file about to be restored is expired
13const checkExpires = function(expires) {
14 return expires !== undefined && Date.now() > expires
15}
16
17module.exports = { getExpires, checkExpires }