{"id":21531907,"url":"https://github.com/matrixai/js-workers","last_synced_at":"2025-04-10T00:28:47.082Z","repository":{"id":40415044,"uuid":"406294445","full_name":"MatrixAI/js-workers","owner":"MatrixAI","description":"Multi-Threaded Workers","archived":false,"fork":false,"pushed_at":"2025-03-11T00:58:17.000Z","size":1295,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"staging","last_synced_at":"2025-04-03T10:01:34.473Z","etag":null,"topics":["threads","webworkers","workers"],"latest_commit_sha":null,"homepage":"https://polykey.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatrixAI.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":"2021-09-14T08:56:29.000Z","updated_at":"2025-03-11T00:51:55.000Z","dependencies_parsed_at":"2024-06-21T04:18:57.627Z","dependency_job_id":"fa4596eb-fadf-4863-88ad-12980e1ce21f","html_url":"https://github.com/MatrixAI/js-workers","commit_stats":{"total_commits":64,"total_committers":3,"mean_commits":"21.333333333333332","dds":0.1875,"last_synced_commit":"e7ef2c34493378902a2b8e75e2e74b20b9ed3933"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-workers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-workers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-workers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatrixAI%2Fjs-workers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatrixAI","download_url":"https://codeload.github.com/MatrixAI/js-workers/tar.gz/refs/heads/staging","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248133749,"owners_count":21053317,"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","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":["threads","webworkers","workers"],"created_at":"2024-11-24T02:18:05.491Z","updated_at":"2025-04-10T00:28:47.072Z","avatar_url":"https://github.com/MatrixAI.png","language":"TypeScript","readme":"# js-workers\n\nWorkers is the library for multi-threading in MatrixAI's JavaScript/TypeScript applications. It is based on top of threads.js.\n\nCurrently no support for Mobile OSes.\n\nNote that only `ArrayBuffer` can be zero-copy transferred to the worker threads. This means if you are wroking with Node `Buffer` you must first slice and copy the `ArrayBuffer` out of the Node `Buffer`.\n\n```ts\nconst b = Buffer.from('hello world');\nconst ab = b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);\n```\n\nThe following diagram is an example architecture of using `ArrayBuffer`:\n\n```\n┌───────────────────────┐\n│      Main Thread      │\n│                       │\n│     ┌───────────┐     │\n│     │Node Buffer│     │\n│     └─────┬─────┘     │          ┌────────────────────────┐\n│           │           │          │                        │\n│     Slice │ Copy      │          │      Worker Thread     │\n│           │           │          │                        │\n│  ┌────────▼────────┐  │ Transfer │  ┌──────────────────┐  │\n│  │Input ArrayBuffer├──┼──────────┼──►                  │  │\n│  └─────────────────┘  │          │  └─────────┬────────┘  │\n│                       │          │            │           │\n│                       │          │    Compute │           │\n│                       │          │            │           │\n│  ┌─────────────────┐  │          │  ┌─────────▼────────┐  │\n│  │                 ◄──┼──────────┼──┤Output ArrayBuffer│  │\n│  └─────────────────┘  │ Transfer │  └──────────────────┘  │\n│                       │          │                        │\n│                       │          │                        │\n└───────────────────────┘          └────────────────────────┘\n```\n\nSee the benchmarks and tests for examples of using this library.\n\n## Installation\n\n```sh\nnpm install --save @matrixai/workers\n```\n\n## Development\n\nRun `nix develop`, and once you're inside, you can use:\n\n```sh\n# install (or reinstall packages from package.json)\nnpm install\n# build the dist\nnpm run build\n# run the repl (this allows you to import from ./src)\nnpm run tsx\n# run the tests\nnpm run test\n# lint the source code\nnpm run lint\n# automatically fix the source\nnpm run lintfix\n```\n\n## Benchmarks\n\n```sh\nnpm run bench\n```\n\nView benchmarks here: https://github.com/MatrixAI/js-workers/blob/master/benches/results/WorkerManager.chart.html with https://raw.githack.com/\n\n### Docs Generation\n\n```sh\nnpm run docs\n```\n\nSee the docs at: https://matrixai.github.io/js-workers/\n\n### Publishing\n\nPublishing is handled automatically by the staging pipeline.\n\nPrerelease:\n\n```sh\n# npm login\nnpm version prepatch --preid alpha # premajor/preminor/prepatch\ngit push --follow-tags\n```\n\nRelease:\n\n```sh\n# npm login\nnpm version patch # major/minor/patch\ngit push --follow-tags\n```\n\nManually:\n\n```sh\n# npm login\nnpm version patch # major/minor/patch\nnpm run build\nnpm publish --access public\ngit push\ngit push --tags\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixai%2Fjs-workers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrixai%2Fjs-workers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixai%2Fjs-workers/lists"}