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

Function newContext

public/javascripts/require.js:197–1696  ·  view source on GitHub ↗
(contextName)

Source from the content-addressed store, hash-verified

195 }
196
197 function newContext(contextName) {
198 var inCheckLoaded, Module, context, handlers,
199 checkLoadedTimeoutId,
200 config = {
201 //Defaults. Do not set a default for map
202 //config to speed up normalize(), which
203 //will run faster if there is no default.
204 waitSeconds: 7,
205 baseUrl: './',
206 paths: {},
207 bundles: {},
208 pkgs: {},
209 shim: {},
210 config: {}
211 },
212 registry = {},
213 //registry of just enabled modules, to speed
214 //cycle breaking code when lots of modules
215 //are registered, but not activated.
216 enabledRegistry = {},
217 undefEvents = {},
218 defQueue = [],
219 defined = {},
220 urlFetched = {},
221 bundlesMap = {},
222 requireCounter = 1,
223 unnormalizedCounter = 1;
224
225 /**
226 * Trims the . and .. from an array of path segments.
227 * It will keep a leading path segment if a .. will become
228 * the first path segment, to help with module name lookups,
229 * which act like paths, but can be remapped. But the end result,
230 * all paths that use this function should look normalized.
231 * NOTE: this method MODIFIES the input array.
232 * @param {Array} ary the array of path segments.
233 */
234 function trimDots(ary) {
235 var i, part;
236 for (i = 0; i < ary.length; i++) {
237 part = ary[i];
238 if (part === '.') {
239 ary.splice(i, 1);
240 i -= 1;
241 } else if (part === '..') {
242 // If at the start, or previous value is still ..,
243 // keep them so that when converted to a path it may
244 // still work when converted to a path, even though
245 // as an ID it is less than ideal. In larger point
246 // releases, may be better to just kick out an error.
247 if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') {
248 continue;
249 } else if (i > 0) {
250 ary.splice(i - 1, 2);
251 i -= 2;
252 }
253 }
254 }

Callers

nothing calls this directly

Calls 15

getOwnFunction · 0.85
bindFunction · 0.85
isFunctionFunction · 0.85
onErrorFunction · 0.85
cleanRegistryFunction · 0.85
makeModuleMapFunction · 0.85
normalizeFunction · 0.85
eachPropFunction · 0.85
getModuleFunction · 0.85
hasPropFunction · 0.85
makeErrorFunction · 0.85
localRequireFunction · 0.85

Tested by

no test coverage detected