assign.js 449 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var has = require('has');
  4. var $assign = GetIntrinsic('%Object%').assign;
  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 (has(source, key)) {
  12. // eslint-disable-next-line no-param-reassign
  13. target[key] = source[key];
  14. }
  15. }
  16. return target;
  17. };