source: imaps-frontend/node_modules/es-abstract/2023/InstanceofOperator.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 911 bytes
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $TypeError = require('es-errors/type');
6
7var $hasInstance = GetIntrinsic('Symbol.hasInstance', true);
8
9var Call = require('./Call');
10var GetMethod = require('./GetMethod');
11var IsCallable = require('./IsCallable');
12var OrdinaryHasInstance = require('./OrdinaryHasInstance');
13var ToBoolean = require('./ToBoolean');
14var Type = require('./Type');
15
16// https://262.ecma-international.org/6.0/#sec-instanceofoperator
17
18module.exports = function InstanceofOperator(O, C) {
19 if (Type(O) !== 'Object') {
20 throw new $TypeError('Assertion failed: Type(O) is not Object');
21 }
22 var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0;
23 if (typeof instOfHandler !== 'undefined') {
24 return ToBoolean(Call(instOfHandler, C, [O]));
25 }
26 if (!IsCallable(C)) {
27 throw new $TypeError('`C` is not Callable');
28 }
29 return OrdinaryHasInstance(C, O);
30};
Note: See TracBrowser for help on using the repository browser.