Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80529 views
1
/**
2
* Copyright 2014-2015, 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
'use strict';
15
16
function assign(target, sources) {
17
if (target == null) {
18
throw new TypeError('Object.assign target cannot be null or undefined');
19
}
20
21
var to = Object(target);
22
var hasOwnProperty = Object.prototype.hasOwnProperty;
23
24
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
25
var nextSource = arguments[nextIndex];
26
if (nextSource == null) {
27
continue;
28
}
29
30
var from = Object(nextSource);
31
32
// We don't currently support accessors nor proxies. Therefore this
33
// copy cannot throw. If we ever supported this then we must handle
34
// exceptions and side-effects. We don't support symbols so they won't
35
// be transferred.
36
37
for (var key in from) {
38
if (hasOwnProperty.call(from, key)) {
39
to[key] = from[key];
40
}
41
}
42
}
43
44
return to;
45
}
46
47
module.exports = assign;
48
49