Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 7ab98de

Browse files
committed
feat: add fetchURL function
1 parent 595ca54 commit 7ab98de

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/load/fetchURL.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { decode } from './decode.js';
2+
3+
/**
4+
* Fetches image URL and decodes it.
5+
* @param dataUrl - Image URL.
6+
* @returns decoded image data.
7+
*/
8+
export async function fetchURL(dataUrl: string) {
9+
const response = await fetch(dataUrl);
10+
const arrayBuffer = await response.arrayBuffer();
11+
const image = decode(new Uint8Array(arrayBuffer));
12+
return image;
13+
}

0 commit comments

Comments
 (0)