MCPcopy Create free account
hub / github.com/cujojs/poly / getDep

Function getDep

test/curl.js:710–750  ·  view source on GitHub ↗
(name, index)

Source from the content-addressed store, hash-verified

708 return parentDef;
709
710 function getDep (name, index) {
711 var resolveOnce, exportOnce, childDef, earlyExport;
712
713 resolveOnce = countdown(1, function (dep) {
714 exportOnce(dep);
715 resolveCollector(dep, index);
716 });
717 exportOnce = countdown(1, function (dep) {
718 exportCollector(dep, index);
719 });
720
721 // get child def / dep
722 childDef = core.fetchDep(name, parentDef);
723
724 // check if childDef can export. if it can, then
725 // we missed the notification and it will never fire in the
726 // when() below.
727 earlyExport = isPromise(childDef) && childDef.exports;
728 if (earlyExport) {
729 exportOnce(earlyExport);
730 }
731
732 when(childDef,
733 resolveOnce,
734 parentDef.reject,
735 parentDef.exports && function (msg) {
736 // messages are only sent from childDefs that support
737 // exports, and we only notify parents that understand
738 // exports too.
739 if (childDef.exports) {
740 if (msg == msgUsingExports) {
741 // if we're using exports cjs variable on both sides
742 exportOnce(childDef.exports);
743 }
744 else if (msg == msgFactoryExecuted) {
745 resolveOnce(childDef.exports);
746 }
747 }
748 }
749 );
750 }
751
752 function allResolved () {
753 parentDef.resolve(deps);

Callers 1

curl.jsFile · 0.85

Calls 3

countdownFunction · 0.85
isPromiseFunction · 0.85
whenFunction · 0.85

Tested by

no test coverage detected