| FlatBuffers An open source project by FPL.

- Programmer's Guide
- Platform / Language / Feature support
- Benchmarks
- FlatBuffers white paper
- FlatBuffers internals
- Grammar of the schema language
- API Reference
- Contributing

Variables
Flatbuffers_javascript_api

## Detailed Description

## Variables
flatbuffers Builder prototype | addFloat32
| Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary). More...
flatbuffers Builder prototype | addFloat64
| Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary). More...
flatbuffers Builder prototype | addInt16
| Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary). More...
flatbuffers Builder prototype | addInt32
| Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary). More...
flatbuffers Builder prototype | addInt64
| Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary). More...
flatbuffers Builder prototype | addInt8
| Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary). More...
flatbuffers Builder prototype | addOffset
| Adds on offset, relative to where it will be written. More...
flatbuffers Builder prototype | asUint8Array
| Get the bytes representing the FlatBuffer. More...
flatbuffers | Builder
| Create a FlatBufferBuilder. More...
flatbuffers Builder prototype | createLong
| A helper function to avoid generated code depending on this file directly. More...
flatbuffers Builder prototype | createString
| Encode the string `s` in the buffer using UTF-8. More...
flatbuffers Builder prototype | dataBuffer
| Get the ByteBuffer representing the FlatBuffer. More...
flatbuffers Builder prototype | finish
| Finalize a buffer, poiting to the given `root_table`. More...
flatbuffers Builder prototype | forceDefaults
| In order to save space, fields that are set to their default value don't get serialized into the buffer. More...

## Variable Documentation

flatbuffers Builder prototype addFloat32

Initial value:
= function(value) {
this.prep(4, 0);
this.writeFloat32(value);
}

Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  {number} | value The `float32` to add the the buffer.

flatbuffers Builder prototype addFloat64

Initial value:
= function(value) {
this.prep(8, 0);
this.writeFloat64(value);
}

Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  {number} | value The `float64` to add the the buffer.

flatbuffers Builder prototype addInt16

Initial value:
= function(value) {
this.prep(2, 0);
this.writeInt16(value);
}

Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  {number} | value The `int16` to add the the buffer.

flatbuffers Builder prototype addInt32

Initial value:
= function(value) {
this.prep(4, 0);
this.writeInt32(value);
}

Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  {number} | value The `int32` to add the the buffer.

flatbuffers Builder prototype addInt64

Initial value:
= function(value) {
this.prep(8, 0);
this.writeInt64(value);
}

Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  {flatbuffers.Long} | value The `int64` to add the the buffer.

flatbuffers Builder prototype addInt8

Initial value:
= function(value) {
this.prep(1, 0);
this.writeInt8(value);
}

Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  {number} | value The `int8` to add the the buffer.

flatbuffers Builder prototype addOffset

Initial value:
= function(offset) {
this.prep(flatbuffers.SIZEOF_INT, 0);
this.writeInt32(this.offset() - offset + flatbuffers.SIZEOF_INT);
}
flatbuffers
Definition: flatbuffers.h:22

Adds on offset, relative to where it will be written.

Parameters

  {flatbuffers.Offset} | offset The offset to add.

flatbuffers Builder prototype asUint8Array

Initial value:
= function() {
return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
}

Get the bytes representing the FlatBuffer.

Only call this after you've called finish().

Returns
  {Uint8Array}

flatbuffers Builder

Create a FlatBufferBuilder.

Parameters

  {number=} | opt_initial_size

flatbuffers Builder prototype createLong

Initial value:
= function(low, high) {
return flatbuffers.Long.create(low, high);
}
flatbuffers
Definition: flatbuffers.h:22

A helper function to avoid generated code depending on this file directly.

Parameters

  {number} | low
  {number} | high

Returns
  {flatbuffers.Long}

flatbuffers Builder prototype createString

Encode the string `s` in the buffer using UTF-8.

If a Uint8Array is passed instead of a string, it is assumed to contain valid UTF-8 encoded data.

Parameters

  {string|Uint8Array} | s The string to encode

Returns
  {flatbuffers.Offset} The offset in the buffer where the encoded string starts

flatbuffers Builder prototype dataBuffer

Initial value:
= function() {
return this.bb;
}

Get the ByteBuffer representing the FlatBuffer.

Only call this after you've called finish(). The actual data starts at the ByteBuffer's current position, not necessarily at 0.

Returns
  {flatbuffers.ByteBuffer}

flatbuffers Builder prototype finish

Initial value:
= function(root_table, opt_file_identifier) {
if (opt_file_identifier) {
var file_identifier = opt_file_identifier;
this.prep(this.minalign, flatbuffers.SIZEOF_INT +
flatbuffers.FILE_IDENTIFIER_LENGTH);
if (file_identifier.length != flatbuffers.FILE_IDENTIFIER_LENGTH) {
throw new Error('FlatBuffers: file identifier must be length ' +
flatbuffers.FILE_IDENTIFIER_LENGTH);
}
for (var i = flatbuffers.FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) {
this.writeInt8(file_identifier.charCodeAt(i));
}
}
this.prep(this.minalign, flatbuffers.SIZEOF_INT);
this.addOffset(root_table);
this.bb.setPosition(this.space);
}
addOffset
flatbuffers Builder prototype addOffset
Adds on offset, relative to where it will be written.
Definition: flatbuffers.js:568
flatbuffers
Definition: flatbuffers.h:22

Finalize a buffer, poiting to the given `root_table`.

Parameters

  {flatbuffers.Offset} | root_table
  {string=} | opt_file_identifier

flatbuffers Builder prototype forceDefaults

Initial value:
= function(forceDefaults) {
this.force_defaults = forceDefaults;
}
forceDefaults
flatbuffers Builder prototype forceDefaults
In order to save space, fields that are set to their default value don't get serialized into the buff...
Definition: flatbuffers.js:236

In order to save space, fields that are set to their default value don't get serialized into the buffer.

Forcing defaults provides a way to manually disable this optimization.

Parameters

  {boolean} | forceDefaults true always serializes default values