Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 views
1
/**
2
* Copyright 2013-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 copyProperties
10
*/
11
12
/**
13
* Copy properties from one or more objects (up to 5) into the first object.
14
* This is a shallow copy. It mutates the first object and also returns it.
15
*
16
* NOTE: `arguments` has a very significant performance penalty, which is why
17
* we don't support unlimited arguments.
18
*/
19
function copyProperties(obj, a, b, c, d, e, f) {
20
obj = obj || {};
21
22
if (__DEV__) {
23
if (f) {
24
throw new Error('Too many arguments passed to copyProperties');
25
}
26
}
27
28
var args = [a, b, c, d, e];
29
var ii = 0, v;
30
while (args[ii]) {
31
v = args[ii++];
32
for (var k in v) {
33
obj[k] = v[k];
34
}
35
36
// IE ignores toString in object iteration.. See:
37
// webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html
38
if (v.hasOwnProperty && v.hasOwnProperty('toString') &&
39
(typeof v.toString != 'undefined') && (obj.toString !== v.toString)) {
40
obj.toString = v.toString;
41
}
42
}
43
44
return obj;
45
}
46
47
module.exports = copyProperties;
48
49
// deprecation notice
50
console.warn(
51
'react/lib/copyProperties has been deprecated and will be removed in the ' +
52
'next version of React. All uses can be replaced with ' +
53
'Object.assign(obj, a, b, ...) or _.extend(obj, a, b, ...).'
54
);
55
56