|
44 | 44 |
|
45 | 45 | })(function (Require, Promise, URL) { |
46 | 46 |
|
47 | | - if (!this) |
| 47 | + if (!this) { |
48 | 48 | throw new Error("Require does not work in strict mode."); |
| 49 | + } |
49 | 50 |
|
50 | 51 | var globalEval = eval; // reassigning causes eval to not use lexical scope. |
51 | 52 |
|
|
139 | 140 | // data-lock on a cycle of dependencies. |
140 | 141 | loading = loading || {}; |
141 | 142 | // has this all happened before? will it happen again? |
142 | | - if (has(loading, topId)) |
| 143 | + if (has(loading, topId)) { |
143 | 144 | return; // break the cycle of violence. |
| 145 | + } |
144 | 146 | loading[topId] = true; // this has happened before |
145 | 147 | return load(topId, viaId) |
146 | 148 | .then(function () { |
|
234 | 236 | // too much performance evil for one function. |
235 | 237 | function identify(id2, require2, seen) { |
236 | 238 | var location = config.location; |
237 | | - if (require2.location === location) |
| 239 | + if (require2.location === location) { |
238 | 240 | return id2; |
| 241 | + } |
239 | 242 |
|
240 | 243 | var internal = !!seen; |
241 | 244 | seen = seen || {}; |
242 | | - if (has(seen, location)) |
| 245 | + if (has(seen, location)) { |
243 | 246 | return null; // break the cycle of violence. |
| 247 | + } |
244 | 248 | seen[location] = true; |
245 | | - |
| 249 | + /*jshint -W089 */ |
246 | 250 | for (var name in config.mappings) { |
247 | 251 | var mapping = config.mappings[name]; |
248 | 252 | location = mapping.location; |
249 | | - if (!config.hasPackage(location)) |
| 253 | + if (!config.hasPackage(location)) { |
250 | 254 | continue; |
| 255 | + } |
251 | 256 | var candidate = config.getPackage(location); |
252 | 257 | var id1 = candidate.identify(id2, require2, seen); |
253 | 258 | if (id1 === null) { |
|
265 | 270 | "Can't identify " + id2 + " from " + require2.location |
266 | 271 | ); |
267 | 272 | } |
| 273 | + /*jshint +W089 */ |
268 | 274 | } |
269 | 275 |
|
270 | 276 | // Creates a unique require function for each module that encapsulates |
|
387 | 393 | try { |
388 | 394 | return JSON.parse(json); |
389 | 395 | } catch (error) { |
390 | | - error.message = error.message + " in " + JSON.stringify(descriptionLocation) |
| 396 | + error.message = error.message + " in " + JSON.stringify(descriptionLocation); |
391 | 397 | throw error; |
392 | 398 | } |
393 | 399 | }); |
|
409 | 415 |
|
410 | 416 | config.hasPackage = function (dependency) { |
411 | 417 | dependency = normalizeDependency(dependency, config); |
412 | | - if (!dependency.location) |
| 418 | + if (!dependency.location) { |
413 | 419 | return false; |
| 420 | + } |
414 | 421 | var location = dependency.location; |
415 | 422 | return !!loadedPackages[location]; |
416 | 423 | }; |
|
494 | 501 | dependency.name + "/" |
495 | 502 | ); |
496 | 503 | } |
497 | | - if (!dependency.location) |
| 504 | + if (!dependency.location) { |
498 | 505 | return dependency; // partially completed |
| 506 | + } |
499 | 507 | // make sure the dependency location has a trailing slash so that |
500 | 508 | // relative urls will resolve properly |
501 | 509 | if (!/\/$/.test(dependency.location)) { |
|
550 | 558 | var overlay = description.overlay || {}; |
551 | 559 | var layer; |
552 | 560 | (config.overlays || Require.overlays).forEach(function (engine) { |
| 561 | + /*jshint -W089 */ |
553 | 562 | if (overlay[engine]) { |
554 | 563 | var layer = overlay[engine]; |
555 | 564 | for (var name in layer) { |
556 | 565 | description[name] = layer[name]; |
557 | 566 | } |
558 | 567 | } |
| 568 | + /*jshint +W089 */ |
559 | 569 | }); |
560 | 570 | delete description.overlay; |
561 | 571 |
|
|
611 | 621 | // dependencies, devDependencies if not in production |
612 | 622 | [description.dependencies, !config.production ? description.devDependencies : null] |
613 | 623 | .forEach(function (dependencies) { |
614 | | - if (!dependencies) |
| 624 | + if (!dependencies) { |
615 | 625 | return; |
| 626 | + } |
616 | 627 | Object.keys(dependencies).forEach(function (name) { |
617 | 628 | if (!mappings[name]) { |
618 | 629 | // dependencies are equivalent to name and version mappings, |
|
656 | 667 | source.unshift.apply(source, parts); |
657 | 668 | } |
658 | 669 | for (var i = 0, ii = source.length; i < ii; i++) { |
| 670 | + /*jshint -W035 */ |
659 | 671 | var part = source[i]; |
660 | 672 | if (part === "" || part === ".") { |
661 | 673 | } else if (part === "..") { |
|
665 | 677 | } else { |
666 | 678 | target.push(part); |
667 | 679 | } |
| 680 | + /*jshint +W035 */ |
668 | 681 | } |
669 | 682 | return target.join("/"); |
670 | 683 | } |
|
804 | 817 | id.indexOf(prefix) === 0 && |
805 | 818 | id.charAt(prefix.length) === "/" |
806 | 819 | ) { |
| 820 | + /*jshint -W083 */ |
807 | 821 | var mapping = mappings[prefix]; |
808 | 822 | var rest = id.slice(prefix.length + 1); |
809 | 823 | return config.loadPackage(mapping, config) |
810 | 824 | .then(function (mappingRequire) { |
| 825 | + /*jshint +W083 */ |
811 | 826 | module.mappingRedirect = rest; |
812 | 827 | module.mappingRequire = mappingRequire; |
813 | 828 | return mappingRequire.deepLoad(rest, config.location); |
|
0 commit comments