source: imaps-frontend/node_modules/object.assign/implementation.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.4 KB
Line 
1'use strict';
2
3// modified from https://github.com/es-shims/es6-shim
4var objectKeys = require('object-keys');
5var hasSymbols = require('has-symbols/shams')();
6var callBound = require('call-bind/callBound');
7var toObject = Object;
8var $push = callBound('Array.prototype.push');
9var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable');
10var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
11
12// eslint-disable-next-line no-unused-vars
13module.exports = function assign(target, source1) {
14 if (target == null) { throw new TypeError('target must be an object'); }
15 var to = toObject(target); // step 1
16 if (arguments.length === 1) {
17 return to; // step 2
18 }
19 for (var s = 1; s < arguments.length; ++s) {
20 var from = toObject(arguments[s]); // step 3.a.i
21
22 // step 3.a.ii:
23 var keys = objectKeys(from);
24 var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
25 if (getSymbols) {
26 var syms = getSymbols(from);
27 for (var j = 0; j < syms.length; ++j) {
28 var key = syms[j];
29 if ($propIsEnumerable(from, key)) {
30 $push(keys, key);
31 }
32 }
33 }
34
35 // step 3.a.iii:
36 for (var i = 0; i < keys.length; ++i) {
37 var nextKey = keys[i];
38 if ($propIsEnumerable(from, nextKey)) { // step 3.a.iii.2
39 var propValue = from[nextKey]; // step 3.a.iii.2.a
40 to[nextKey] = propValue; // step 3.a.iii.2.b
41 }
42 }
43 }
44
45 return to; // step 4
46};
Note: See TracBrowser for help on using the repository browser.