Skip to content

MetaMask/object-multiplex

Repository files navigation

@metamask/object-multiplex

Simple stream multiplexing for objectMode.

Usage

// 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);

Contributing

Setup

  • Install Node.js version 18
    • If you are using nvm (recommended) running nvm use will automatically choose the right node version for you.
  • Install Yarn v1
  • Run yarn setup to install dependencies and run any requried post-install scripts
    • Warning: Do not use the 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.

Testing and Linting

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.

Release & Publishing

The project follows the same release process as the other libraries in the MetaMask organization:

  1. Create a release branch
    • For a typical release, this would be based on main
    • To update an older maintained major version, base the release branch on the major version branch (e.g. 1.x)
  2. Update the changelog
  3. Update version in package.json file (e.g. yarn version --minor --no-git-tag-version)
  4. Create a pull request targeting the base branch (e.g. master or 1.x)
  5. Code review and QA
  6. Once approved, the PR is squashed & merged
  7. The commit on the base branch is tagged
  8. The tag can be published as needed