MCPcopy
hub / github.com/jabbany/CommentCoreLibrary / load

Function load

src/scripting/api/Function.js:14–47  ·  view source on GitHub ↗
(library, onComplete)

Source from the content-addressed store, hash-verified

12}
13
14function load (library, onComplete) {
15 if (typeof Runtime === 'undefined' || Runtime === null) {
16 __trace('No runtime defined. Attempting to raw-load library!', 'warn');
17 importScripts(library + '.js');
18 } else {
19 // Delegate this to runtime
20 Runtime.requestLibrary(library, function (error, response) {
21 if (error) {
22 __trace('Load: ' + error, 'warn');
23 } else {
24 if (response.type === 'import') {
25 importScripts(response.location);
26 } else if (response.type === 'raw') {
27 try {
28 eval(response.code);
29 } catch (e) {
30 __trace('Load: ' + e, 'warn');
31 }
32 } else if (response.type === 'object') {
33 if (typeof self === 'object' && self !== null) {
34 self[response.name] = response.obj;
35 }
36 } else if (response.type === 'noop') {
37 // Don't do anything
38 // This means library was already loaded
39 }
40 // Execute the remaining code
41 if (typeof onComplete === 'function') {
42 onComplete();
43 }
44 }
45 });
46 }
47}
48
49function clone (target) {
50 if (null === target || 'object' !== typeof target) {

Callers

nothing calls this directly

Calls 1

__traceFunction · 0.85

Tested by

no test coverage detected