用工小程序前端代码
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.

46 lines
1.4 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. 'use strict';
  2. // modified from https://github.com/es-shims/es6-shim
  3. var objectKeys = require('object-keys');
  4. var hasSymbols = require('has-symbols/shams')();
  5. var callBound = require('call-bound');
  6. var $Object = require('es-object-atoms');
  7. var $push = callBound('Array.prototype.push');
  8. var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable');
  9. var originalGetSymbols = hasSymbols ? $Object.getOwnPropertySymbols : null;
  10. // eslint-disable-next-line no-unused-vars
  11. module.exports = function assign(target, source1) {
  12. if (target == null) { throw new TypeError('target must be an object'); }
  13. var to = $Object(target); // step 1
  14. if (arguments.length === 1) {
  15. return to; // step 2
  16. }
  17. for (var s = 1; s < arguments.length; ++s) {
  18. var from = $Object(arguments[s]); // step 3.a.i
  19. // step 3.a.ii:
  20. var keys = objectKeys(from);
  21. var getSymbols = hasSymbols && ($Object.getOwnPropertySymbols || originalGetSymbols);
  22. if (getSymbols) {
  23. var syms = getSymbols(from);
  24. for (var j = 0; j < syms.length; ++j) {
  25. var key = syms[j];
  26. if ($propIsEnumerable(from, key)) {
  27. $push(keys, key);
  28. }
  29. }
  30. }
  31. // step 3.a.iii:
  32. for (var i = 0; i < keys.length; ++i) {
  33. var nextKey = keys[i];
  34. if ($propIsEnumerable(from, nextKey)) { // step 3.a.iii.2
  35. var propValue = from[nextKey]; // step 3.a.iii.2.a
  36. to[nextKey] = propValue; // step 3.a.iii.2.b
  37. }
  38. }
  39. }
  40. return to; // step 4
  41. };