PageSourceSearch

https://crazycars.pages.dev/modules__.js

js crazycars.pages.dev collected 2026-10-03 06:38:14 UTC 2,593 bytes, 70 lines download raw bytes

1var loadModules = function (modules, urlPrefix, doneCallback) { // eslint-disable-line no-unused-vars
2
3    // check for wasm module support
4    function wasmSupported() {
5        try {
6            if (typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function") {
7                const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
8                if (module instanceof WebAssembly.Module)
9                    return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
10            }
11        } catch (e) { }
12        return false;
13    }
14
15    // load a script
16    function loadScriptAsync(url, doneCallback) {
17        var tag = document.createElement('script');
18        tag.onload = function () {
19            doneCallback();
20        };
21        tag.onerror = function () {
22            throw new Error('failed to load ' + url);
23        };
24        tag.async = true;
25        tag.src = url;
26        tag.crossOrigin = 'anonymous';
27        document.head.appendChild(tag);
28    }
29
30    // load and initialize a wasm module
31    function loadWasmModuleAsync(moduleName, jsUrl, binaryUrl, doneCallback) {
32        loadScriptAsync(jsUrl, function () {
33            var lib = window[moduleName];
34            window[moduleName + 'Lib'] = lib;
35            lib({ locateFile: function () { return binaryUrl; } } ).then( function (instance) {
36                window[moduleName] = instance;
37                doneCallback();
38            });
39        });
40    }
41
42    if (typeof modules === "undefined" || modules.length === 0) {
43        // caller may depend on callback behaviour being async
44        setTimeout(doneCallback);
45    } else {
46        var asyncCounter = modules.length;
47        var asyncCallback = function () {
48            asyncCounter--;
49            if (asyncCounter === 0) {
50                doneCallback();
51            }
52        };
53
54        var wasm = wasmSupported();
55        modules.forEach(function (m) {
56            if (!m.hasOwnProperty('preload') || m.preload) {
57                if (wasm) {
58                    loadWasmModuleAsync(m.moduleName, urlPrefix + m.glueUrl, urlPrefix + m.wasmUrl, asyncCallback);
59                } else {
60                    if (!m.fallbackUrl) {
61                        throw new Error('wasm not supported and no fallback supplied for module ' + m.moduleName);
62                    }
63                    loadWasmModuleAsync(m.moduleName, urlPrefix + m.fallbackUrl, "", asyncCallback);
64                }
65            } else {
66                asyncCallback();
67            }
68        });
69    }
70};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.