# Namespace: ProtoBuf

## ProtoBuf

The ProtoBuf namespace.

Source:
  - ProtoBuf.js, line 40

### Classes

Builder
Map

### Namespaces

DotProto
Reflect
Util

### Members

#### (static, non-null) ByteBuffer :function

  ##### Type:

  - function
  Source:
    - ProtoBuf.js, line 46

#### (static) convertFieldsToCamelCase :boolean

  If set to `true`, field names will be converted from underscore notation to camel case. Defaults to `false`. Must be set prior to parsing.

  ##### Type:

  - boolean
  Source:
    - ProtoBuf.js, line 274

#### (static, constant) ID_MAX :number

  Maximum field id.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 266

#### (static, constant) ID_MIN :number

  Minimum field id.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 258

#### (static, non-null) Lang :Object.<string, RegExp>

  Language expressions.

  ##### Type:

  - Object.<string, RegExp>
  Source:
    - ProtoBuf.js, line 414

#### (static, nullable) Long :function

  ##### Type:

  - function
  Source:
    - ProtoBuf.js, line 52

#### (static, constant, non-null) MAP_KEY_TYPES :Array.<!Object.<string, {name: string, wireType: number, defaultValue: *}>>

  Valid map key types.

  ##### Type:

  - Array.<!Object.<string, {name: string, wireType: number, defaultValue: *}>>
  Source:
    - ProtoBuf.js, line 236

#### (static, constant, non-null) PACKABLE_WIRE_TYPES :Array.<number>

  Packable wire types.

  ##### Type:

  - Array.<number>
  Source:
    - ProtoBuf.js, line 123

#### (static) populateAccessors :boolean

  By default, messages are populated with (setX, set_x) accessors for each field. This can be disabled by setting this to `false` prior to building messages.

  ##### Type:

  - boolean
  Source:
    - ProtoBuf.js, line 282

#### (static) populateDefaults :boolean

  By default, messages are populated with default values if a field is not present on the wire. To disable this behavior, set this setting to `false`.

  ##### Type:

  - boolean
  Source:
    - ProtoBuf.js, line 290

#### (static, constant, non-null) TYPES :Object.<string, Object>

  Types.

  ##### Type:

  - Object.<string, Object>
  Source:
    - ProtoBuf.js, line 136

#### (static, constant) VERSION :string

  ProtoBuf.js version.

  ##### Type:

  - string
  Source:
    - ProtoBuf.js, line 60

#### (static, constant) WIRE_TYPES :Object.<string, number>

  Wire types.

  ##### Type:

  - Object.<string, number>
  Source:
    - ProtoBuf.js, line 68

#### (static, constant) WIRE_TYPES.BITS32 :number

  Fixed 32 bits wire type.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 115

#### (static, constant) WIRE_TYPES.BITS64 :number

  Fixed 64 bits wire type.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 83

#### (static, constant) WIRE_TYPES.ENDGROUP :number

  End group wire type.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 107

#### (static, constant) WIRE_TYPES.LDELIM :number

  Length delimited wire type.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 91

#### (static, constant) WIRE_TYPES.STARTGROUP :number

  Start group wire type.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 99

#### (static) WIRE_TYPES.VARINT :number

  Varint wire type.

  ##### Type:

  - number
  Source:
    - ProtoBuf.js, line 75

### Methods

#### (static) loadJson(json, builderopt, filenameopt) → {ProtoBuf.Builder}

  Loads a .json definition and returns the Builder.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `json` | * | string |  | JSON definition
  `builder` | ProtoBuf.Builder | string | Object | <optional> | Builder to append to. Will create a new one if omitted.
  `filename` | string | Object | <optional> | The corresponding file name if known. Must be specified for imports.

  Source:
    - ProtoBuf.js, line 5127

  ##### Throws:

  If the definition cannot be parsed or built
  Type
    Error

  ##### Returns:

  Builder to create new messages

  Type
    ProtoBuf.Builder

