
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
node-workman-worker
Advanced tools
Worker library for node-workman.
Written in TypeScript and the definitions (.d.ts
-files) are published in NPM
with the rest of the files.
Add the library with yarn
yarn add node-workman-worker
Or with NPM
npm install node-workman-worker
Then import the library in your code
import {worker} from "node-workman-worker"
Create your task handlers
interface Calculation {
a: number
b: number
}
async function work(data: Calculation): Promise<any> {
return data.a + data.b
}
async function waitAndWork(data: Calculation): Promise<any> {
return new Promise<any>(function(resolve: {(result: any): void}) {
setTimeout(function() {
resolve(data.a + data.b)
}, 1000)
})
}
And register them before running the core worker logic.
worker.registerTask("work", work)
worker.registerTask("wait", waitAndWork)
worker.run({
server: "ws://localhost:9999/worker"
})
That's it. Nothing more required. Simple, right?
You can check the full example src/test-worker.ts
Pull requests and issues are open for any good ideas, but please keep in mind that this is supposed to stay fairly simple. If in doubt, open an issue to ask if your proposed idea would be accepted.
To run the typescript compiler and the test worker (src/test-worker.ts
) just
run:
yarn dev
MIT. Need a more open license? Just ask.
FAQs
Worker library for node-workman
The npm package node-workman-worker receives a total of 1 weekly downloads. As such, node-workman-worker popularity was classified as not popular.
We found that node-workman-worker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.