Installations
npm install flatbuffers-addon
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=8.10.0
Node Version
12.18.0
NPM Version
6.14.4
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (74.5%)
C++ (21.53%)
Python (3.97%)
Developer
smbape
Download Statistics
Total Downloads
16,481
Last Day
1
Last Week
13
Last Month
41
Last Year
2,345
GitHub Statistics
3 Stars
41 Commits
2 Watching
11 Branches
1 Contributors
Bundle Size
4.97 kB
Minified
2.05 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.4
Package Id
flatbuffers-addon@1.0.4
Unpacked Size
1.31 MB
Size
540.32 kB
File Count
14
NPM Version
6.14.4
Node Version
12.18.0
Total Downloads
Cumulative downloads
Total Downloads
16,481
Last day
0%
1
Compared to previous day
Last week
333.3%
13
Compared to previous week
Last month
1,266.7%
41
Compared to previous month
Last year
-77%
2,345
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
flatbuffers-addon
Generate flatbuffers directly from node.
Generate binary
1const flatc = require("flatbuffers-addon"); 2const buffer = flatc.binary(options);
options.schema
type: String|Buffer
if schema
is a String and schema_contents
is null
or undefined
, schema
will be treated as schema_contents
.
otherwise, it will be treated as the schema file path.
options.schema_contents
type: String|Buffer
The schema contents.
If the schema_contents
is a schema binary, the schema
file path must end with .bfbs
.
options.schema_binary
type: bool
default: false
Serialize schemas instead of JSON
options.json
type: String|Buffer|Object
if json
is a String and json_contents
is null
or undefined
, json
will be treated as json_contents
.
if json
is a Buffer or an Object, json
will be treated as json_contents
.
otherwise json
must be a String and will be treated as the path to the JSON.
options.json_contents
type: String|Buffer|Object
The JSON to serialize
options.include_directories
type: [String]
Include directories for schemas
options.conform
type: String|Buffer
Specify a schema the following schema
should be an evolution of.
if conform
is a String and conform_contents
is null
or undefined
, conform
will be treated as conform_contents
.
options.conform_contents
type: String|Buffer
Conform schema contents.
options.conform_include_directories
type: [String]
Include directories for conform schemas
options.strict_json
NOT TESTED
type: bool
default: false
field names must be / will be quoted, no trailing commas in tables/vectors.
options.ignore_null_scalar
type: bool
default: false
Allow scalar fields to be null
options.allow_non_utf8
NOT TESTED
type: bool
default: false
Pass non-UTF-8 input through parser
options.skip_unexpected_fields_in_json
type: bool
default: false
Allow fields in JSON that are not defined in the schema. These fields will be discared when generating binaries.
options.size_prefixed
NOT TESTED
type: bool
default: false
Input binaries are size prefixed buffers.
options.proto_mode
NOT TESTED
type: bool
default: false
Input is a .proto, translate to .fbs.
options.proto_oneof_union
NOT TESTED
type: bool
default: false
Translate .proto oneofs to flatbuffer unions.
options.binary_schema_comments
NOT TESTED
type: bool
default: false
Add doc comments to the binary schema files.
options.binary_schema_builtins
NOT TESTED
type: bool
default: false
Add builtin attributes to the binary schema files.
options.force_defaults
type: bool
default: false
If false, don't serialize values equal to the default, therefore reducing size of the binary output.
Generate js
1const flatc = require("flatbuffers-addon"); 2const code = flatc.js(options);
options.schema
type: String|Buffer
if schema
is a String and schema_contents
is null
or undefined
, schema
will be treated as schema_contents
.
otherwise, it will be treated as the schema file path.
options.schema_contents
type: String|Buffer
The schema contents.
If the schema_contents
is a schema binary, the schema
file path must end with .bfbs
.
options.include_directories
type: [String]
Include directories for schemas
options.conform
type: String|Buffer
Specify a schema the following schema
should be an evolution of.
if conform
is a String and conform_contents
is null
or undefined
, conform
will be treated as conform_contents
.
options.conform_contents
type: String|Buffer
Conform schema contents.
options.conform_include_directories
type: [String]
Include directories for conform schemas
options.type
NOT TESTED
type: String
ts
to generate TypeScript code.
options.allow_non_utf8
NOT TESTED
type: bool
default: false
Pass non-UTF-8 input through parser
options.mutable_buffer
type: bool
default: false
Generate accessors that can mutate buffers in-place.
options.generate_all
NOT TESTED
type: bool
default: false
Generate not just code for the current schema files, but for all files it includes as well. If the language uses a single file for output (by default the case for C++ and JS), all code will end up in this one file.
options.skip_js_exports
type: bool
default: false
Removes Node.js style export lines in JS.
options.use_goog_js_export_format
NOT TESTED
type: bool
default: false
Uses goog.exports* for closure compiler exporting in JS.
options.use_ES6_js_export_format
NOT TESTED
type: bool
default: false
Uses ECMAScript 6 export style lines in JS.
options.keep_include_path
NOT TESTED
type: bool
default: false
Keep original prefix of schema include statement.
options.skip_flatbuffers_import
NOT TESTED
type: bool
default: false
Don't include flatbuffers import statement for TypeScript.
options.reexport_ts_modules
NOT TESTED
type: bool
default: true
re-export imported dependencies for TypeScript
options.js_ts_short_names
NOT TESTED
type: bool
default: true
Use short function names for JS and TypeScript.
Examples
1const { flatbuffers } = require("flatbuffers"); 2const flatc = require("flatbuffers-addon"); 3 4const schema = ` 5 namespace some.nested.namespace; 6 7 file_extension "dat"; 8 9 table Book { 10 id:string (id: 0); 11 title:string (id: 1); 12 authors:[string] (id: 2); 13 release:ulong (id: 3); 14 genres: [ulong] (id: 4); 15 } 16 17 table Library { 18 name:string (id: 0); 19 books: [Book] (id: 1); 20 } 21 22 root_type Library; 23`; 24 25const js = flatc.js({ 26 schema 27}); 28 29const library = { 30 name: "BookShop 0", 31 books: [{ 32 id: "book-0", 33 title: "Book 0", 34 authors: ["Author 0"] 35 }] 36}; 37 38 39const buffer = flatc.binary({ 40 schema, 41 json: library 42}); 43 44const deserialized = ((code, binary) => { 45 // Evalute generated js code 46 const sandbox = {}; 47 (new Function(code)).call(sandbox); 48 49 // @see https://google.github.io/flatbuffers/flatbuffers_guide_use_javascript.html 50 const bytes = new Uint8Array(binary); 51 const buf = new flatbuffers.ByteBuffer(bytes); 52 53 // Deserialized flatbuffers binary data 54 const Library = sandbox.some.nested.namespace.Library; 55 return Library.getRootAsLibrary(buf); 56 57})(js, buffer); 58 59console.log(deserialized.name() === "BookShop 0"); 60console.log(deserialized.books(0).title() === "Book 0"); 61
No vulnerabilities found.
Reason
binaries present in source code
Details
- Warn: binary detected: prebuilds/linux-x64/node.napi.node:1
- Warn: binary detected: prebuilds/win32-x64/node.napi.node:1
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
26 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
1
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More