set.js 341 B

1234567891011121314151617
  1. var namespace = require('./namespace');
  2. /**
  3. * set "nested" object property
  4. */
  5. function set(obj, prop, val){
  6. var parts = (/^(.+)\.(.+)$/).exec(prop);
  7. if (parts){
  8. namespace(obj, parts[1])[parts[2]] = val;
  9. } else {
  10. obj[prop] = val;
  11. }
  12. }
  13. module.exports = set;