MCPcopy Create free account
hub / github.com/GoogleChrome/samples / asyncLoad

Function asyncLoad

mkbitmap/mkbitmap.js:1795–1809  ·  view source on GitHub ↗

@param {boolean=} noRunDep

(url, onload, onerror, noRunDep)

Source from the content-addressed store, hash-verified

1793
1794 /** @param {boolean=} noRunDep */
1795 function asyncLoad(url, onload, onerror, noRunDep) {
1796 var dep = !noRunDep ? getUniqueRunDependency('al ' + url) : '';
1797 readAsync(url, (arrayBuffer) => {
1798 assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
1799 onload(new Uint8Array(arrayBuffer));
1800 if (dep) removeRunDependency(dep);
1801 }, (event) => {
1802 if (onerror) {
1803 onerror();
1804 } else {
1805 throw 'Loading data file "' + url + '" failed.';
1806 }
1807 });
1808 if (dep) addRunDependency(dep);
1809 }
1810
1811
1812

Callers 1

mkbitmap.jsFile · 0.70

Calls 4

getUniqueRunDependencyFunction · 0.70
assertFunction · 0.70
removeRunDependencyFunction · 0.70
addRunDependencyFunction · 0.70

Tested by

no test coverage detected