MCPcopy Create free account
hub / github.com/beutton/browser-flight-simulator / ArrayBufferLoader

Class ArrayBufferLoader

packages/core/src/ArrayBufferLoader.ts:4–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import invariant from 'tiny-invariant'
3
4export class ArrayBufferLoader extends Loader<ArrayBuffer> {
5 override load(
6 url: string,
7 onLoad: (data: ArrayBuffer) => void,
8 onProgress?: (event: ProgressEvent) => void,
9 onError?: (error: unknown) => void
10 ): void {
11 const loader = new FileLoader(this.manager)
12 loader.setResponseType('arraybuffer')
13 loader.setRequestHeader(this.requestHeader)
14 loader.setPath(this.path)
15 loader.setWithCredentials(this.withCredentials)
16 loader.load(
17 url,
18 arrayBuffer => {
19 invariant(arrayBuffer instanceof ArrayBuffer)
20 try {
21 onLoad(arrayBuffer)
22 } catch (error) {
23 if (onError != null) {
24 onError(error)
25 } else {
26 console.error(error)
27 }
28 this.manager.itemError(url)
29 }
30 },
31 onProgress,
32 onError
33 )
34 }
35}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected