(name)
| 539 | } |
| 540 | |
| 541 | function lazyLoad(name) { |
| 542 | return new Proxy( |
| 543 | {}, |
| 544 | { |
| 545 | get(target, prop) { |
| 546 | // behavr like array or |
| 547 | if (prop === 'length') return Object.keys(config).length |
| 548 | if (prop === Symbol.iterator) { |
| 549 | return function* () { |
| 550 | for (let i = 0; i < Object.keys(config).length; i++) { |
| 551 | yield target[i] |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | // load actual name from vocabulary |
| 557 | if (container.translation && container.translation.I && name === 'I') { |
| 558 | // Use translated name for I |
| 559 | const actualName = container.translation.I |
| 560 | if (actualName !== 'I') { |
| 561 | name = actualName |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | if (name === 'I') { |
| 566 | if (!container.support.I) { |
| 567 | // Actor will be created during container.create() |
| 568 | return undefined |
| 569 | } |
| 570 | methodsOfObject(container.support.I) |
| 571 | return container.support.I[prop] |
| 572 | } |
| 573 | |
| 574 | if (!container.support[name] && typeof config[name] === 'object') { |
| 575 | container.support[name] = config[name] |
| 576 | } |
| 577 | |
| 578 | if (!container.support[name]) { |
| 579 | // Cannot load object synchronously in proxy getter |
| 580 | // Return undefined and log warning - object should be pre-loaded during container creation |
| 581 | debug(`Support object ${name} not pre-loaded, returning undefined`) |
| 582 | return undefined |
| 583 | } |
| 584 | |
| 585 | const currentObject = container.support[name] |
| 586 | let currentValue = currentObject[prop] |
| 587 | |
| 588 | if (isFunction(currentValue) || isAsyncFunction(currentValue)) { |
| 589 | if (prop.toString().charAt(0) !== '_' && currentObject._before && !beforeCalledSet.has(name)) { |
| 590 | beforeCalledSet.add(name) |
| 591 | const originalValue = currentValue |
| 592 | const wrappedValue = async function (...args) { |
| 593 | await currentObject._before() |
| 594 | return originalValue.apply(currentObject, args) |
| 595 | } |
| 596 | const ms = new MetaStep(name, prop) |
| 597 | ms.setContext(currentObject) |
| 598 | debug(`metastep is created for ${name}.${prop.toString()}() (with _before)`) |
no outgoing calls
no test coverage detected