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:
1.1 KB
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var isPropertyDescriptor = require('../helpers/records/property-descriptor');
|
---|
| 6 | var DefineOwnProperty = require('../helpers/DefineOwnProperty');
|
---|
| 7 |
|
---|
| 8 | var FromPropertyDescriptor = require('./FromPropertyDescriptor');
|
---|
| 9 | var IsDataDescriptor = require('./IsDataDescriptor');
|
---|
[79a0317] | 10 | var isPropertyKey = require('../helpers/isPropertyKey');
|
---|
[d565449] | 11 | var SameValue = require('./SameValue');
|
---|
| 12 | var ToPropertyDescriptor = require('./ToPropertyDescriptor');
|
---|
[79a0317] | 13 |
|
---|
| 14 | var isObject = require('../helpers/isObject');
|
---|
[d565449] | 15 |
|
---|
| 16 | // https://262.ecma-international.org/6.0/#sec-definepropertyorthrow
|
---|
| 17 |
|
---|
| 18 | module.exports = function DefinePropertyOrThrow(O, P, desc) {
|
---|
[79a0317] | 19 | if (!isObject(O)) {
|
---|
[d565449] | 20 | throw new $TypeError('Assertion failed: Type(O) is not Object');
|
---|
| 21 | }
|
---|
| 22 |
|
---|
[79a0317] | 23 | if (!isPropertyKey(P)) {
|
---|
| 24 | throw new $TypeError('Assertion failed: P is not a Property Key');
|
---|
[d565449] | 25 | }
|
---|
| 26 |
|
---|
| 27 | var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc);
|
---|
| 28 | if (!isPropertyDescriptor(Desc)) {
|
---|
| 29 | throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor');
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | return DefineOwnProperty(
|
---|
| 33 | IsDataDescriptor,
|
---|
| 34 | SameValue,
|
---|
| 35 | FromPropertyDescriptor,
|
---|
| 36 | O,
|
---|
| 37 | P,
|
---|
| 38 | Desc
|
---|
| 39 | );
|
---|
| 40 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.