source: imaps-frontend/node_modules/es-abstract/2018/InstanceofOperator.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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