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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rtf-dm/protocol

v0.6.6

Published

package for creating packet level protocol description

Downloads

21

Readme

Installation

nmp i @rtf-dm/protocol

Simple and small package to describe packets

Usage:

import { Packet, encode, decode, Schema } from '@rtf-dm/protocol';

//1. Describe your packet payload type:

type TestPacketPayload = {
  ID: string;
  numberField1b: number;
  numberField2b: number;
  numberField4b: number;
  numberField2bBE: number;
  numberField4bBE: number;
  arrayField1b: number[];
  arrayField2bLe: number[];
  arrayField2bBe: number[];
  filler: number;
  filler2: number;
  arrayField4bLe: number[];
  arrayField4bBe: number[];
};

/*2. Describe encoding schema:
 *    Note that order of schema fields make sense!
 *    It means if 'ID' field first in array and have a length 5
 *    first five bytes in packet will have value of 'ID' payload;
 * */

const schema = new Schema<TestPacketPayload>([
  ['ID', { size: 1, length: 5, type: 'string', encoding: 'ascii' }],
  ['numberField1b', { size: 1, type: 'number' }],
  ['numberField2b', { size: 2, type: 'number', byteOrder: 'LE' }],
  ['numberField4b', { size: 4, type: 'number', byteOrder: 'LE' }],
  ['numberField2bBE', { size: 2, type: 'number', byteOrder: 'BE' }],
  ['numberField4bBE', { size: 4, type: 'number', byteOrder: 'BE' }],
  ['arrayField1b', { length: 4, type: 'array', size: 1 }],
  ['arrayField2bLe', { length: 4, type: 'array', size: 2, byteOrder: 'LE' }],
  ['arrayField2bBe', { length: 4, type: 'array', size: 2, byteOrder: 'BE' }],
  ['filler', { size: 1, type: 'number' }],
  ['filler2', { size: 1, type: 'number' }],
  ['arrayField4bBe', { length: 4, type: 'array', size: 4, byteOrder: 'BE' }],
  ['arrayField4bLe', { length: 4, type: 'array', size: 4, byteOrder: 'LE' }],
]);

//3. Create a new class that extends Packet class:
class TestPacket extends Packet<TestPacketPayload> {
  constructor(payload: TestPacketPayload) {
    super(payload, schema);
  }
}

const packet = new TestPacket({
  ID: 'TEST',
  numberField1b: 1,
  numberField2b: 1024,
  numberField4b: 123456,
  numberField2bBE: 0xffdd,
  numberField4bBE: 0xaabbccdd,
  arrayField1b: [0xfa, 0xfa, 0xfa, 0xfa],
  arrayField2bLe: [0xfffe, 0xfffe, 0xfffe, 0xfffe],
  arrayField2bBe: [0xfffe, 0xfffe, 0xfffe, 0xfffe],
  filler: 129, // align to
  filler2: 138,
  arrayField4bLe: [0xfafbfcfd, 0xfafbfcfd, 0xfafbfcfd, 0xfafbfcfd],
  arrayField4bBe: [0xfafbfcfd, 0xfafbfcfd, 0xfafbfcfd, 0xfafbfcfd],
});

const buf = packet.encode();
const decoded = packet.decode(buf);

VER 0.6.3

  • Update readme

VER 0.6.1

  • Rename schema "length" field for non array type to "size" for consistency
  • Types improvements

VER 0.5.12

  • Fixed types.
  • Added support for array encoding
  • Added support for strings encoding ('utf8' and 'ascii' was tested other encodings not planned to be tested)
  • Test coverage: 100% at that moment