Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

capnp-ts

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capnp-ts

Strongly typed Cap'n Proto implementation for the browser and Node.js using TypeScript

  • 0.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
630K
increased by0.35%
Maintainers
1
Weekly downloads
 
Created

What is capnp-ts?

The capnp-ts package is a TypeScript implementation of the Cap'n Proto serialization protocol. It allows for efficient serialization and deserialization of data, making it useful for applications that require high-performance data interchange.

What are capnp-ts's main functionalities?

Serialization

This feature allows you to serialize data into a Cap'n Proto message. The code sample demonstrates how to create a new message, initialize a structure, set a field, and serialize the message into an ArrayBuffer.

const capnp = require('capnp-ts');
const MyStruct = capnp.import('path/to/my-struct.capnp');

const message = new capnp.Message();
const myStruct = message.initRoot(MyStruct);
myStruct.setField('value');

const serializedData = message.toArrayBuffer();

Deserialization

This feature allows you to deserialize data from a Cap'n Proto message. The code sample demonstrates how to create a message from an ArrayBuffer, get the root structure, and retrieve a field value.

const capnp = require('capnp-ts');
const MyStruct = capnp.import('path/to/my-struct.capnp');

const serializedData = /* some ArrayBuffer */;
const message = new capnp.Message(serializedData);
const myStruct = message.getRoot(MyStruct);

const value = myStruct.getField();

Schema Definition

This feature allows you to define schemas using Cap'n Proto's schema language. The code sample shows how to import a schema defined in a .capnp file.

const capnp = require('capnp-ts');
const MyStruct = capnp.import('path/to/my-struct.capnp');

// Define a schema in a .capnp file
// struct MyStruct {
//   field @0 :Text;
// }

Other packages similar to capnp-ts

Keywords

FAQs

Package last updated on 18 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc