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

thriftrw

Package Overview
Dependencies
Maintainers
9
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thriftrw

thrift encoding/decoding using bufrw

  • 3.11.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
417K
decreased by-12.13%
Maintainers
9
Weekly downloads
 
Created

What is thriftrw?

The thriftrw npm package is a Thrift IDL (Interface Definition Language) compiler and runtime for JavaScript. It allows you to define data types and service interfaces in Thrift IDL and then generate JavaScript code to serialize, deserialize, and handle these types and services.

What are thriftrw's main functionalities?

Serialization and Deserialization

This feature allows you to serialize and deserialize Thrift objects. The code sample demonstrates how to define a Thrift struct, create an instance of it, serialize it to a buffer, and then deserialize it back to an object.

const Thrift = require('thriftrw').Thrift;
const thrift = new Thrift({source: 'struct User { 1: string name, 2: i32 age }'});
const User = thrift.User;

const user = new User({name: 'Alice', age: 30});
const buffer = User.toBuffer(user);
const deserializedUser = User.fromBuffer(buffer);
console.log(deserializedUser);

Service Interface

This feature allows you to define and implement Thrift service interfaces. The code sample demonstrates how to define a Thrift service, implement it, and call a method on the service.

const Thrift = require('thriftrw').Thrift;
const thrift = new Thrift({source: 'service UserService { User getUser(1: i32 id) } struct User { 1: string name, 2: i32 age }'});
const UserService = thrift.UserService;

const userService = new UserService({
  getUser: function (id, callback) {
    callback(null, new thrift.User({name: 'Alice', age: 30}));
  }
});

userService.getUser(1, (err, user) => {
  if (err) throw err;
  console.log(user);
});

Other packages similar to thriftrw

FAQs

Package last updated on 17 Jun 2023

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