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

Function CurlApi

test/curl.js:946–968  ·  view source on GitHub ↗
(ids, callback, waitFor)

Source from the content-addressed store, hash-verified

944
945 // thanks to Joop Ringelberg for helping troubleshoot the API
946 function CurlApi (ids, callback, waitFor) {
947 var then, ctx;
948 ctx = core.createContext(userCfg, undef, [].concat(ids));
949 this['then'] = then = function (resolved, rejected) {
950 when(ctx,
951 // return the dependencies as arguments, not an array
952 function (deps) {
953 if (resolved) resolved.apply(undef, deps);
954 },
955 // just throw if the dev didn't specify an error handler
956 function (ex) {
957 if (rejected) rejected(ex); else throw ex;
958 }
959 );
960 return this;
961 };
962 this['next'] = function (ids, cb) {
963 // chain api
964 return new CurlApi(ids, cb, ctx);
965 };
966 if (callback) then(callback);
967 when(waitFor, function () { core.getDeps(ctx); });
968 }
969
970 return new CurlApi(args[0], args[1]);
971

Callers

nothing calls this directly

Calls 2

whenFunction · 0.85
thenFunction · 0.85

Tested by

no test coverage detected