import {createChunk} from "@/utils/fileUtil/CreateChunk";
import {proxy} from "vue/src/core/instance/state";
import SparkMD5 from "spark-md5";

onmessage = async(e)=>{
    const {
        file,
        CHUNK_SIZE,
        startChunkIndex: start,
        endChunkIndex:end ,// (i+1) * threadChunckCount
    } = e.data
    const proms = []; //
    for (let i = start; i<end;i++){
        proms.push(createChunk(file,i,CHUNK_SIZE));
    }
    const chunks = await Promise.all(proms) //  所有分片结果
    postMessage(chunks) // 返回处理结果给主线程
    new SparkMD5()

}
export default Worker;