Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A simple interface between Workers.
npm install --save battalion
To expose an interface from a Worker:
// src/worker-module.js
import Battalion from 'battalion'
Battalion.export(self, {
addTwo ({ first, second }) {
return first + second
}
})
Then, to create / access that worker from the main thread:
// src/index.js
import Battalion from 'battalion'
import MyWorker from './worker-module' // import worker with webpack / worker-loader
let battalion = new Battalion(MyWorker)
let workerInstance = battalion.createInstance()
workerInstance.dispatch('addTwo', { first: 1, second: 2 }).then((result) => {
console.log(result) // => 3
})
Options object:
Promise
: the Promise implementation to use (defaults to Promise
)Task
: the Task implementation to use (uses Promises by default)MyWorker
: Worker class.
Exposes methods from a worker file.
context
: The worker context (should be self
)
methods
: Object containing methods that will be called by dispatch
.
Returns a WorkerInstance
.
count
: Number of workers to use.
Returns a PoolInstance
.
Assign a worker instance a job.
type
: Name of exported function to run.
data
: Object that will be passed to the function.
Returns a Promise (or Task) of the eventual result.
Same as above, but will be distributed among available workers.
callback
: Function, will be called when a job is complete.
Receives an object containing two properties: completed
(total number of completed jobs) and pending
(jobs in job queue).
Resets the completed
jobs count and empties the existing job queue.
FAQs
Web worker management utilities
The npm package battalion receives a total of 0 weekly downloads. As such, battalion popularity was classified as not popular.
We found that battalion 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.