Commit 4a8c119
authored
refactor(module): simplify and fix configMerge (#4203)
I had a hard time understanding `configMerge` - the old `arguments`
slicing and nested loops took me a while. The jsdoc didn't help much.
After it finally clicked, I rewrote it to be readable: rest param + a
simple `for...of` instead of the `while`-stack.
And there's one real behavior fix. With this default and user config:
```js
defaults: { foo: { a: 1 } }
config: { foo: [10, 20] }
```
the old code merged them into `{ foo: { 0: 10, 1: 20, a: 1 } }`. Now the
array just replaces the object -> `{ foo: [10, 20] }`.
I added a small test for that case.
Only affects modules using `configDeepMerge: true` that override an
object default with an array, so the impact is tiny.1 parent ed95826 commit 4a8c119
2 files changed
Lines changed: 36 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
445 | 433 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
464 | 446 | | |
465 | 447 | | |
466 | | - | |
| 448 | + | |
| 449 | + | |
467 | 450 | | |
468 | 451 | | |
469 | 452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
248 | 262 | | |
249 | 263 | | |
250 | 264 | | |
| |||
0 commit comments