MCPcopy
hub / github.com/nbubna/store / checkLoaded

Function checkLoaded

libs/requirejs.js:626–711  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 2

localRequireFunction · 0.85
newContextFunction · 0.85

Calls 7

eachPropFunction · 0.85
hasPathFallbackFunction · 0.85
removeScriptFunction · 0.85
makeErrorFunction · 0.85
onErrorFunction · 0.85
breakCycleFunction · 0.85
eachFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…