()
| 638 | } |
| 639 | |
| 640 | function checkLoaded() { |
| 641 | var err, usingPathFallback, |
| 642 | waitInterval = config.waitSeconds * 1000, |
| 643 | //It is possible to disable the wait interval by using waitSeconds of 0. |
| 644 | expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), |
| 645 | noLoads = [], |
| 646 | reqCalls = [], |
| 647 | stillLoading = false, |
| 648 | needCycleCheck = true; |
| 649 | |
| 650 | //Do not bother if this call was a result of a cycle break. |
| 651 | if (inCheckLoaded) { |
| 652 | return; |
| 653 | } |
| 654 | |
| 655 | inCheckLoaded = true; |
| 656 | |
| 657 | //Figure out the state of all the modules. |
| 658 | eachProp(enabledRegistry, function (mod) { |
| 659 | var map = mod.map, |
| 660 | modId = map.id; |
| 661 | |
| 662 | //Skip things that are not enabled or in error state. |
| 663 | if (!mod.enabled) { |
| 664 | return; |
| 665 | } |
| 666 | |
| 667 | if (!map.isDefine) { |
| 668 | reqCalls.push(mod); |
| 669 | } |
| 670 | |
| 671 | if (!mod.error) { |
| 672 | //If the module should be executed, and it has not |
| 673 | //been inited and time is up, remember it. |
| 674 | if (!mod.inited && expired) { |
| 675 | if (hasPathFallback(modId)) { |
| 676 | usingPathFallback = true; |
| 677 | stillLoading = true; |
| 678 | } else { |
| 679 | noLoads.push(modId); |
| 680 | removeScript(modId); |
| 681 | } |
| 682 | } else if (!mod.inited && mod.fetched && map.isDefine) { |
| 683 | stillLoading = true; |
| 684 | if (!map.prefix) { |
| 685 | //No reason to keep looking for unfinished |
| 686 | //loading. If the only stillLoading is a |
| 687 | //plugin resource though, keep going, |
| 688 | //because it may be that a plugin resource |
| 689 | //is waiting on a non-plugin cycle. |
| 690 | return (needCycleCheck = false); |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | }); |
| 695 | |
| 696 | if (expired && noLoads.length) { |
| 697 | //If wait time expired, throw error of unloaded modules. |
no test coverage detected
searching dependent graphs…