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

capnp-es

v0.0.4

Published

TypeScript implementation of the Cap'n Proto serialization.

Downloads

43

Readme

🔥 capnp-es

npm version npm downloads bundle size codecov

[!WARNING] This is an alpha-quality software. please use at your own risk (project status).

TypeScript implementation of the Cap'n Proto serialization protocol.

Cap’n Proto is an insanely fast data interchange format and capability-based RPC system. Think JSON, except binary. Or think Protocol Buffers, except faster. Cap’n Proto was built by Kenton Varda to be used in Sandstorm and is now heavily used in Cloudflare.

Usage

Compiling schema

Make sure capnpc command is available. You can find install instructions here to install it.

Run the following to compile a schema file into typeScript/javascript source code:

npx capnp-es path/to/myschema.capnp -ojs,ts,dts

This will generate path/to/myschema.{js,ts,dts}.

Use npx capnp-es --help for full usage info.

See playground for examples and learn more about .capnp schema in language docs.

Reading Messages

Here's a quick usage example:

import * as capnp from "capnp-es";
import { MyStruct } from "./myschema.js";

const message = capnp.Message.fromArrayBuffer(buffer);
const struct = message.getRoot(MyStruct);

RPC Protocol

Experimental RPC protocol is supported (level 1).

See tests for some examples.

Status

This project is a rework of jdiaz5513/capnp-ts by Julián Díaz and is under development.

  • Internal refactors and simplifications as was playing around.
  • Compiler, runtime, and std lib published via a single and compact ESM-only package with subpath exports.
  • Compiler updated to use Typescript v5 API
  • Output files can be .ts (new), .js (ESM instead of CJS), and .d.ts and has no .capnp suffix.
  • Compiler API can be used via the capnp-es/compiler subpath export programmatically.
  • Use native TextEncoder and TextDecoder for utf8 encoding
  • Enums are typed plain JS objects (this way .ts files work with strip-only ts loaders without enum support.)
  • Compiler CLI can directly accept a path to .capnp files and internally use capnpc
  • Built-in schemas are compiled from source (compiler, compiles itself. so cool right?)
  • Use reflection (getter setters) to access structs.
  • RPC level-1 merged from jdiaz5513/capnp-ts#169.
  • List interface implements Array object (custom methods removed).
  • Pointers had been improved to feel (inspected and serialized) like native JS values as much as possible.
  • Basic JSDocs generated for class and getter

Contribution

Feedback and PRs are more than welcome. 🙏

  • Clone this repository
  • Install the latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

🔀 Forked from jdiaz5513/capnp-ts by Julián Díaz.

💛 Published under the MIT license.