{"id":19807933,"url":"https://github.com/jwygithub/file-slice","last_synced_at":"2025-08-23T11:11:54.435Z","repository":{"id":228502183,"uuid":"774165427","full_name":"jwyGithub/file-slice","owner":"jwyGithub","description":"A file slicing tool ","archived":false,"fork":false,"pushed_at":"2024-03-19T07:23:45.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T21:30:36.084Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwyGithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-19T03:55:11.000Z","updated_at":"2024-03-19T04:02:43.000Z","dependencies_parsed_at":"2024-03-19T05:24:51.996Z","dependency_job_id":"4b2deb63-b58a-40d2-bc54-b44eb3c8118f","html_url":"https://github.com/jwyGithub/file-slice","commit_stats":null,"previous_names":["jwygithub/file-slice"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jwyGithub/file-slice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Ffile-slice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Ffile-slice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Ffile-slice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Ffile-slice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwyGithub","download_url":"https://codeload.github.com/jwyGithub/file-slice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwyGithub%2Ffile-slice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271746767,"owners_count":24813582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T09:12:22.772Z","updated_at":"2025-08-23T11:11:54.395Z","avatar_url":"https://github.com/jwyGithub.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# file-slice\n\nA file slicing tool\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/@jiangweiye/file-slice\" alt='version'\u003e\n  \u003cimg src=\"https://img.shields.io/npm/dm/@jiangweiye/file-slice\" alt='download'\u003e\n  \u003cimg src=\"https://img.shields.io/github/issues/jwyGithub/file-slice\" alt='issues'\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/jwyGithub/file-slice\" alt='license'\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n## Install\n\n### pnpm\n\n```sh\npnpm add @jiangweiye/file-slice\n```\n\n### yarn\n\n```sh\nyarn add @jiangweiye/file-slice\n```\n\n### npm\n\n```sh\nnpm install @jiangweiye/file-slice\n```\n\n## Usage\n\n### vite\n\n```typescript\nimport { sliceFile } from '@jiangweiye/file-slice';\n// specify the imported file as worker\nimport WorkerScript from '@jiangweiye/file-slice/worker?worker';\n\nconst CHUNK_SIZE = 1024 * 1024 * 5;\nconst THREAD_COUNT = 4;\n\nconst selectFile = document.querySelector\u003cHTMLInputElement\u003e('#select-file');\n\nselectFile?.addEventListener('change', async e =\u003e {\n    const file = (e.target as HTMLInputElement).files?.[0];\n\n    const chunks = await sliceFile({\n        file: file!,\n        chunkSize: CHUNK_SIZE,\n        threadCount: THREAD_COUNT,\n        workerScript: () =\u003e new WorkerScript()\n    });\n\n    console.log('chunks', chunks);\n});\n```\n\n### webpack\n\n```bash\nnpm install worker-loader -D\n```\n\n```javascript\nmodule.exports = {\n    module: {\n        rules: [\n            {\n                test: /\\.worker\\.js$/,\n                use: { loader: 'worker-loader' }\n            }\n        ]\n    }\n};\n```\n\n```typescript\nimport { sliceFile } from '@jiangweiye/file-slice';\nimport WorkerScript from '@jiangweiye/file-slice/slice.worker.js';\n\nconst CHUNK_SIZE = 1024 * 1024 * 5;\nconst THREAD_COUNT = 4;\n\ndocument.getElementById('select-file').addEventListener('change', async function (e) {\n    const file = e.target.files?.[0];\n\n    const chunks = await sliceFile({\n        file: file,\n        chunkSize: CHUNK_SIZE,\n        threadCount: THREAD_COUNT,\n        workerScript: () =\u003e new WorkerScript()\n    });\n\n    console.log('chunks', chunks);\n});\n```\n\n### Options\n\n```typescript\ninterface ISliceFileOptions {\n    /**\n     * @description 文件\n     */\n    file: File;\n    /**\n     * @description 切片大小\n     * @default 1024 * 1024\n     */\n    chunkSize?: number;\n    /**\n     * @description 线程数\n     * @default navigator.hardwareConcurrency || 4\n     */\n    threadCount?: number;\n    /**\n     * @description worker脚本\n     */\n    workerScript: ((...args: any[]) =\u003e Worker) | string;\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwygithub%2Ffile-slice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwygithub%2Ffile-slice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwygithub%2Ffile-slice/lists"}