rsnext/packages/next/server/lib/squoosh/emscripten-utils.ts
Tim Neutkens 5b9ad8da90
Move next-server directory files to server directory (#26756)
* Move next-server directory files to server directory

* Update tests

* Update paths in other places
2021-06-30 13:44:40 +02:00

34 lines
620 B
TypeScript

import { fileURLToPath } from 'url'
export function pathify(path: string) {
if (path.startsWith('file://')) {
path = fileURLToPath(path)
}
return path
}
export function instantiateEmscriptenWasm(
factory: (args: {
locateFile: () => string
}) => {
decode?: (
buffer: Buffer | Uint8Array,
width: number,
height: number,
opts: any
) => Buffer
encode?: (
buffer: Buffer | Uint8Array,
width: number,
height: number,
opts: any
) => Buffer
},
path: string
) {
return factory({
locateFile() {
return pathify(path)
},
})
}