We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c98d54f commit 6cd194eCopy full SHA for 6cd194e
1 file changed
src/index.ts
@@ -1,6 +1,25 @@
1
import initializeWasm from './helper';
2
import { FilesData, IUnpackJSAPI } from './types';
3
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
23
export const fetchByteArray = async (url: string): Promise<Uint8Array> => {
24
const response = await fetch(url);
25
if (!response.ok) {
0 commit comments