Socket
Socket
Sign inDemoInstall

acg-flatbuffers

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acg-flatbuffers

An implementation of FlatBuffers in pure JavaScript


Version published
Maintainers
2
Created
Source

Forked by Aaron C Gaudette on 13 Jan. 2017. See here. This is an updated version of the original.

FlatBuffers in JavaScript

This is an implementation of FlatBuffers in pure JavaScript. Unlike the official compiler, this implementation generates JavaScript code to convert between JavaScript objects and FlatBuffers at run time using the JIT. It currently requires binary schemas compiled with the flatc compiler, which is written in C++ and has to be built (see the build instructions).

Example Usage

  1. Create a schema called example.fbs:

    table Example {
      x: float;
      y: float;
    }
    
    root_type Example;
    
  2. Generate the binary schema called example.bfbs:

    flatc --binary --schema example.fbs
    
  3. Install this library:

    npm install acg-flatbuffers
    
  4. Use the library:

    var flatbuffers = require('acg-flatbuffers');
    var fs = require('fs');
    
    var example = flatbuffers.compileSchema(fs.readFileSync('example.bfbs'));
    var generated = example.generate({ x: 1, y: 2 });
    var parsed = example.parse(generated);
    
    console.log('generated:', Array.from(generated));
    console.log('parsed:', parsed);
    

Running that code should print this:

generated: [ 12, 0, 0, 0, 8, 0, 12, 0, 8, 0, 4, 0, 8, 0, 0, 0, 0, 0, 0, 64, 0, 0, 128, 63 ]
parsed: { x: 1, y: 2 }

FAQs

Package last updated on 24 Jan 2018

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