Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / node_modules / @grpc / proto-loader / README.md
1 # gRPC Protobuf Loader
2
3 A utility package for loading `.proto` files for use with gRPC, using the latest Protobuf.js package.
4 Please refer to [protobuf.js' documentation](https://github.com/dcodeIO/protobuf.js/blob/master/README.md)
5 to understands its features and limitations.
6
7 ## Installation
8
9 ```sh
10 npm install @grpc/proto-loader
11 ```
12
13 ## Usage
14
15 ```js
16 const protoLoader = require('@grpc/proto-loader');
17 const grpcLibrary = require('grpc');
18 // OR
19 const grpcLibrary = require('@grpc/grpc-js');
20
21 protoLoader.load(protoFileName, options).then(packageDefinition => {
22   const packageObject = grpcLibrary.loadPackageDefinition(packageDefinition);
23 });
24 // OR
25 const packageDefinition = protoLoader.loadSync(protoFileName, options);
26 const packageObject = grpcLibrary.loadPackageDefinition(packageDefinition);
27 ```
28
29 The options parameter is an object that can have the following optional properties:
30
31 | Field name | Valid values | Description
32 |------------|--------------|------------
33 | `keepCase` | `true` or `false` | Preserve field names. The default is to change them to camel case.
34 | `longs` | `String` or `Number` | The type to use to represent `long` values. Defaults to a `Long` object type.
35 | `enums` | `String` | The type to use to represent `enum` values. Defaults to the numeric value.
36 | `bytes` | `Array` or `String` | The type to use to represent `bytes` values. Defaults to `Buffer`.
37 | `defaults` | `true` or `false` | Set default values on output objects. Defaults to `false`.
38 | `arrays` | `true` or `false` | Set empty arrays for missing array values even if `defaults` is `false` Defaults to `false`.
39 | `objects` | `true` or `false` | Set empty objects for missing object values even if `defaults` is `false` Defaults to `false`.
40 | `oneofs` | `true` or `false` | Set virtual oneof properties to the present field's name. Defaults to `false`.
41 | `includeDirs` | An array of strings | A list of search paths for imported `.proto` files.
42
43 The following options object closely approximates the existing behavior of `grpc.load`:
44
45 ```js
46 const options = {
47   keepCase: true,
48   longs: String,
49   enums: String,
50   defaults: true,
51   oneofs: true
52 }
53 ```