* * @param {object} config
(config)
| 407 | * @param {object} config |
| 408 | */ |
| 409 | static resolveDeferredConfigs(config) { |
| 410 | const deferred = []; |
| 411 | |
| 412 | function _iterate (prop) { |
| 413 | if (prop == null || prop.constructor === String) { |
| 414 | return; |
| 415 | } |
| 416 | |
| 417 | // We put the properties we are going to look it in an array to keep the order predictable |
| 418 | const propsToSort = Object.keys(prop).filter((property) => prop[property] != null); |
| 419 | |
| 420 | // Second step is to iterate of the elements in a predictable (sorted) order |
| 421 | for (let name of propsToSort.sort()) { |
| 422 | const property = prop[name]; |
| 423 | |
| 424 | if (property.constructor === Object) { |
| 425 | _iterate(property); |
| 426 | } else if (property.constructor === Array) { |
| 427 | property.forEach(function (entry, i) { |
| 428 | if (entry instanceof DeferredConfig) { |
| 429 | deferred.push(entry.prepare(config, property, i)); |
| 430 | } else { |
| 431 | _iterate(property[i]); |
| 432 | } |
| 433 | }); |
| 434 | } else if (property instanceof DeferredConfig) { |
| 435 | deferred.push(property.prepare(config, prop, name)); |
| 436 | } |
| 437 | // else: Nothing to do. Keep the property how it is. |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | _iterate(config); |
| 442 | |
| 443 | deferred.forEach((defer) => { defer.resolve() }); |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * Used to resolve configs that have async functions. |
no test coverage detected