source: imaps-frontend/node_modules/es-abstract/2024/ObjectDefineProperties.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.3 KB
RevLine 
[d565449]1'use strict';
2
3var callBound = require('call-bind/callBound');
4
5var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
6var Get = require('./Get');
7var ToObject = require('./ToObject');
8var ToPropertyDescriptor = require('./ToPropertyDescriptor');
9
10var forEach = require('../helpers/forEach');
11var getOwnPropertyDescriptor = require('gopd');
12var OwnPropertyKeys = require('../helpers/OwnPropertyKeys');
13
14var $push = callBound('Array.prototype.push');
15
16// https://262.ecma-international.org/15.0/#sec-objectdefineproperties
17
18module.exports = function ObjectDefineProperties(O, Properties) {
19 var props = ToObject(Properties); // step 1
20 var keys = OwnPropertyKeys(props); // step 2
21 var descriptors = []; // step 3
22
23 forEach(keys, function (nextKey) { // step 4
24 var propDesc = ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a
25 if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b
26 var descObj = Get(props, nextKey); // step 4.b.i
27 var desc = ToPropertyDescriptor(descObj); // step 4.b.ii
28 $push(descriptors, { '[[Key]]': nextKey, '[[Descriptor]]': desc }); // step 4.b.iii
29 }
30 });
31
32 forEach(descriptors, function (pair) { // step 5
33 DefinePropertyOrThrow(O, pair['[[Key]]'], pair['[[Descriptor]]']); // step 5.c
34 });
35
36 return O; // step 6
37};
Note: See TracBrowser for help on using the repository browser.