Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
publisher-subscriber-pattern
Advanced tools
Publisher subscriber pattern that can be used with different event emitters including browser window
npm i publisher-subscriber-pattern
The example uses the browser's window object as emitterInstance. Other valid emitter instances can be also used.
import { Publisher } from 'publisher-subscriber-pattern';
const publisher = new Publisher(window, 'addEventListener','removeEventListener');
Publisher's subscribe method returns function, which can be used later to unsubscribe from the publisher's event.
const unsubscribe = publisher.subscribe('scroll', (event) => {});
// ...foo code...
unsubscribe();
There is also a method unsubscribeAll for unsubscribing all subscribers from all emitter's events.
publisher.unsubscribeAll();
Required parameters: eventName, eventCallback
Optional parameter: subscriberInstance, which will be bound to the eventCallback argument as this (see Function.prototype.bind)
Method subscribes eventCallback to eventName, so whenever event occurs the eventCallback is called
Returns function for unsubscribing from the event
FAQs
Publisher subscriber pattern that can be used with different event emitters including browser window
The npm package publisher-subscriber-pattern receives a total of 3 weekly downloads. As such, publisher-subscriber-pattern popularity was classified as not popular.
We found that publisher-subscriber-pattern 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 found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.