main
Last change
on this file since d565449 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
|
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');
|
---|
| 10 | var IsPropertyKey = require('./IsPropertyKey');
|
---|
| 11 | var SameValue = require('./SameValue');
|
---|
| 12 | var ToPropertyDescriptor = require('./ToPropertyDescriptor');
|
---|
| 13 | var Type = require('./Type');
|
---|
| 14 |
|
---|
| 15 | // https://262.ecma-international.org/6.0/#sec-definepropertyorthrow
|
---|
| 16 |
|
---|
| 17 | module.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.