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.0 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $TypeError = require('es-errors/type');
|
---|
4 |
|
---|
5 | var IsDataDescriptor = require('./IsDataDescriptor');
|
---|
6 | var IsAccessorDescriptor = require('./IsAccessorDescriptor');
|
---|
7 |
|
---|
8 | var isPropertyDescriptor = require('../helpers/records/property-descriptor');
|
---|
9 |
|
---|
10 | // https://262.ecma-international.org/5.1/#sec-8.10.4
|
---|
11 |
|
---|
12 | module.exports = function FromPropertyDescriptor(Desc) {
|
---|
13 | if (typeof Desc === 'undefined') {
|
---|
14 | return Desc;
|
---|
15 | }
|
---|
16 |
|
---|
17 | if (!isPropertyDescriptor(Desc)) {
|
---|
18 | throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
|
---|
19 | }
|
---|
20 |
|
---|
21 | if (IsDataDescriptor(Desc)) {
|
---|
22 | return {
|
---|
23 | value: Desc['[[Value]]'],
|
---|
24 | writable: !!Desc['[[Writable]]'],
|
---|
25 | enumerable: !!Desc['[[Enumerable]]'],
|
---|
26 | configurable: !!Desc['[[Configurable]]']
|
---|
27 | };
|
---|
28 | } else if (IsAccessorDescriptor(Desc)) {
|
---|
29 | return {
|
---|
30 | get: Desc['[[Get]]'],
|
---|
31 | set: Desc['[[Set]]'],
|
---|
32 | enumerable: !!Desc['[[Enumerable]]'],
|
---|
33 | configurable: !!Desc['[[Configurable]]']
|
---|
34 | };
|
---|
35 | }
|
---|
36 | throw new $TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor');
|
---|
37 |
|
---|
38 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.