Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 views
1
/**
2
* Copyright 2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule Object.assign
10
*/
11
12
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
13
14
function assign(target, sources) {
15
if (target == null) {
16
throw new TypeError('Object.assign target cannot be null or undefined');
17
}
18
19
var to = Object(target);
20
var hasOwnProperty = Object.prototype.hasOwnProperty;
21
22
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
23
var nextSource = arguments[nextIndex];
24
if (nextSource == null) {
25
continue;
26
}
27
28
var from = Object(nextSource);
29
30
// We don't currently support accessors nor proxies. Therefore this
31
// copy cannot throw. If we ever supported this then we must handle
32
// exceptions and side-effects. We don't support symbols so they won't
33
// be transferred.
34
35
for (var key in from) {
36
if (hasOwnProperty.call(from, key)) {
37
to[key] = from[key];
38
}
39
}
40
}
41
42
return to;
43
};
44
45
module.exports = assign;
46
47