Returns a string tag naming which type a value belongs to, or undefined for plain JavaScript values such as native dates, strings, numbers, and objects. Also identifies range instances when @native-dates/plugins/ranges is loaded.
inspect.js
import { date, hours, kindOf, now, time } from 'native-dates';import { dateRange } from '@native-dates/plugins/ranges';kindOf(now()); // 'datetime'kindOf(date('2026-11-16')); // 'date'kindOf(time('9:30am')); // 'time'kindOf(hours(2)); // 'duration'kindOf(dateRange('2026-11-01', '2026-11-07')); // 'dateRange'kindOf(new Date()); // undefined
Returns true when the value is a Time instance, narrowing its type in TypeScript.
import { isTime, time } from 'native-dates';isTime(time('9:30am')); // true
isDuration()
isDuration(value): value is Duration
Returns true when the value is a Duration instance, narrowing its type in TypeScript.
import { hours, isDuration } from 'native-dates';isDuration(hours(2)); // true
Cross-realm instanceof and brands
Standard JavaScript instanceof checks fail across iframe boundaries and duplicate bundled copies. Every class here implements [Symbol.hasInstance] over a global registry symbol, so both instanceof and the guard functions work across realms.
You can also read the exported brand symbols directly when writing custom serializers, test matchers, or generic helpers that detect ranges without importing the ranges plugin:
import { DateTime, IS_DATE_TIME, IS_RANGE, now } from 'native-dates';import { timeRange } from '@native-dates/plugins/ranges';const current = now();current instanceof DateTime; // trueBoolean(current[IS_DATE_TIME]); // trueconst shift = timeRange('9am', '5pm');Boolean(shift[IS_RANGE]); // true
Constant
Global symbol key
Matches
IS_DATE_TIME
Symbol.for('native-dates/DateTime')
Matches any DateTime instance.
IS_CALENDAR_DATE
Symbol.for('native-dates/CalendarDate')
Matches any CalendarDate instance.
IS_TIME
Symbol.for('native-dates/Time')
Matches any Time instance.
IS_DURATION
Symbol.for('native-dates/Duration')
Matches any Duration instance.
IS_RANGE
Symbol.for('native-dates/Range')
Matches DateRange, DateTimeRange, and TimeRange instances.