Browse Source

Better comments

pull/7/head
Luke Childs 8 years ago
parent
commit
3a4014e1db
  1. 5
      src/index.js

5
src/index.js

@ -3,13 +3,18 @@ const differenceInMilliseconds = require('date-fns/difference_in_milliseconds');
const addSeconds = require('date-fns/add_seconds');
const parse = require('parse-headers');
// Returns boolean for whether or not the cache has expired
const expired = headers => isPast(expired.on(headers));
// Return ms until cache expires
expired.in = headers => differenceInMilliseconds(expired.on(headers), new Date());
// Returns date when cache will expire
expired.on = headers => {
// Parse headers if we got a raw string
headers = (typeof headers === 'string') ? parse(headers) : headers;
// Date from headers
const originDate = new Date(headers.date);
// Get max age ms

Loading…
Cancel
Save