_objectAssign.js 698 B

1234567891011121314151617181920212223242526272829
  1. import _has from "./_has.js"; // Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  2. function _objectAssign(target) {
  3. if (target == null) {
  4. throw new TypeError('Cannot convert undefined or null to object');
  5. }
  6. var output = Object(target);
  7. var idx = 1;
  8. var length = arguments.length;
  9. while (idx < length) {
  10. var source = arguments[idx];
  11. if (source != null) {
  12. for (var nextKey in source) {
  13. if (_has(nextKey, source)) {
  14. output[nextKey] = source[nextKey];
  15. }
  16. }
  17. }
  18. idx += 1;
  19. }
  20. return output;
  21. }
  22. export default typeof Object.assign === 'function' ? Object.assign : _objectAssign;