
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
mtk-worker-pool
Advanced tools
从maptalks中抽离的单独使用的web worker pool模块。 maptalks worker pool源码
pnpm add mtk-worker-pool
import { registerWorkerAdapter, worker } from 'mtk-worker-pool'
/**
* 发送到worker的数据结构
*/
interface ISendToWorkerMsg {
url: string
}
/**
*从worker中返回的数据结构
*/
interface IWorkerPostResponseMsg {
data: string
}
interface WorkerExportsFuncParam<T, K extends IWorkerPostResponseMsg> {
initialize: (self: any) => void
onmessage: (
msg: {
data: T
callback: string
workerId: number
workerKey: string
actorId: number
},
postResponse: (err: any, data: K, buffers: ArrayBuffer[]) => void
) => void
}
/**
* 注入到worker中的函数类型
*/
type WorkerExportsFunc = (exports: WorkerExportsFuncParam<ISendToWorkerMsg, IWorkerPostResponseMsg>) => void
const fun1: WorkerExportsFunc = (exports) => {
exports.initialize = (self) => {
console.log('worker init')
}
const canvas = new OffscreenCanvas(1, 1)
const TILESIZE = 256
exports.onmessage = (msg, postResponse) => {
console.log(msg)
const data = 'worker msg'
postResponse(null, { data }, [])
}
}
const workerKey = 'workertest'
/**
* 注册worker
*/
registerWorkerAdapter(workerKey, fun1)
/**
* 初始化actor
*/
const actor = new worker.Actor(workerKey)
const url = 'xxx'
// 消息通信数据格式
// 主线程到worker actor.send(data, buffers, callback, worker.id);
// worker到主线程 postResponse(err, data, buffers);
console.log(actor)
/**
* 发送数据到worker
*/
actor.send({ url }, [], (error: any, message: IWorkerPostResponseMsg) => {
// 从worker中返回的数据
console.log(message)
})
FAQs
从maptalks中提取web worker线程池实现代码
We found that mtk-worker-pool 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.