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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@goodtools/protobuf-decoder

v1.0.0

Published

Read raw protobuf buffers and return a readable representation of the data

Downloads

11

Readme

protobuf-decoder

Read raw protobuf buffers and return a readable representation of the data

The protobuf encoding format can be found here.

Usage

import { decode, simplify } from "@goodtools/protobuf-decoder";

const buf = Buffer.from([
  0x08, 0x8f, 0x81, 0xeb, 0xcf, 0xe0, 0x2a, 0x12, 0x08, 0x6b, 0x6f, 0x74, 0x6c,
  0x69, 0x6e, 0x34, 0x36, 0x3a, 0x05, 0x00, 0x01, 0x03, 0x04, 0x07, 0x42, 0x00,
  0x48, 0xfa, 0x01, 0x55, 0x00, 0x00, 0x48, 0x43, 0x72, 0x0a, 0x0a, 0x08, 0x50,
  0x4f, 0x4b, 0x45, 0x43, 0x4f, 0x49, 0x4e, 0x72, 0x0c, 0x0a, 0x08, 0x53, 0x54,
  0x41, 0x52, 0x44, 0x55, 0x53, 0x54, 0x10, 0x64,
]);

const decoded = decode(buf);
const simplified = simplify(decoded);
const serialized = JSON.stringify(val);
console.log(serialized)

Simplified Representation

A simplified result would only contain the first possible value of a field given its type.

00000000  08 8f 81 eb cf e0 2a 12  08 6b 6f 74 6c 69 6e 34  |......*..kotlin4|
00000010  36 3a 05 00 01 03 04 07  42 00 48 fa 01 55 00 00  |6:......B.H..U..|
00000020  48 43 72 0a 0a 08 50 4f  4b 45 43 4f 49 4e 72 0c  |HCr...POKECOINr.|
00000030  0a 08 53 54 41 52 44 55  53 54 10 64              |..STARDUST.d|
0000003c
{
  "fields": [
    {
      "field": 1,
      "object": false,
      "type": "varint",
      "value": "1469046243471"
    },
    {
      "field": 2,
      "object": false,
      "type": "len",
      "value": "kotlin46"
    },
    {
      "field": 7,
      "object": false,
      "type": "len",
      "value": "\u0000\u0001\u0003\u0004\u0007"
    },
    {
      "field": 8,
      "object": true,
      "type": "len",
      "value": {
        "fields": [
          
        ]
      }
    },
    {
      "field": 9,
      "object": false,
      "type": "varint",
      "value": "250"
    },
    {
      "field": 10,
      "object": false,
      "type": "i32",
      "value": "1128792064"
    },
    {
      "field": 14,
      "object": true,
      "type": "len",
      "value": {
        "fields": [
          {
            "field": 1,
            "object": false,
            "type": "len",
            "value": "POKECOIN"
          }
        ]
      }
    },
    {
      "field": 14,
      "object": true,
      "type": "len",
      "value": {
        "fields": [
          {
            "field": 1,
            "object": false,
            "type": "len",
            "value": "STARDUST"
          },
          {
            "field": 2,
            "object": false,
            "type": "varint",
            "value": "100"
          }
        ]
      }
    }
  ]
}