File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 11import initializeWasm from './helper' ;
22import { FilesData , IUnpackJSAPI } from './types' ;
33
4+ /**
5+ * Resolve file content given its name (resolving symlinks if any)
6+ * @param files the current FilesData
7+ * @param filename the filename to resolve
8+ * @returns the resolved file content
9+ */
10+ export function resolveFile ( files : FilesData , filename : string ) : Uint8Array {
11+ if ( ! files [ filename ] ) {
12+ throw new Error ( `File ${ filename } does not exist.` ) ;
13+ }
14+
15+ if ( typeof files [ filename ] === 'string' ) {
16+ // It's a symlink
17+ return resolveFile ( files , files [ filename ] ) ;
18+ }
19+
20+ return files [ filename ] ;
21+ }
22+
423export const fetchByteArray = async ( url : string ) : Promise < Uint8Array > => {
524 const response = await fetch ( url ) ;
625 if ( ! response . ok ) {
You can’t perform that action at this time.
0 commit comments