MCPcopy
hub / github.com/formatjs/formatjs / OrdinaryHasInstance

Function OrdinaryHasInstance

packages/ecma262-abstract/OrdinaryHasInstance.ts:8–30  ·  view source on GitHub ↗
(
  C: object,
  O: any,
  internalSlots?: {boundTargetFunction: any}
)

Source from the content-addressed store, hash-verified

6 * https://tc39.es/ecma262/#sec-ordinaryhasinstance
7 */
8export function OrdinaryHasInstance(
9 C: object,
10 O: any,
11 internalSlots?: {boundTargetFunction: any}
12): boolean {
13 if (!IsCallable(C)) {
14 return false
15 }
16 if (internalSlots?.boundTargetFunction) {
17 let BC = internalSlots?.boundTargetFunction
18 return O instanceof BC
19 }
20 if (typeof O !== 'object') {
21 return false
22 }
23 let P = C.prototype
24 if (typeof P !== 'object') {
25 throw new TypeError(
26 'OrdinaryHasInstance called on an object with an invalid prototype property.'
27 )
28 }
29 return Object.prototype.isPrototypeOf.call(P, O)
30}

Callers 7

core.tsFile · 0.85
getFunction · 0.85
core.tsFile · 0.85
getFunction · 0.85
resolvedOptionsMethod · 0.85
getFunction · 0.85
core.tsFile · 0.85

Calls 1

IsCallableFunction · 0.70

Tested by

no test coverage detected