source: imaps-frontend/node_modules/es-abstract/2017/CompletePropertyDescriptor.js@ d565449

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
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var hasOwn = require('hasown');
6
7var IsDataDescriptor = require('./IsDataDescriptor');
8var IsGenericDescriptor = require('./IsGenericDescriptor');
9
10var isPropertyDescriptor = require('../helpers/records/property-descriptor');
11
12// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor
13
14module.exports = function CompletePropertyDescriptor(Desc) {
15 if (!isPropertyDescriptor(Desc)) {
16 throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
17 }
18
19 /* eslint no-param-reassign: 0 */
20
21 if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) {
22 if (!hasOwn(Desc, '[[Value]]')) {
23 Desc['[[Value]]'] = void 0;
24 }
25 if (!hasOwn(Desc, '[[Writable]]')) {
26 Desc['[[Writable]]'] = false;
27 }
28 } else {
29 if (!hasOwn(Desc, '[[Get]]')) {
30 Desc['[[Get]]'] = void 0;
31 }
32 if (!hasOwn(Desc, '[[Set]]')) {
33 Desc['[[Set]]'] = void 0;
34 }
35 }
36 if (!hasOwn(Desc, '[[Enumerable]]')) {
37 Desc['[[Enumerable]]'] = false;
38 }
39 if (!hasOwn(Desc, '[[Configurable]]')) {
40 Desc['[[Configurable]]'] = false;
41 }
42 return Desc;
43};
Note: See TracBrowser for help on using the repository browser.