MCPcopy Index your code
hub / github.com/formatjs/formatjs / format

Method format

packages/intl-relativetimeformat/index.ts:32–50  ·  view source on GitHub ↗
(value: number, unit: Intl.RelativeTimeFormatUnit)

Source from the content-addressed store, hash-verified

30 })
31 }
32 format(value: number, unit: Intl.RelativeTimeFormatUnit): string {
33 if (typeof this !== 'object') {
34 throw new TypeError('format was called on a non-object')
35 }
36 const internalSlots = getInternalSlots(this)
37 if (!internalSlots.initializedRelativeTimeFormat) {
38 throw new TypeError('format was called on a invalid context')
39 }
40 return PartitionRelativeTimePattern(
41 this,
42 Number(value),
43 ToString(unit) as Intl.RelativeTimeFormatUnit,
44 {
45 getInternalSlots,
46 }
47 )
48 .map(el => el.value)
49 .join('')
50 }
51 formatToParts(
52 value: number,
53 unit: Intl.RelativeTimeFormatUnit

Callers

nothing calls this directly

Calls 3

ToStringFunction · 0.85
getInternalSlotsFunction · 0.70

Tested by

no test coverage detected