Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@metamask/object-multiplex
Advanced tools
@metamask/object-multiplex is a utility for creating and managing multiple independent streams of data over a single connection. It is particularly useful in scenarios where you need to multiplex several communication channels over a single transport layer, such as in browser extensions or inter-process communication.
Creating a Multiplex Stream
This feature allows you to create a new multiplex stream instance. This instance can be used to manage multiple independent streams over a single connection.
const ObjectMultiplex = require('@metamask/object-multiplex');
const stream = new ObjectMultiplex();
Creating Substreams
This feature allows you to create substreams within the main multiplex stream. Each substream can be used independently to send and receive data.
const ObjectMultiplex = require('@metamask/object-multiplex');
const stream = new ObjectMultiplex();
const substream1 = stream.createStream('substream1');
const substream2 = stream.createStream('substream2');
Sending Data Over Substreams
This feature allows you to send data over a specific substream. The data sent over one substream is isolated from other substreams.
const ObjectMultiplex = require('@metamask/object-multiplex');
const stream = new ObjectMultiplex();
const substream = stream.createStream('substream');
substream.write('Hello, World!');
Receiving Data From Substreams
This feature allows you to receive data from a specific substream. You can set up event listeners to handle incoming data on each substream.
const ObjectMultiplex = require('@metamask/object-multiplex');
const stream = new ObjectMultiplex();
const substream = stream.createStream('substream');
substream.on('data', (data) => {
console.log('Received data:', data);
});
The 'multiplex' package provides similar functionality for creating multiple independent streams over a single connection. It is a more general-purpose library compared to @metamask/object-multiplex, which is tailored for use in browser extensions.
The 'mux-demux' package allows for multiplexing and demultiplexing of streams. It is a lightweight alternative to @metamask/object-multiplex and is suitable for simpler use cases where advanced features are not required.
Simple stream multiplexing for objectMode
.
// create multiplexer
const mux = new ObjMultiplex();
// setup substreams
const streamA = mux.createStream("hello");
const streamB = mux.createStream("world");
// pipe over transport (and back)
mux.pipe(transport).pipe(mux);
// send values over the substreams
streamA.write({ thisIsAn: "object" });
streamA.write(123);
// or pipe together normally
streamB.pipe(evilAiBrain).pipe(streamB);
nvm use
will automatically choose the right node version for you.yarn setup
to install dependencies and run any requried post-install scripts
yarn
/ yarn install
command directly. Use yarn setup
instead. The normal install command will skip required post-install scripts, leaving your development environment in an invalid state.Run yarn test
to run the tests once.
Run yarn lint
to run the linter, or run yarn lint:fix
to run the linter and fix any automatically fixable issues.
The project follows the same release process as the other libraries in the MetaMask organization:
main
1.x
)yarn version --minor --no-git-tag-version
)FAQs
Simple stream multiplexing for objectMode.
We found that @metamask/object-multiplex demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.