source: frontend/node_modules/es-abstract/2018/DefinePropertyOrThrow.js

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
3var $TypeError = require('es-errors/type');
4var isObject = require('es-object-atoms/isObject');
5
6var isPropertyDescriptor = require('../helpers/records/property-descriptor');
7var DefineOwnProperty = require('../helpers/DefineOwnProperty');
8
9var FromPropertyDescriptor = require('./FromPropertyDescriptor');
10var IsDataDescriptor = require('./IsDataDescriptor');
11var isPropertyKey = require('../helpers/isPropertyKey');
12var SameValue = require('./SameValue');
13var ToPropertyDescriptor = require('./ToPropertyDescriptor');
14
15// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow
16
17module.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.