MCPcopy Index your code
hub / github.com/ded/script.js / $script

Function $script

src/script.js:30–67  ·  view source on GitHub ↗
(paths, idOrDone, optDone)

Source from the content-addressed store, hash-verified

28 }
29
30 function $script(paths, idOrDone, optDone) {
31 paths = paths[push] ? paths : [paths]
32 var idOrDoneIsDone = idOrDone && idOrDone.call
33 , done = idOrDoneIsDone ? idOrDone : optDone
34 , id = idOrDoneIsDone ? paths.join('') : idOrDone
35 , queue = paths.length
36 function loopFn(item) {
37 return item.call ? item() : list[item]
38 }
39 function callback() {
40 if (!--queue) {
41 list[id] = 1
42 done && done()
43 for (var dset in delay) {
44 every(dset.split('|'), loopFn) && !each(delay[dset], loopFn) && (delay[dset] = [])
45 }
46 }
47 }
48 setTimeout(function () {
49 each(paths, function loading(path, force) {
50 if (path === null) return callback()
51
52 if (!force && !/^https?:\/\//.test(path) && scriptpath) {
53 path = (path.indexOf('.js') === -1) ? scriptpath + path + '.js' : scriptpath + path;
54 }
55
56 if (scripts[path]) {
57 if (id) ids[id] = 1
58 return (scripts[path] == 2) ? callback() : setTimeout(function () { loading(path, true) }, 0)
59 }
60
61 scripts[path] = 1
62 if (id) ids[id] = 1
63 create(path, callback)
64 })
65 }, 0)
66 return $script
67 }
68
69 function create(path, fn) {
70 var el = doc.createElement('script'), loaded

Callers 1

script.jsFile · 0.85

Calls 3

eachFunction · 0.85
callbackFunction · 0.85
createFunction · 0.85

Tested by

no test coverage detected