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

mcb1-2

v2.0.0

Published

MCB1/2.0 协议 - 二进制TLV格式,使用动词/资源/结果码/元数据,无Web协议关联

Readme

MCB1/2.0 二进制协议库

作者:xinghanxu

MCB1/2.0 是一个基于 TCP/TLS 的二进制 TLV 格式通信协议,使用 动词 (Verb)资源 (Resource)结果码 (Outcome)元数据 (Meta)负载 (Payload) 等概念,完全不与常见Web协议术语重合,没有任何Web协议特征。

特性

  • 纯二进制 TLV,无明文字符串
  • 动词 + 资源 + 元数据 + 负载
  • 结果码 + 附言 + 元数据 + 负载
  • 内置鉴权(通过元数据)
  • 支持 TCP 和 TLS
  • 简单易用的客户端/服务端

安装

npm install mcb1-2

快速开始

服务端

const { MCB1Server } = require('mcb1-2');

const server = new MCB1Server({ port: 3443 });

// 可选鉴权
server.useAuth(async (req) => {
  const token = req.meta['mcb1-token'];
  return token === 'my-secret';
});

server.onRequest(async (req, respond) => {
  if (req.verb === 'CHECK' && req.resource === '/health') {
    respond(0, '', {}, 'alive');
  } else {
    respond(1, '未找到资源');
  }
});

await server.start();

客户端

const { MCB1Client } = require('mcb1-2');

const client = new MCB1Client({ host: 'localhost', port: 3443 });
client.setAuth('token', 'my-secret');

const resp = await client.send('CHECK', '/health');
console.log(resp.payload.toString());  // "alive"
client.close();

API 参考

MCB1Client

  • constructor(options)
  • setAuth(type, credentials)'token', 'basic', 'custom'
  • send(verb, resource, meta, payload) – 返回 Promise<Response>
  • close()

MCB1Server

  • constructor(options)
  • useAuth(asyncFn) – 鉴权中间件
  • onRequest(handler) – 处理器接收 (req, respond)
  • start() / stop()

req 对象:{ verb, resource, meta, payload }
respond(outcome, info, meta, payload)

结果码约定:0=成功, 1=未找到, 2=格式错误, 3=动词不允许, 4=内部错误, 5=未授权

协议格式

TLV 块列表,以 FIN 结束:

  • VERB (0x01): 动词字符串
  • RESOURCE (0x02): 资源标识符
  • OUTCOME (0x03): 2 字节结果码
  • INFO (0x04): 附言字符串
  • META (0x10): 键值对,格式 key\x00value\x00
  • PAYLOAD (0x20): 数据体
  • FIN (0x7F): 结束

许可证

MIT