1 |
3a515b92
|
cagy
|
'use strict';
|
2 |
|
|
|
3 |
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
4 |
|
|
|
5 |
|
|
var $TypeError = GetIntrinsic('%TypeError%');
|
6 |
|
|
|
7 |
|
|
var DefineOwnProperty = require('../helpers/DefineOwnProperty');
|
8 |
|
|
|
9 |
|
|
var FromPropertyDescriptor = require('./FromPropertyDescriptor');
|
10 |
|
|
var IsDataDescriptor = require('./IsDataDescriptor');
|
11 |
|
|
var IsPropertyKey = require('./IsPropertyKey');
|
12 |
|
|
var SameValue = require('./SameValue');
|
13 |
|
|
var Type = require('./Type');
|
14 |
|
|
|
15 |
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-createmethodproperty
|
16 |
|
|
|
17 |
|
|
module.exports = function CreateMethodProperty(O, P, V) {
|
18 |
|
|
if (Type(O) !== 'Object') {
|
19 |
|
|
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
if (!IsPropertyKey(P)) {
|
23 |
|
|
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
var newDesc = {
|
27 |
|
|
'[[Configurable]]': true,
|
28 |
|
|
'[[Enumerable]]': false,
|
29 |
|
|
'[[Value]]': V,
|
30 |
|
|
'[[Writable]]': true
|
31 |
|
|
};
|
32 |
|
|
return DefineOwnProperty(
|
33 |
|
|
IsDataDescriptor,
|
34 |
|
|
SameValue,
|
35 |
|
|
FromPropertyDescriptor,
|
36 |
|
|
O,
|
37 |
|
|
P,
|
38 |
|
|
newDesc
|
39 |
|
|
);
|
40 |
|
|
};
|