@@ -60,7 +60,8 @@ zero-config := (dirname: String, opts?: {
6060 dc?: String,
6161 blackList?: Array<String>,
6262 env?: Object<String, String>,
63- seed?: Object<String, Any>
63+ seed?: Object<String, Any>,
64+ defaults?: Object<String, Any>
6465}) => {
6566 get: (keypath?: Keypath) => Any,
6667 set: ((keypath: Keypath, value: Any) => void) &
@@ -107,6 +108,8 @@ Below are the sources it reads in order of least precendence.
107108 you pass ` --foo='bar' --bar.baz='bob' ` you will get
108109 ` { "foo": "bar", "bar": { "baz": "bob" } } `
109110 - a seed object of manual overwrites for testing purposes.
111+ - a defaults object that populates values that have
112+ not been set by any other means.
110113
111114The config loader also uses ` config-chain ` for the actual
112115 loading logic so you can read [ their docs] [ config-chain ]
@@ -203,6 +206,17 @@ The `seed` option is very useful for testing purposes, it allows
203206This is an alternative to the ` NODE_ENV=test ` pattern, we highly
204207 recommend that you do not have a ` test.json ` file at all.
205208
209+ #### ` opts.defaults `
210+
211+ ` opts.defaults ` is optional, it can be set to an object.
212+
213+ If it exists, it will populate all the values that are unset
214+ (but not undefined) in the loaded config with those in
215+ ` opts.defaults ` .
216+
217+ The difference between ` defaults ` and ` seed ` is that ` seed ` over-
218+ writes set values, while ` defaults ` does not.
219+
206220#### ` var value = config.get(keypath) `
207221
208222` config.get(keypath) ` will return the value at a keypath. The
0 commit comments