|
'use strict'; |
|
|
|
var GetIntrinsic = require('get-intrinsic'); |
|
|
|
var $TypeError = GetIntrinsic('%TypeError%'); |
|
|
|
var GetV = require('./GetV'); |
|
var IsCallable = require('./IsCallable'); |
|
var IsPropertyKey = require('./IsPropertyKey'); |
|
|
|
var inspect = require('object-inspect'); |
|
|
|
|
|
|
|
module.exports = function GetMethod(O, P) { |
|
|
|
if (!IsPropertyKey(P)) { |
|
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); |
|
} |
|
|
|
|
|
var func = GetV(O, P); |
|
|
|
|
|
if (func == null) { |
|
return void 0; |
|
} |
|
|
|
|
|
if (!IsCallable(func)) { |
|
throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); |
|
} |
|
|
|
|
|
return func; |
|
}; |
|
|