
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
msg-pubsub is a simple events dispatcher publish / subscribe library (just 0.9kb). aysnc, simple and usefull.
msg-pubsub 是一个很简单的消息分发的Javascript库(仅仅
0.9kb),简洁实用。
可以用于:
1. pub(msg_name, data1, data2, ...)
异步方式发布名字为 msg_name 的消息,并且赋予系列变量datas为callback方法的输入值。
2. pubSync(msg_name, data1, data2, ...)
同步的方式发布名字为 msg_name 的消息,并且赋予系列变量datas为callback方法的输入值。阻塞。
3. sub(msg_name, callback, context)
订阅消息,参数为 msg_name 和 callback, 当有名字为msg_name的消息发布的时候,callback方法将会被执行。
这个方法会返回一个msgObj,这个可以用于使用un(msgObj)方法来取消消息订阅。
4. subone(msg_name, callback, context)
订阅消息,参数为 msg_name with callback. 当被触发一次之后失效。只能被触发一次,一次之后自动失效。
5. unsub(msgObj / msg_name)
取消消息订阅。可以仅仅取消订阅一个消息回调方法,也可以直接取消全部的消息。
6. clear()
清空所有消息。
1. 引入js文件
npm install msg-pubsub
可以使用 <script> 标签直接引入; 也可以使用 require 或者 import 关键字引入,会得到全局变量 ps。
import ps from 'msg-pubsub';
// or
var ps = require("msg-pubsub");
2. 简单使用
使用 pub 方法来发布消息, 使用方法 sub 来订阅消息, 使用 unsub 来取消订阅。
import ps from 'msg-pubsub';
function test_callback(data1, data2) {
console.log('this is msg 1');
}
// 发布消息
ps.pub('test_msg', 'test_data1', 'test_data2');
// 订阅消息
var msgObj = ps.sub('test_msg', test_callback);
var msgObj2 = ps.sub('test_msg', function(data1, data2) {
console.log('this is msg 2');
});
// 取消订阅
ps.unsub(msgObj); // 取消订阅这个消息.
ps.unsub('test_msg'); // 取消订阅所有的 `test_msg`.
ps.unsub(test_callback); // 取消订阅所有的 `test_callback` 方法.
MIT
FAQs
msg-pubsub is a simple events dispatcher publish / subscribe library (just 0.9kb). aysnc, simple and usefull.
The npm package msg-pubsub receives a total of 1 weekly downloads. As such, msg-pubsub popularity was classified as not popular.
We found that msg-pubsub 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
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.