1
0

shim.js 483 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var keys = require('../keys')
  3. , value = require('../valid-value')
  4. , max = Math.max;
  5. module.exports = function (dest, src/*, …srcn*/) {
  6. var error, i, l = max(arguments.length, 2), assign;
  7. dest = Object(value(dest));
  8. assign = function (key) {
  9. try { dest[key] = src[key]; } catch (e) {
  10. if (!error) error = e;
  11. }
  12. };
  13. for (i = 1; i < l; ++i) {
  14. src = arguments[i];
  15. keys(src).forEach(assign);
  16. }
  17. if (error !== undefined) throw error;
  18. return dest;
  19. };