@@ -137,28 +137,32 @@ var config = Hoek.applyToDefaults(defaults, options, true); // results in { host
137
137
```
138
138
139
139
### applyToDefaultsWithShallow(defaults, options, keys)
140
- keys is an array of key names to shallow copy
140
+ keys is an array of dot-separated, or array-based, key paths to shallow copy
141
141
142
142
Apply options to a copy of the defaults. Keys specified in the last parameter are shallow copied from options instead of merged.
143
143
144
144
``` javascript
145
145
146
146
var defaults = {
147
+ db: {
147
148
server: {
148
149
host: " localhost" ,
149
150
port: 8000
150
151
},
151
152
name: ' example'
152
- };
153
+ }
154
+ };
153
155
154
156
var options = { server: { port: 8080 } };
155
157
156
- var config = Hoek .applyToDefaultsWithShallow (defaults, options, [' server' ]); // results in { server: { port: 8080 }, name: 'example' }
158
+ var config = Hoek .applyToDefaultsWithShallow (defaults, options, [' db.server' ]); // results in { db: { server: { port: 8080 }, name: 'example' } }
159
+ var config = Hoek .applyToDefaultsWithShallow (defaults, options, [[' db' , ' server' ]]); // results in { db: { server: { port: 8080 }, name: 'example' } }
157
160
```
158
161
159
162
### deepEqual(b, a, [ options] )
160
163
161
- Performs a deep comparison of the two values including support for circular dependencies, prototype, and properties. To skip prototype comparisons, use ` options.prototype = false `
164
+ Performs a deep comparison of the two values including support for circular dependencies, prototype, and enumerable properties.
165
+ To skip prototype comparisons, use ` options.prototype = false `
162
166
163
167
``` javascript
164
168
Hoek .deepEqual ({ a: [1 , 2 ], b: ' string' , c: { d: true } }, { a: [1 , 2 ], b: ' string' , c: { d: true } }); // results in true
@@ -218,16 +222,18 @@ flattenedArray = Hoek.flatten(array, target); // results in [4, [5], 1, 2, 3]
218
222
219
223
### reach(obj, chain, [ options] )
220
224
221
- Converts an object key chain string to reference
225
+ Converts an object key chain string or array to reference
222
226
223
227
- ` options ` - optional settings
224
228
- ` separator ` - string to split chain path on, defaults to '.'
225
229
- ` default ` - value to return if the path or value is not present, default is ` undefined `
226
230
- ` strict ` - if ` true ` , will throw an error on missing member, default is ` false `
227
231
- ` functions ` - if ` true ` allow traversing functions for properties. ` false ` will throw an error if a function is part of the chain.
228
232
229
- A chain including negative numbers will work like negative indices on an
230
- array.
233
+ A chain can be a string that will be split into key names using ` separator ` ,
234
+ or an array containing each individual key name.
235
+
236
+ A chain including negative numbers will work like negative indices on an array.
231
237
232
238
If chain is ` null ` , ` undefined ` or ` false ` , the object itself will be returned.
233
239
@@ -238,7 +244,7 @@ var obj = {a : {b : { c : 1}}};
238
244
239
245
Hoek .reach (obj, chain); // returns 1
240
246
241
- var chain = ' a.b.-1 ' ;
247
+ var chain = [ ' a ' , ' b ' , - 1 ] ;
242
248
var obj = {a : {b : [2 ,3 ,6 ]}};
243
249
244
250
Hoek .reach (obj, chain); // returns 6
0 commit comments