Socket
Socket
Sign inDemoInstall

protobufjs-cli

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protobufjs-cli

Translates between file formats and generates static code as well as TypeScript definitions.


Version published
Weekly downloads
1.2M
decreased by-1.52%
Maintainers
2
Weekly downloads
 
Created

What is protobufjs-cli?

The protobufjs-cli package is a command-line interface for Protobuf.js, which provides a collection of tools to compile, inspect, and manage .proto files and their corresponding JavaScript code. It allows users to generate static code, JSON descriptors, and TypeScript definitions from .proto files, as well as to encode and decode messages using the Protocol Buffers binary format.

What are protobufjs-cli's main functionalities?

Compile .proto files to static JavaScript

This command compiles a .proto file into a static JavaScript module that can be used with CommonJS module systems. The output is written to 'compiled.js'.

pbjs -t static-module -w commonjs -o compiled.js file.proto

Generate JSON descriptors from .proto files

This command generates a JSON descriptor from a .proto file. The JSON output, which describes the message types and services, is written to 'descriptors.json'.

pbjs -t json -o descriptors.json file.proto

Generate TypeScript definitions from .proto files

This command generates TypeScript definitions from a compiled JavaScript file (generated by pbjs). The TypeScript definitions are written to 'types.d.ts'.

pbts -o types.d.ts compiled.js

Encode a message to the Protocol Buffers binary format

This command first compiles the .proto file to a static module and then encodes a message of type 'MessageName' with the provided field values to the Protocol Buffers binary format.

pbjs -t static-module file.proto | pbjs -p file.proto -e MessageName '{"field": "value"}'

Decode a message from the Protocol Buffers binary format

This command first compiles the .proto file to a static module and then decodes a message of type 'MessageName' from the Protocol Buffers binary format.

pbjs -t static-module file.proto | pbjs -p file.proto -d MessageName < encoded-message.bin

Other packages similar to protobufjs-cli

FAQs

Package last updated on 21 Aug 2024

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