Skip to content

isTemporalInstant

Checks if a value is a Temporal.Instant.

Uses instanceof when Temporal is available globally, and falls back to Symbol.toStringTag for environments without Temporal (e.g. browsers).

Available since v2.0.0

import { isTemporalInstant } from '@helpers4/guard';
isTemporalInstant(value: unknown): value is Instant
ParameterTypeDescription
valueunknownThe value to check

value is Instant — True if value is a Temporal.Instant

isTemporalInstant(Temporal.Now.instant())      // => true
isTemporalInstant(Temporal.Now.plainDateISO())  // => false
isTemporalInstant(new Date())                   // => false

View source on GitHub