-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate.ts
More file actions
29 lines (23 loc) · 1.38 KB
/
date.ts
File metadata and controls
29 lines (23 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @file Safe references to `Date`. `DateNow` prefers the smol Fast API binding
* (single-byte wallclock read inlined into JIT'd callers) when available;
* stock Node falls back to `Date.now`.
*/
import { getSmolPrimordial } from '../smol/primordial'
import { uncurryThis } from './uncurry'
const _smolPrimordial = getSmolPrimordial()
export const DateCtor: DateConstructor = Date
// ─── Date (static) ─────────────────────────────────────────────────────
// `dateNow` Fast API binding inlines the wallclock-read into JIT'd
// callers — meaningful win in tight monitoring loops where Date.now()
// is called millions of times/sec for performance traces.
export const DateNow = _smolPrimordial?.dateNow ?? Date.now
export const DateParse = Date.parse
export const DateUTC = Date.UTC
// ─── Date (prototype) ──────────────────────────────────────────────────
export const DatePrototypeGetTime = uncurryThis(Date.prototype.getTime)
export const DatePrototypeToISOString = uncurryThis(Date.prototype.toISOString)
export const DatePrototypeToLocaleString = uncurryThis(
Date.prototype.toLocaleString,
)
export const DatePrototypeValueOf = uncurryThis(Date.prototype.valueOf)