Skip to content

flagStaleness

function flagStaleness(flag, options?): FlagStaleness;

Defined in: lifecycle.ts:107

Assess one flag’s staleness against its Flag.lifecycle policy.

  • Duration expiry → stale when not archived, past the duration from its anchor (createdAt/updatedAt), and idle longer than the policy’s idle grace (default StalenessOptions.idleDays, 7 days).
  • Datetime expiry → stale when not archived and past the deadline (idle is ignored — it’s a hard deadline).

Flags without a lifecycle policy are never stale (opt-in).

Parameter Type
flag Flag
options? StalenessOptions

FlagStaleness

import { flagStaleness } from "@xtandard/flags";
const { stale, ageDays } = flagStaleness(flag, { now: "2026-06-29T00:00:00Z" });