main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
680 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var GetV = require('./GetV');
|
---|
| 6 | var IsCallable = require('./IsCallable');
|
---|
| 7 | var IsPropertyKey = require('./IsPropertyKey');
|
---|
| 8 |
|
---|
| 9 | var inspect = require('object-inspect');
|
---|
| 10 |
|
---|
| 11 | // https://262.ecma-international.org/6.0/#sec-getmethod
|
---|
| 12 |
|
---|
| 13 | module.exports = function GetMethod(O, P) {
|
---|
| 14 | // 7.3.9.1
|
---|
| 15 | if (!IsPropertyKey(P)) {
|
---|
| 16 | throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | // 7.3.9.2
|
---|
| 20 | var func = GetV(O, P);
|
---|
| 21 |
|
---|
| 22 | // 7.3.9.4
|
---|
| 23 | if (func == null) {
|
---|
| 24 | return void 0;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | // 7.3.9.5
|
---|
| 28 | if (!IsCallable(func)) {
|
---|
| 29 | throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func));
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | // 7.3.9.6
|
---|
| 33 | return func;
|
---|
| 34 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.