index.js 817 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  3. function ToObject(val) {
  4. if (val == null) {
  5. throw new TypeError('Object.assign cannot be called with null or undefined');
  6. }
  7. return Object(val);
  8. }
  9. function ownEnumerableKeys(obj) {
  10. var keys = Object.getOwnPropertyNames(obj);
  11. if (Object.getOwnPropertySymbols) {
  12. keys = keys.concat(Object.getOwnPropertySymbols(obj));
  13. }
  14. return keys.filter(function (key) {
  15. return propIsEnumerable.call(obj, key);
  16. });
  17. }
  18. module.exports = Object.assign || function (target, source) {
  19. var from;
  20. var keys;
  21. var to = ToObject(target);
  22. for (var s = 1; s < arguments.length; s++) {
  23. from = arguments[s];
  24. keys = ownEnumerableKeys(Object(from));
  25. for (var i = 0; i < keys.length; i++) {
  26. to[keys[i]] = from[keys[i]];
  27. }
  28. }
  29. return to;
  30. };