/flatc-js

Node.js bindings for Google FlatBuffers compiler (https://github.com/google/flatbuffers).

Primary LanguageJavaScriptApache License 2.0Apache-2.0

flatc.js

Node.js bindings for Google FlatBuffers compiler.

Purpose

This module provides a simple wrapper around Google FlatBuffers compiler (flatc) in order to make it usable in Node.js. The required binaries are either downloaded directly (Windows) or built from source (Linux) from the official release.

Requirements

Under Linux, you need to have cmake and g++ (or some other supported compiler) installed.

Installation

npm install --save-dev flatc

Usage

const flatc = require('flatc');

flatc("monster.fbs", {
    language: ["js", "ts"],
    outputDir: "output",
}).then(() => {
    console.log("Done!");
}).catch(console.error);

If you have the glob module installed, you can also use patterns like *.fbs for specifying input files.

Options

The wrapper just passes through boolean properties as flags. For more information see the FlatBuffers documentation.

const default_options = {
    language: "js",
    outputDir: null,
    genMutable: false,
    genObjectApi: false,
    genOnefile: false,
    genAll: false,
    noJsExports: false,
    googJsExport: false,
}