INNER CODE UNIT · JavaScript

quantify

DinoChiesa/jwt-webtool · src/js/app.js:149

const quantify = (quantity, term) => {
  const termIsPlural = term.endsWith("s"),
    quantityIsPlural = quantity != 1 && quantity != -1;
  if (termIsPlural && !quantityIsPlural) return term.slice(0, -1);
  return !termIsPlural && quantityIsPlural ? term + "s" : term;
};

function reformIndents(s) {
  const s2 = s
    .split(new RegExp("\n", "g"))
    .map((s) => s.trim())
    .join("\n");
  return s2.trim();
}

function timeAgo(time) {
  return new TimeAgo("en-US").format(time);
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…