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.
atomic-emitter
Advanced tools
An atomic event emitter that can only emit one type of event, optionally with private write access.
Similar to Raynos' geval, with the following changes:
atomic-emitter
has an interface similar to geval's SingleEvent. You can pass it around, add listeners and emit events.
var Emitter = require("atomic-emitter")
var clicksEmitter = Emitter()
var removeListener = clicksEmitter(function(ev, time) {
console.log('click happened', ev)
})
document.addEventListener("click", function (ev) {
clicksEmitter.emit(ev, +new Date())
})
// ...
removeListener() // and you will stop listening to events
You can also restrict write access to the creator of the emitter, if you want:
var Emitter = require("atomic-emitter")
var clicksEmitter = Emitter(function (emit) {
document.addEventListener("click", function (ev) {
emit(ev)
})
})
var removeListener = clicksEmitter(function listener(ev) {
console.log('click happened', ev)
})
clicksEmitter.emit({test: true}) // Will throw an exception
// ...
removeListener() // and you will stop listening to events
The purpose of this is that you no longer have an EventEmitter-inherited object with obscure events, but a normal everyday-object with some of its properties populated with atomic emitters as values -- events are real values now. For example:
var stream = {
ondata: Emitter()
, onclose: Emitter()
}
Create an atomic emitter with an emit function passed to the creating code.
Create an atomic emitter with a public emit function.
Add an event listener.
Emit the event.
(c) 2015 by Marcel Klehr
MIT License
FAQs
An atomic event emitter that can only emit one type of event, optionally with private write access.
The npm package atomic-emitter receives a total of 1 weekly downloads. As such, atomic-emitter popularity was classified as not popular.
We found that atomic-emitter 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.