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

bhttp-js

v0.3.6

Published

A BHTTP (Binary Representation of HTTP Messages) Encoder and Decoder

Readme

Documentation

Index

Supported Environments

bhttp-js can be used in all JavaScript runtimes which support Request/Response interface of Fetch API:

  • Deno: 1.x
  • Node.js: 18.x, 19.x, 20.x, 21.x, 22.x
  • Bun: 0.x, 1.x
  • Cloudflare Workers
  • @fastly/js-compute
  • Web browsers: Chrome, Edge, Firefox, Safari and so on.

Installation

Deno

Starting from version 0.3.4, bhttp-js is available from the JSR registry. From this version onwards, please use JSR import instead of HTTPS import in Deno.

JSR imoprt (recommended on >=0.3.4):

Add bhttp-js package using the commands below:

deno add @dajiaji/bhttp

Then, you can use the module from code like this:

import { BHttpDecoder, BHttpEncoder } from "@dajiaji/bhttp";

Node.js

Using npm, yarn or pnpm:

npm install bhttp-js
yarn add bhttp-js
pnpm install bhttp-js

Using jsr:

npx jsr add @dajiaji/bhttp
yarn dlx jsr add @dajiaji/bhttp
pnpm dlx jsr add @dajiaji/bhttp

Cloudflare Workers

Using jsr:

npx jsr add @dajiaji/bhttp
yarn dlx jsr add @dajiaji/bhttp
pnpm dlx jsr add @dajiaji/bhttp

Bun

Using jsr:

bunx jsr add @dajiaji/bhttp

Web Browser

Followings are how to use with typical CDNs. Other CDNs can be used as well.

Using esm.sh:

<!-- use a specific version -->
<script type="module">
  import { BHttpDecoder, BhttpEncoder } from "https://esm.sh/bhttp-js@<SEMVER>";
  // ...
</script>

<!-- use the latest stable version -->
<script type="module">
  import { BHttpDecoder, BhttpEncoder } from "https://esm.sh/bhttp-js";
  // ...
</script>

Using unpkg:

<!-- use a specific version -->
<script type="module">
  import {
    BHttpDecoder,
    BhttpEncoder,
  } from "https://unpkg.com/bhttp-js@<SEMVER>/esm/mod.js";
  // ...
</script>

Usage

This section shows some typical usage examples.

Deno

See samples/deno.

import { BHttpDecoder, BHttpEncoder } from "@dajiaji/bhttp";

const req = new Request("https://www.example.com/hello.txt", {
  method: "GET",
  headers: {
    "User-Agent": "curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3",
    "Accept-Language": "en, mi",
  },
});

// Encode a Request object to a BHTTP binary string.
const encoder = new BHttpEncoder();
const binReq = await encoder.encodeRequest(req);

// Decode the BHTTP binary string to a Request object.
const decoder = new BHttpDecoder();
const decodedReq = decoder.decodeRequest(binReq);

Node.js

See samples/node.

Bun

See samples/bun.

Cloudflare Workers

See samples/cloudflare.

Web Browser

BHTTP client on Web Browser:

<html>
  <head></head>
  <body>
    <script type="module">
      import { BHttpDecoder, BHttpEncoder } from "https://esm.sh/bhttp-js@<SEMVER>";

      globalThis.doBHttp = async () => {
        try {
          const encoder = new BHttpEncoder();
          const req = new Request("https://target.example/query?foo=bar");
          const bReq = await encoder.encodeRequest(req);
          const res = await fetch("https://bin.example/to_target", {
            method: "POST",
            headers: {
              "Content-Type": "message/bhttp",
            },
            body: bReq,
          });

          const decoder = new BHttpDecoder();
          const decodedRes = decoder.decodeResponse(await res.arrayBuffer());
          // decodedRes.status === 200;
          const body = await decodedRes.text();
          // body === "baz"
        } catch (err) {
          alert(err.message);
        }
      };
    </script>
    <button type="button" onclick="doBHttp()">do BHTTP</button>
  </body>
</html>

Contributing

We welcome all kind of contributions, filing issues, suggesting new features or sending PRs.

References