assign.js 464 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var hasOwn = require('hasown');
  4. var $assign = GetIntrinsic('%Object.assign%', true);
  5. module.exports = function assign(target, source) {
  6. if ($assign) {
  7. return $assign(target, source);
  8. }
  9. // eslint-disable-next-line no-restricted-syntax
  10. for (var key in source) {
  11. if (hasOwn(source, key)) {
  12. // eslint-disable-next-line no-param-reassign
  13. target[key] = source[key];
  14. }
  15. }
  16. return target;
  17. };