|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 | var isObject = require('es-object-atoms/isObject');
|
|---|
| 5 |
|
|---|
| 6 | var isPropertyDescriptor = require('../helpers/records/property-descriptor');
|
|---|
| 7 | var DefineOwnProperty = require('../helpers/DefineOwnProperty');
|
|---|
| 8 |
|
|---|
| 9 | var FromPropertyDescriptor = require('./FromPropertyDescriptor');
|
|---|
| 10 | var IsDataDescriptor = require('./IsDataDescriptor');
|
|---|
| 11 | var isPropertyKey = require('../helpers/isPropertyKey');
|
|---|
| 12 | var SameValue = require('./SameValue');
|
|---|
| 13 | var ToPropertyDescriptor = require('./ToPropertyDescriptor');
|
|---|
| 14 |
|
|---|
| 15 | // https://262.ecma-international.org/6.0/#sec-definepropertyorthrow
|
|---|
| 16 |
|
|---|
| 17 | module.exports = function DefinePropertyOrThrow(O, P, desc) {
|
|---|
| 18 | if (!isObject(O)) {
|
|---|
| 19 | throw new $TypeError('Assertion failed: Type(O) is not Object');
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | if (!isPropertyKey(P)) {
|
|---|
| 23 | throw new $TypeError('Assertion failed: P is not a Property Key');
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc);
|
|---|
| 27 | if (!isPropertyDescriptor(Desc)) {
|
|---|
| 28 | throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor');
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | return DefineOwnProperty(
|
|---|
| 32 | IsDataDescriptor,
|
|---|
| 33 | SameValue,
|
|---|
| 34 | FromPropertyDescriptor,
|
|---|
| 35 | O,
|
|---|
| 36 | P,
|
|---|
| 37 | Desc
|
|---|
| 38 | );
|
|---|
| 39 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.