source: imaps-frontend/node_modules/es-abstract/2022/ObjectDefineProperties.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[d565449]1'use strict';
2
[79a0317]3var callBound = require('call-bound');
[d565449]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');
[79a0317]12var OwnPropertyKeys = require('own-keys');
[d565449]13
14var $push = callBound('Array.prototype.push');
15
16// https://262.ecma-international.org/6.0/#sec-objectdefineproperties
[79a0317]17
18/** @type {<T extends Record<PropertyKey, unknown> = {}>(O: T, Properties: object) => T} */
[d565449]19module.exports = function ObjectDefineProperties(O, Properties) {
20 var props = ToObject(Properties); // step 1
21 var keys = OwnPropertyKeys(props); // step 2
[79a0317]22 /** @type {[string | symbol, import('../types').Descriptor][]} */
[d565449]23 var descriptors = []; // step 3
24
25 forEach(keys, function (nextKey) { // step 4
26 var propDesc = ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a
27 if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b
28 var descObj = Get(props, nextKey); // step 4.b.i
29 var desc = ToPropertyDescriptor(descObj); // step 4.b.ii
30 $push(descriptors, [nextKey, desc]); // step 4.b.iii
31 }
32 });
33
34 forEach(descriptors, function (pair) { // step 5
35 var P = pair[0]; // step 5.a
36 var desc = pair[1]; // step 5.b
37 DefinePropertyOrThrow(O, P, desc); // step 5.c
38 });
39
40 return O; // step 6
41};
Note: See TracBrowser for help on using the repository browser.