fillIn.js 512 B

123456789101112131415161718192021
  1. var forEach = require('../array/forEach');
  2. var slice = require('../array/slice');
  3. var forOwn = require('./forOwn');
  4. /**
  5. * Copy missing properties in the obj from the defaults.
  6. */
  7. function fillIn(obj, var_defaults){
  8. forEach(slice(arguments, 1), function(base){
  9. forOwn(base, function(val, key){
  10. if (obj[key] == null) {
  11. obj[key] = val;
  12. }
  13. });
  14. });
  15. return obj;
  16. }
  17. module.exports = fillIn;