Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
broadcast-channel
Advanced tools
A BroadcastChannel that works in New Browsers, Old Browsers, WebWorkers and NodeJs
The broadcast-channel npm package allows different browser tabs, iframes, web workers, and node.js processes to communicate with each other. It uses various methods like IndexedDB, local storage, or native events to create a channel that can be used to broadcast messages across different contexts running on the same machine.
Creating a Broadcast Channel
This code sample demonstrates how to import the BroadcastChannel class from the package and create a new channel named 'my-channel'.
const { BroadcastChannel } = require('broadcast-channel');
const channel = new BroadcastChannel('my-channel');
Sending a Message
This code sample shows how to send a message ('Hello World') through the channel to other listening contexts.
channel.postMessage('Hello World');
Receiving Messages
This code sample sets up an event listener to receive messages sent to the channel and logs them to the console.
channel.onmessage = (message) => console.log('Received:', message);
Closing a Channel
This code sample demonstrates how to close the channel when it is no longer needed to free up resources.
channel.close();
PubSubJS is a topic-based publish/subscribe library that's similar to broadcast-channel but does not support communication between different browser tabs or node processes.
While primarily a local storage library, localForage can be used to store and retrieve messages across sessions, which can be a form of communication similar to broadcast-channel, but it's not designed specifically for message broadcasting.
A BroadcastChannel that works in old browsers, new browsers, WebWorkers and NodeJs
+ LeaderElection over the channels
A BroadcastChannel that allows you to send data between different browser-tabs or nodejs-processes.
npm install --save broadcast-channel
const BroadcastChannel = require('broadcast-channel');
const channel = new BroadcastChannel('foobar');
channel.postMessage('I am not alone');
const BroadcastChannel = require('broadcast-channel');
const channel = new BroadcastChannel('foobar');
channel.onmessage = msg => console.dir(msg);
// > 'I am not alone'
FAQs
A BroadcastChannel that works in New Browsers, Old Browsers, WebWorkers, NodeJs, Deno and iframes
The npm package broadcast-channel receives a total of 1,158,790 weekly downloads. As such, broadcast-channel popularity was classified as popular.
We found that broadcast-channel demonstrated a healthy version release cadence and project activity because the last version was released less than 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.