source: frontend/node_modules/es-abstract/2015/InstanceofOperator.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 927 bytes
RevLine 
[9af201e]1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $TypeError = require('es-errors/type');
6var isObject = require('es-object-atoms/isObject');
7
8var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true);
9
10var Call = require('./Call');
11var GetMethod = require('./GetMethod');
12var IsCallable = require('./IsCallable');
13var OrdinaryHasInstance = require('./OrdinaryHasInstance');
14var ToBoolean = require('./ToBoolean');
15
16// https://262.ecma-international.org/6.0/#sec-instanceofoperator
17
18module.exports = function InstanceofOperator(O, C) {
19 if (!isObject(O)) {
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.