Projekt

Obecné

Profil

Stáhnout (633 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
'use strict';
2
3
var GetIntrinsic = require('../GetIntrinsic');
4
5
var $TypeError = GetIntrinsic('%TypeError%');
6
7
var Get = require('./Get');
8
var IsCallable = require('./IsCallable');
9
var Type = require('./Type');
10
11
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance
12
13
module.exports = function OrdinaryHasInstance(C, O) {
14
	if (IsCallable(C) === false) {
15
		return false;
16
	}
17
	if (Type(O) !== 'Object') {
18
		return false;
19
	}
20
	var P = Get(C, 'prototype');
21
	if (Type(P) !== 'Object') {
22
		throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.');
23
	}
24
	return O instanceof C;
25
};