import { createWorker } from 'worker-lib';
const execute = {};
const createExecuter = (worker) => {
    const key = worker ?? './worker.js';
    if (!execute[key]) {
        execute[key] = createWorker(() => worker
            ? new Worker(new URL(worker, import.meta.url))
            : new Worker(new URL('./worker.js', import.meta.url)), 4);
    }
    return execute[key];
};
export const encode = async ({ data, width, height, quality, worker }) => {
    const execute = createExecuter(worker);
    return data instanceof ImageData
        ? execute('encode', data.data, data.width, data.height, quality || 100)
        : execute('encode', data, width, height, quality || 100);
};
export default true;
//# sourceMappingURL=index.js.map