source: imaps-frontend/node_modules/es-abstract/2017/DefinePropertyOrThrow.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var isPropertyDescriptor = require('../helpers/records/property-descriptor');
6var DefineOwnProperty = require('../helpers/DefineOwnProperty');
7
8var FromPropertyDescriptor = require('./FromPropertyDescriptor');
9var IsDataDescriptor = require('./IsDataDescriptor');
10var IsPropertyKey = require('./IsPropertyKey');
11var SameValue = require('./SameValue');
12var ToPropertyDescriptor = require('./ToPropertyDescriptor');
13var Type = require('./Type');
14
15// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow
16
17module.exports = function DefinePropertyOrThrow(O, P, desc) {
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 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.