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’sidlegrace (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).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
flag |
Flag |
options? |
StalenessOptions |
Returns
Section titled “Returns”Example
Section titled “Example”import { flagStaleness } from "@xtandard/flags";
const { stale, ageDays } = flagStaleness(flag, { now: "2026-06-29T00:00:00Z" });