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

@f0rr0/thrift-compact-protocol

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@f0rr0/thrift-compact-protocol

Marshalling/unmarshalling between Facebook Thrift Compact Protocol and Javascript with type definitions.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

thrift-compact-protocol

Marshalling/unmarshalling between Facebook Thrift Compact Protocol and Javascript with type definitions.

Usage

import {
  t,
  ThriftType,
  thriftReadToObject,
  thriftWriteFromObject,
} from '@f0rr0/thrift-compact-protocol'

// Describe the shape of expected Thrift data over the wire
const structDefinition = t.struct({
  foo: t.field(1, t.boolean()),
  bar: t.field(2, t.int64()).optional(),
  baz: t.field(
    4,
    t.list(
      t.struct({
        quz: t.field(1, t.binary()),
      })
    )
  ),
})

// Typescript type is inferred from the Thrift definition
type StructDefinition = t.TypeOf<typeof structDefinition>

// Parse a Thrift buffer to JS object
const javascriptObject = thriftReadToObject(
  someThriftBufferPayload,
  structDefinition
)

// Write JS object to Thrift buffer
const thriftBuffer = thriftWriteFromObject(
  {
    foo: true,
    bar: BigInt(1),
    baz: [
      {
        quz: 'string',
      },
    ],
  },
  structDefinition
)

FAQs

Package last updated on 27 May 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