You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
10 years ago
|
/**
|
||
|
* Copyright 2014, Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This file contains an unmodified version of:
|
||
|
* https://github.com/facebook/react/blob/v0.12.0/src/vendor/stubs/Object.assign.js
|
||
|
*
|
||
|
* This source code is licensed under the BSD-style license found here:
|
||
|
* https://github.com/facebook/react/blob/v0.12.0/LICENSE
|
||
|
* An additional grant of patent rights can be found here:
|
||
|
* https://github.com/facebook/react/blob/v0.12.0/PATENTS
|
||
|
*/
|
||
|
|
||
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
function assign(target, sources) {
|
||
|
if (target == null) {
|
||
|
throw new TypeError("Object.assign target cannot be null or undefined");
|
||
|
}
|
||
|
|
||
|
var to = Object(target);
|
||
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||
|
|
||
|
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
|
||
|
var nextSource = arguments[nextIndex];
|
||
|
if (nextSource == null) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
var from = Object(nextSource);
|
||
|
|
||
|
// We don't currently support accessors nor proxies. Therefore this
|
||
|
// copy cannot throw. If we ever supported this then we must handle
|
||
|
// exceptions and side-effects. We don't support symbols so they won't
|
||
|
// be transferred.
|
||
|
|
||
|
for (var key in from) {
|
||
|
if (hasOwnProperty.call(from, key)) {
|
||
|
to[key] = from[key];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return to;
|
||
|
}
|
||
|
|
||
|
module.exports = assign;
|