MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / localRequire

Function localRequire

public/javascripts/require.js:1369–1432  ·  view source on GitHub ↗
(deps, callback, errback)

Source from the content-addressed store, hash-verified

1367 options = options || {};
1368
1369 function localRequire(deps, callback, errback) {
1370 var id, map, requireMod;
1371
1372 if (options.enableBuildCallback && callback && isFunction(callback)) {
1373 callback.__requireJsBuild = true;
1374 }
1375
1376 if (typeof deps === 'string') {
1377 if (isFunction(callback)) {
1378 //Invalid call
1379 return onError(makeError('requireargs', 'Invalid require call'), errback);
1380 }
1381
1382 //If require|exports|module are requested, get the
1383 //value for them from the special handlers. Caveat:
1384 //this only works while module is being defined.
1385 if (relMap && hasProp(handlers, deps)) {
1386 return handlers[deps](registry[relMap.id]);
1387 }
1388
1389 //Synchronous access to one module. If require.get is
1390 //available (as in the Node adapter), prefer that.
1391 if (req.get) {
1392 return req.get(context, deps, relMap, localRequire);
1393 }
1394
1395 //Normalize module name, if it contains . or ..
1396 map = makeModuleMap(deps, relMap, false, true);
1397 id = map.id;
1398
1399 if (!hasProp(defined, id)) {
1400 return onError(makeError('notloaded', 'Module name "' +
1401 id +
1402 '" has not been loaded yet for context: ' +
1403 contextName +
1404 (relMap ? '' : '. Use require([])')));
1405 }
1406 return defined[id];
1407 }
1408
1409 //Grab defines waiting in the global queue.
1410 intakeDefines();
1411
1412 //Mark all the dependencies as needing to be loaded.
1413 context.nextTick(function () {
1414 //Some defines could have been added since the
1415 //require call, collect them.
1416 intakeDefines();
1417
1418 requireMod = getModule(makeModuleMap(null, relMap));
1419
1420 //Store if map config should be applied to this require
1421 //call for dependencies.
1422 requireMod.skipMap = options.skipMap;
1423
1424 requireMod.init(deps, callback, errback, {
1425 enabled: true
1426 });

Callers 1

newContextFunction · 0.85

Calls 8

isFunctionFunction · 0.85
onErrorFunction · 0.85
makeErrorFunction · 0.85
hasPropFunction · 0.85
makeModuleMapFunction · 0.85
intakeDefinesFunction · 0.85
getModuleFunction · 0.85
checkLoadedFunction · 0.85

Tested by

no test coverage detected