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

Function get

packages/intl-collator/core.ts:170–192  ·  view source on GitHub ↗
(this: CollatorType)

Source from the content-addressed store, hash-verified

168Object.defineProperty(Collator.prototype, 'compare', {
169 configurable: true,
170 get(this: CollatorType) {
171 if (
172 typeof this !== 'object' ||
173 !OrdinaryHasInstance(Collator, this)
174 ) {
175 throw TypeError(
176 'Intl.Collator compare property accessor called on incompatible receiver'
177 )
178 }
179 const collator = this
180 const internalSlots = getInternalSlots(collator)
181 let boundCompare = internalSlots.boundCompare
182 if (boundCompare === undefined) {
183 // Collator Compare Functions convert both arguments with ToString and
184 // then call CompareStrings. The getter caches the bound compare function
185 // in the collator internal slots.
186 // https://tc39.es/ecma402/#sec-collator-comparefunctions
187 boundCompare = (x: string, y: string) =>
188 compareCollatorStrings(internalSlots, String(x), String(y))
189 internalSlots.boundCompare = boundCompare
190 }
191 return boundCompare
192 },
193})
194
195Object.defineProperty(Collator.prototype, 'resolvedOptions', {

Callers

nothing calls this directly

Calls 3

OrdinaryHasInstanceFunction · 0.85
compareCollatorStringsFunction · 0.85
getInternalSlotsFunction · 0.70

Tested by

no test coverage detected