INNER CODE UNIT · JavaScript

isExpired

bostrot/wsl2-distro-manager · n8n/licensing/seat_check.js:73

function isExpired(row, now) {
  const exp = Date.parse(row.expires);
  return Number.isNaN(exp) || now.getTime() >= exp;
}

function time(value) {
  const t = Date.parse(value);
  return Number.isNaN(t) ? 0 : t;
}

// The `seats` most recently activated devices that are still around.
function seatHolders(entries, seats, now) {
  const cutoff = now.getTime() - SEAT_WINDOW_DAYS * DAY_MS;
  return entries
    .filter((e) => e.kind === 'device' && time(e.last_seen) >= cutoff)
    .sort((a, b) => time(b.activated_at) - time(a.activated_at)
      || time(b.last_seen) - time(a.last_seen))
    .slice(0, seats);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…