MCPcopy
hub / github.com/formatjs/formatjs / get

Function get

packages/intl-numberformat/core.ts:185–220  ·  view source on GitHub ↗
(this: NumberFormat)

Source from the content-addressed store, hash-verified

183 enumerable: false,
184 configurable: true,
185 get(this: NumberFormat) {
186 if (typeof this !== 'object' || !OrdinaryHasInstance(NumberFormat, this)) {
187 throw TypeError(
188 'Intl.NumberFormat format property accessor called on incompatible receiver'
189 )
190 }
191 const internalSlots = getInternalSlots(this as any)
192 let boundFormat = internalSlots.boundFormat
193 if (boundFormat === undefined) {
194 // https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-number-format-functions
195 boundFormat = (
196 value?:
197 | number
198 | bigint
199 | `${number}`
200 | 'Infinity'
201 | '-Infinity'
202 | '+Infinity'
203 ) => FormatNumeric(internalSlots, ToIntlMathematicalValue(value))
204
205 try {
206 // https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/format-function-name.js
207 Object.defineProperty(boundFormat, 'name', {
208 configurable: true,
209 enumerable: false,
210 writable: false,
211 value: '',
212 })
213 } catch {
214 // In older browser (e.g Chrome 36 like polyfill-fastly.io)
215 // TypeError: Cannot redefine property: name
216 }
217 internalSlots.boundFormat = boundFormat
218 }
219 return boundFormat
220 },
221} as const
222try {
223 // https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/name.js

Callers

nothing calls this directly

Calls 4

OrdinaryHasInstanceFunction · 0.85
FormatNumericFunction · 0.85
ToIntlMathematicalValueFunction · 0.85
getInternalSlotsFunction · 0.70

Tested by

no test coverage detected