uber-node / zero-config

A zero configuration configuration loader
MIT License
116 stars 10 forks source link

.get() returns a mutable internal object references. This is a bit confusing. #29

Closed lxe closed 8 years ago

lxe commented 9 years ago

Here's what I'm talking about:

var zc = require('zero-config');
var config = zc(process.cwd()); 

config.set('lol', { foo: { bar: 42 }});
console.log(config.get('lol'));
// {foo: { bar : 42 }}

config.get('lol').foo = 'mutated internally' // this is not good
console.log(config.get('lol'));
// { foo: 'mutated internally' }

I think that you should only be able to mutate the config via .set(). .get() should return copies/clones of objects, not internal references.

Raynos commented 9 years ago

good idea.