#### (static) loadJsonFile(filename, callbackopt, builderopt) → {ProtoBuf.Builder|undefined}

  Loads a .json file and returns the Builder.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `filename` | string | Object |  | Path to json file or an object specifying 'file' with an overridden 'root' path for all imported files.
  `callback` | function | <optional> | Callback that will receive `null` as the first and the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the file will be read synchronously and this function will return the Builder.
  `builder` | ProtoBuf.Builder | <optional> | Builder to append to. Will create a new one if omitted.

  Source:
    - ProtoBuf.js, line 5152

  ##### Returns:

  The Builder if synchronous (no callback specified, will be NULL if the request has failed), else undefined

  Type
    ProtoBuf.Builder | undefined

#### (static) loadProto(proto, builderopt, filenameopt) → {ProtoBuf.Builder}

  Loads a .proto string and returns the Builder.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `proto` | string |  | .proto file contents
  `builder` | ProtoBuf.Builder | string | Object | <optional> | Builder to append to. Will create a new one if omitted.
  `filename` | string | Object | <optional> | The corresponding file name if known. Must be specified for imports.

  Source:
    - ProtoBuf.js, line 5034

  ##### Throws:

  If the definition cannot be parsed or built
  Type
    Error

  ##### Returns:

  Builder to create new messages

  Type
    ProtoBuf.Builder

#### (static) loadProtoFile(filename, callbackopt, builderopt) → {ProtoBuf.Builder|undefined}

  Loads a .proto file and returns the Builder.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `filename` | string | Object |  | Path to proto file or an object specifying 'file' with an overridden 'root' path for all imported files.
  `callback` | function | <optional> | Callback that will receive `null` as the first and the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the file will be read synchronously and this function will return the Builder.
  `builder` | ProtoBuf.Builder | <optional> | Builder to append to. Will create a new one if omitted.

  Source:
    - ProtoBuf.js, line 5065

  ##### Returns:

  The Builder if synchronous (no callback specified, will be NULL if the request has failed), else undefined

  Type
    ProtoBuf.Builder | undefined

#### (static) newBuilder(optionsopt) → (non-null) {ProtoBuf.Builder}

  Constructs a new empty Builder.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `options` | Object.<string, *> | <optional> | Builder options, defaults to global options set on ProtoBuf

  Source:
    - ProtoBuf.js, line 5109

  ##### Returns:

  Builder

  Type
    ProtoBuf.Builder

#### (static) protoFromFile(filename, callbackopt, builderopt) → {ProtoBuf.Builder|undefined}

  Loads a .proto file and returns the Builder. This is an alias of ProtoBuf.loadProtoFile.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `filename` | string | Object |  | Path to proto file or an object specifying 'file' with an overridden 'root' path for all imported files.
  `callback` | function | <optional> | Callback that will receive `null` as the first and the Builder as its second argument on success, otherwise the error as its first argument. If omitted, the file will be read synchronously and this function will return the Builder.
  `builder` | ProtoBuf.Builder | <optional> | Builder to append to. Will create a new one if omitted.

  Source:
    - ProtoBuf.js, line 5100

  ##### Returns:

  The Builder if synchronous (no callback specified, will be NULL if the request has failed), else undefined

  Type
    ProtoBuf.Builder | undefined

#### (static) protoFromString(proto, builderopt, filenameopt) → {ProtoBuf.Builder}

  Loads a .proto string and returns the Builder. This is an alias of ProtoBuf.loadProto.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `proto` | string |  | .proto file contents
  `builder` | ProtoBuf.Builder | string | <optional> | Builder to append to. Will create a new one if omitted.
  `filename` | string | Object | <optional> | The corresponding file name if known. Must be specified for imports.

  Source:
    - ProtoBuf.js, line 5051

  ##### Throws:

  If the definition cannot be parsed or built
  Type
    Error

  ##### Returns:

  Builder to create new messages

  Type
    ProtoBuf.Builder