{"author":{"name":"Christoph Guttandin"},"bugs":{"url":"https://github.com/chrisguttandin/worker-timers-broker/issues"},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"dependencies":{"@babel/runtime":"^7.29.7","broker-factory":"^3.1.15","fast-unique-numbers":"^9.0.27","tslib":"^2.8.1","worker-timers-worker":"^9.0.15"},"description":"The broker which is used by the worker-timers package.","devDependencies":{"@babel/core":"^7.29.7","@babel/plugin-external-helpers":"^7.29.7","@babel/plugin-transform-runtime":"^7.29.7","@babel/preset-env":"^7.29.7","@commitlint/cli":"^21.0.2","@commitlint/config-angular":"^21.0.2","@rollup/plugin-babel":"^7.1.0","@vitest/browser-webdriverio":"^4.1.9","commitizen":"^4.3.2","cz-conventional-changelog":"^3.3.0","eslint":"^9.39.4","eslint-config-holy-grail":"^63.0.4","globals":"^17.6.0","husky":"^9.1.7","lint-staged":"^17.0.7","prettier":"^3.8.4","rimraf":"^6.1.3","rollup":"^4.62.0","tsconfig-holy-grail":"^16.0.0","tslint":"^6.1.3","tslint-config-holy-grail":"^57.0.0","typescript":"^5.9.3","vitest":"^4.1.9"},"homepage":"https://github.com/chrisguttandin/worker-timers-broker","license":"MIT","main":"build/es5/bundle.js","module":"build/es2019/module.js","name":"worker-timers-broker","repository":{"type":"git","url":"git+https://github.com/chrisguttandin/worker-timers-broker.git"},"scripts":{"build":"rimraf build/* && tsc --project src/tsconfig.json && rollup --config config/rollup/bundle.mjs","lint":"npm run lint:config && npm run lint:src && npm run lint:test","lint:config":"eslint --config config/eslint/config.mjs --ext .cjs --ext .js --ext .mjs --report-unused-disable-directives config/","lint:src":"tslint --config config/tslint/src.json --project src/tsconfig.json src/*.ts src/**/*.ts","lint:test":"eslint --config config/eslint/test.mjs --ext .js --report-unused-disable-directives test/","prepare":"husky","prepublishOnly":"npm run build","test":"npm run lint && npm run build && npm run test:unit","test:unit":"if [ \"$TYPE\" = \"\" -o \"$TYPE\" = \"unit\" ]; then npx vitest --config config/vitest/unit.ts; fi"},"types":"build/es2019/module.d.ts","version":"8.0.18","gitHead":"1bcadfb7002224aab6e18a080db36ee3258fe817","_id":"worker-timers-broker@8.0.18","_nodeVersion":"22.23.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-FrjzDVX1wKfZN0gRbCFqv8VHuTncG4sbI/WGEg4tSSQeIsnwqg4YBYWMAHYLJtUDEYYmiK65UKFrVMVk2irDSg==","shasum":"271ec8380f34f6167b53d7954f70aa2934d448ed","tarball":"http://registry-npm.ywwl.com/worker-timers-broker/download/worker-timers-broker-8.0.18.tgz","fileCount":55,"unpackedSize":35444,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDwga55M8X07jmsX50cbTaw/c3NeAVnpFx8U8Cv6oErpAIhAOFwfhIRsjzP366tg3zoM/CR+yc52+Q0mx9ImK6q6CIs"}],"size":8716,"noattachment":false,"key":"/worker-timers-broker/-/worker-timers-broker-8.0.18.tgz"},"_npmUser":{"name":"chrisguttandin","email":"chrisguttandin@media-codings.com"},"directories":{},"maintainers":[{"name":"chrisguttandin","email":"chrisguttandin@media-codings.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/worker-timers-broker_8.0.18_1782169619797_0.1876133185845923"},"_hasShrinkwrap":false,"readme":"# worker-timers-broker\n\n**The broker which is used by the worker-timers package.**\n\n[![version](https://img.shields.io/npm/v/worker-timers-broker.svg?style=flat-square)](https://www.npmjs.com/package/worker-timers-broker)\n\n## Usage\n\nIn most cases using this package via [`worker-timers`](https://github.com/chrisguttandin/worker-timers) is probably the most convenient choice.\n\nHowever `worker-timers-broker` is published as a separate package on npm. It can be installed using the following command:\n\n```shell\nnpm install worker-timers-broker\n```\n\nThe package exports two functions.\n\n### load()\n\nThe `load()` function can be used to create a custom instance of `worker-timers` by explicitly specifying the URL which points to the code of the [`worker-timers-worker`](https://github.com/chrisguttandin/worker-timers-worker) package.\n\n```js\nimport { load } from 'worker-timers-broker';\n\nconst { clearInterval, clearTimeout, setInterval, setTimeout } = load('./the/worker-timers-worker/file');\n\nconst intervalId = setInterval(() => {\n    // do something many times\n}, 100);\n\nclearInterval(intervalId);\n\nconst timeoutId = setTimeout(() => {\n    // do something once\n}, 100);\n\nclearTimeout(timeoutId);\n```\n\n### wrap()\n\nThe `wrap()` function can be used to wrap a Web Worker instance which already runs the code of the [`worker-timers-worker`](https://github.com/chrisguttandin/worker-timers-worker) package.\n\nIn a project using [Vite](https://vite.dev) it can for example be used by leveraging [query suffixes](https://vite.dev/guide/features.html#import-with-query-suffixes).\n\n```js\nimport { wrap } from 'worker-timers-broker';\nimport createWorkerTimersWorker from 'worker-timers-worker?worker';\n\nconst { clearInterval, clearTimeout, setInterval, setTimeout } = wrap(createWorkerTimersWorker());\n\nconst intervalId = setInterval(() => {\n    // do something many times\n}, 100);\n\nclearInterval(intervalId);\n\nconst timeoutId = setTimeout(() => {\n    // do something once\n}, 100);\n\nclearTimeout(timeoutId);\n```\n\nPlease note the syntax for other build tools may vary.\n\n## Security contact information\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.\n","publish_time":1782169619962,"_cnpm_publish_time":1782169619962,"dist-tags":{"latest":"8.0.18"}}