arnaucube
arnaucube/thoughtsPublic Self-hosted repository
thoughts/node_modules/jsonwebtoken/lib/timespan.js
node_modules/jsonwebtoken/lib/timespan.jsRaw
 1var ms = require('ms');
 2
 3module.exports = function (time, iat) {
 4  var timestamp = iat || Math.floor(Date.now() / 1000);
 5
 6  if (typeof time === 'string') {
 7    var milliseconds = ms(time);
 8    if (typeof milliseconds === 'undefined') {
 9      return;
10    }
11    return Math.floor(timestamp + milliseconds / 1000);
12  } else if (typeof time === 'number') {
13    return timestamp + time;
14  } else {
15    return;
16  }
17
18};