MCPcopy
hub / github.com/brianchirls/Seriously.js / checkLoaded

Function checkLoaded

lib/require.js:616–701  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected