mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
20 lines
409 B
TypeScript
20 lines
409 B
TypeScript
import { fileURLToPath } from 'url';
|
|
|
|
export function pathify(path: string): string {
|
|
if (path.startsWith('file://')) {
|
|
path = fileURLToPath(path);
|
|
}
|
|
return path;
|
|
}
|
|
|
|
export function instantiateEmscriptenWasm<T extends EmscriptenWasm.Module>(
|
|
factory: EmscriptenWasm.ModuleFactory<T>,
|
|
path: string,
|
|
): Promise<T> {
|
|
return factory({
|
|
locateFile() {
|
|
return pathify(path);
|
|
},
|
|
});
|
|
}
|