npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clacks-message-formatter

v0.1.0

Published

Message formatting and validation plugin for the clacks-p2p ecosystem

Readme

What is clacks-message-formatter?

This is a plugin for the clacks p2p messaging system.

Its simple purpose is to allow custom message formats to be defined, allowing clacks peers to validate and reject messages that do not conform.

Basic Usage

Prerequisites

This plugin requires clacks

Installing

> npm install clacks-message-formatter

Loading

Clacks plugins are loaded into an instance with the "extend" function, as demonstrated below (assuming you have created a clacksInstance already):

MessageFormatter = require('clacks-message-formatter')
clacksInstance.extend(new MessageFormatter({<options>}))

Options

When instantiating the message formatter, you can provide some basic options if you wish

  • optional - An array of optional field names (empty by default)
  • required - An array of required fields (empty by default)
  • rejectInvalid - A boolean that determines whether invalid messages are rejected with an error (true by default). If set to false, the invalid message will still be processed.
  • errorStatus - A HTTP status code to be issues on error (500 by default)

In addition to the optional and required fields, there is a core required field called "class" that all applications must define. The "class" may be useful to identify which application or family a message belongs to.

So, for example, if we're creating an imaginary file sharing application called 'file spreader' that splits files into chunks, you'd require a count of the pieces it was originally broken up into, you most likely want hashes of each chunk, as well as a hash of the full file, and of course the actual chunk data itself. Optionally, the creator may wish to share some tagline and maybe an address they can be reached on. To achieve this, we'd define the formatter / validator thusly:

new MessageFormatter({
	class: 'file-spreader',
	required: ['piecesCount', 'chunkHashes', 'finalHash', 'chunkData'],
	optional: ['createdBy', 'homeAddress']
});

Test Example

You can view a test example in the clacks-tests repository.

Contributing

If this project interests you, all contributions are welcome, from pull requests to suggestions and bug reports.

For clacks-logger specific issues, please use this issue tracker if you spot any problems, have general questions, ideas or feedback.

For core clacks-p2p issues, please use the main issue tracker instead.