Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80542 views
1
/**
2
* Copyright 2014 Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
* @provides Object.es6
17
* @polyfill
18
*/
19
20
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
21
22
if (!Object.assign) {
23
Object.assign = function(target, sources) {
24
if (target === null || target === undefined) {
25
throw new TypeError('Object.assign target cannot be null or undefined');
26
}
27
28
var to = Object(target);
29
var hasOwnProperty = Object.prototype.hasOwnProperty;
30
31
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
32
var nextSource = arguments[nextIndex];
33
if (nextSource === null || nextSource === undefined) {
34
continue;
35
}
36
37
var from = Object(nextSource);
38
39
// We don't currently support accessors nor proxies. Therefore this
40
// copy cannot throw. If we ever supported this then we must handle
41
// exceptions and side-effects.
42
43
for (var key in from) {
44
if (hasOwnProperty.call(from, key)) {
45
to[key] = from[key];
46
}
47
}
48
}
49
50
return to;
51
};
52
}
53
54