'use strict';

/*!
 * @techmely/utils
 * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
 * MIT Licensed
 */


// src/runHeavyAsyncFn/index.ts
var runAsync = (fn) => {
  const worker = new Worker(URL.createObjectURL(new Blob([`postMessage((${fn})());`])));
  return new Promise((res, rej) => {
    worker.onmessage = ({ data }) => {
      res(data);
      worker.terminate();
    };
    worker.onerror = (err) => {
      rej(err);
      worker.terminate();
    };
  });
};

exports.runAsync = runAsync;
