Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@foundit/broadcasterjs
Advanced tools
A simple yet powerful pub/sub pattern javascript event bus
easy to use
framework agnostic
minimal footprint
optimised for SPA applications
unintrusive as a dependency
no own dependencies
Here you can report issues or contribute
No need to initialize separately. Import the 'broadcast' factory function and use to your hearts content.
npm install @foundit/broadcasterjs
import { broadcast } from '@foundit/broadcasterjs'
useEffect(() => {
return broadcast.on(['MYBROADCAST-ID', myFlagEmittedCallbackFunction])
}, [myFlagEmittedCallbackFunction])
broadcast.on()
returns a unsubscribe function which comes in handy when you want to cleanup on component unmount. If your listener handler function does not depend on the React component it is instanciated, in you can of course omit the return
to make it persist.
.on
- start a subscription.
const off() = broadcast.on([
'MYBROADCAST-ID',
({ detail }) => {
document.body.append(detail + ' ')
},
])
.once
- start a subscription but cancel subscription after first emission.
const off() = broadcast.once([
'MYBROADCAST-ID',
({ detail }) => {
document.body.append(detail + ' ')
},
])
Call the return function to cancel a subscription.
off() // Use the subscribers return function.
Publish (emit) an event with a string payload.
broadcast.emit('MYBROADCAST-ID', 'Hello world')
Add ?debug=broadcasterjs
to your url and open your devtools console. Normally it shold be enough with inspecting comment node as described above.
The broadcaster functions on
,once
takes an optional third value and emit
takes an optional third argument in the form of a settings object.
{
debug: boolean (false)
debugGlobal: boolean (false)
allowDoublettesSubscribers: boolean (false)
useLatestSubscriberScope?: boolean (false) // <- internal use
suppresDebug?: boolean (false) // <- internal use
}
v 1.1.2 The common js version was not previously updated and did not return the unsubscribe function. It would then still behave as pre v1.1.0. v 1.1.1 v 1.1.0 The subscribe functions 'on' and 'once' now return a unsubscribe function (no arguments) that is much more user friendly than the previous off function. 'off' is still available but removed from the documentation.
Develop: yarn start
Compile typescript: tsc
Build out esm/cjs dist: npm run build
Publish to npm: npm publish --access=public
FAQs
A simple yet powerful pub/sub pattern javascript event bus
The npm package @foundit/broadcasterjs receives a total of 106 weekly downloads. As such, @foundit/broadcasterjs popularity was classified as not popular.
We found that @foundit/broadcasterjs 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.