MCPcopy
hub / github.com/formatjs/formatjs / resolvedOptions

Method resolvedOptions

packages/intl-durationformat/core.ts:254–279  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

252 )
253 }
254 resolvedOptions(): ResolvedDurationFormatOptions {
255 if (
256 typeof this !== 'object' ||
257 !OrdinaryHasInstance(DurationFormat, this)
258 ) {
259 throw TypeError(
260 'Method Intl.DurationFormat.prototype.resolvedOptions called on incompatible receiver'
261 )
262 }
263 const internalSlots = getInternalSlots(this)
264 const ro: Record<string, unknown> = {}
265 for (const key of RESOLVED_OPTIONS_KEYS) {
266 let v = internalSlots[key]
267 if (key === 'fractionalDigits') {
268 if (v !== undefined) {
269 v = Number(v)
270 }
271 } else if (v === 'fractional') {
272 v = 'numeric'
273 } else {
274 invariant(v !== undefined, `Missing internal slot ${key}`)
275 }
276 ro[key] = v
277 }
278 return ro as any
279 }
280 formatToParts(duration: DurationInput): DurationFormatPart[] {
281 const locInternalSlots = getInternalSlots(this)
282 if (locInternalSlots.initializedDurationFormat === undefined) {

Callers

nothing calls this directly

Calls 3

OrdinaryHasInstanceFunction · 0.85
getInternalSlotsFunction · 0.70
invariantFunction · 0.50

Tested by

no test coverage detected