source: imaps-frontend/node_modules/es-abstract/2017/ObjectDefineProperties.js

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.3 KB
Line 
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/6.0/#sec-objectdefineproperties
17module.exports = function ObjectDefineProperties(O, Properties) {
18 var props = ToObject(Properties); // step 1
19 var keys = OwnPropertyKeys(props); // step 2
20 var descriptors = []; // step 3
21
22 forEach(keys, function (nextKey) { // step 4
23 var propDesc = ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a
24 if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b
25 var descObj = Get(props, nextKey); // step 4.b.i
26 var desc = ToPropertyDescriptor(descObj); // step 4.b.ii
27 $push(descriptors, [nextKey, desc]); // step 4.b.iii
28 }
29 });
30
31 forEach(descriptors, function (pair) { // step 5
32 var P = pair[0]; // step 5.a
33 var desc = pair[1]; // step 5.b
34 DefinePropertyOrThrow(O, P, desc); // step 5.c
35 });
36
37 return O; // step 6
38};
Note: See TracBrowser for help on using the repository browser.