Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / node_modules / protobufjs / README.md
1 protobuf.js 5 [![Build Status](https://travis-ci.org/dcodeIO/protobuf.js.svg?branch=ProtoBuf5)](https://travis-ci.org/dcodeIO/protobuf.js) [![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=%3C3%20protobuf.js)\r
2 =====================================\r
3 **Protocol Buffers** are a language-neutral, platform-neutral, extensible way of serializing structured data for use\r
4 in communications protocols, data storage, and more, originally designed at Google ([see](https://developers.google.com/protocol-buffers/docs/overview)).\r
5 \r
6 **protobuf.js** is a pure JavaScript implementation on top of [bytebuffer.js](https://github.com/dcodeIO/bytebuffer.js)\r
7 including a .proto parser, message class building and simple encoding and decoding. There is no compilation step\r
8 required, it's super easy to use and it works out of the box on .proto files!\r
9 \r
10 Getting started\r
11 ---------------\r
12 * **Step 1:** Become familar with [Google's Protocol Buffers (protobuf)](https://developers.google.com/protocol-buffers/docs/overview)\r
13 * **Step 2:** Read on or head straight to [our wiki](https://github.com/dcodeIO/protobuf.js/wiki) for additional information\r
14 * **Step 3:** Build something cool! :-)\r
15 \r
16 Features\r
17 --------\r
18 * [RequireJS](http://requirejs.org/)/AMD compatible\r
19 * [node.js](http://nodejs.org)/CommonJS compatible, also available via [npm](https://npmjs.org/package/protobufjs)\r
20 * Browser compatible\r
21 * [Closure Compiler](https://developers.google.com/closure/compiler/) compatible (fully annotated, [externs](https://github.com/dcodeIO/protobuf.js/tree/master/externs))\r
22 * Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)\r
23 * Well tested through [test.js](https://github.com/dcodeIO/test.js)\r
24 * [bytebuffer.js](https://github.com/dcodeIO/bytebuffer.js) is the only production dependency\r
25 * Fully compatible to the official implementation including advanced features\r
26 * proto2js command line utility\r
27 \r
28 Installation\r
29 ------------\r
30 \r
31 ### node.js / CommonJS\r
32 \r
33 ```\r
34 $> npm install protobufjs\r
35 ```\r
36 \r
37 ```js\r
38 var ProtoBuf = require("protobufjs");\r
39 ...\r
40 ```\r
41 \r
42 ### RequireJS / AMD\r
43 \r
44 Requires [bytebuffer.js](http://github.com/dcodeIO/bytebuffer.js). Optionally depends on [long.js](https://github.com/dcodeIO/long.js) for long (int64) support. If you do not require long support, you can skip the Long.js config. RequireJS example:\r
45 \r
46 ```js\r
47 require(["protobuf"], function(ProtoBuf) {\r
48     ...\r
49 });\r
50 ```\r
51 \r
52 Or as a module dependency:\r
53 \r
54 ```js\r
55 define("MyModule", ["protobuf"], function(ProtoBuf) {\r
56     ...\r
57 });\r
58 ```\r
59 \r
60 ### Browser\r
61 \r
62 Requires [bytebuffer.js](http://github.com/dcodeIO/bytebuffer.js). Optionally depends on [long.js](https://github.com/dcodeIO/long.js) for long (int64) support. If you do not require long support, you can skip the Long.js include.\r
63 \r
64 ```html\r
65 <!-- Order is important -->\r
66 <script src="long.min.js"></script>\r
67 <script src="bytebuffer.min.js"></script>\r
68 <script src="protobuf.min.js"></script>\r
69 ```\r
70 \r
71 ```js\r
72 var ProtoBuf = dcodeIO.ProtoBuf;\r
73 ...\r
74 ```\r
75 \r
76 Getting started\r
77 ---------------\r
78 \r
79 *Note:* You'll need the full build to load .proto data. light builds are able to load JSON only.\r
80 \r
81 ### Loading .proto files\r
82 \r
83 To load a .proto file, use:\r
84 \r
85 **API:** `ProtoBuf.loadProtoFile(source[, callback[, builder]]):Builder|undefined`\r
86 \r
87 ```js\r
88 // Synchronously\r
89 var builder = ProtoBuf.loadProtoFile("path/to/file.proto");\r
90 \r
91 // Asynchronously\r
92 ProtoBuf.loadProtoFile("path/to/file.proto", function(err, builder) {\r
93     ...\r
94 });\r
95 ```\r
96 \r
97 `ProtoBuf.loadProtoFile` also accepts an object specifying the import root directory and the file to load as its first parameter: `{root: string, file: string}`. Additionally, an already created and then reused builder can be specified as the last argument, which is useful if all the definitions shall reside in a single namespace.\r
98 \r
99 ### Loading .proto strings\r
100 \r
101 **API:** `ProtoBuf.loadProto(source[, builder][, filename]):Builder`\r
102 \r
103 ```js\r
104 var builder = ProtoBuf.loadProto(...protoString..., "myproto.proto");\r
105 ```\r
106 \r
107 ### Loading JSON files and strings\r
108 \r
109 To load the (raw) JSON counterpart generated through pbjs, use `ProtoBuf.loadJsonFile` respectively `ProtoBuf.loadJson`. It's the same API.\r
110 \r
111 If you generated classes or modules with it, loading is done just by including respectively requiring the resulting file. Loading is handled transparently in this case.\r
112 \r
113 When using JSON only, you can use protobuf-light.js or protobuf-light.min.js instead, which do NOT include the ProtoBuf.DotProto package for parsing and are therefore smaller.\r
114 \r
115 Command line\r
116 ------------\r
117 Since ProtoBuf.js 4.0.0 the library ships with the `pbjs` command line utility. With it it's possible to convert between .proto and JSON descriptors and even to generate the code required to access runtime structures as pure JS (classes), an AMD module or a CommonJS module.\r
118 \r
119 ```\r
120 \r
121  _ |_ . _\r
122 |_)|_)|_)           ProtoBuf.js v4.0.0-b3 https://github.com/dcodeIO/ProtoBuf.js\r
123 |     '\r
124 \r
125 CLI utility to convert between .proto and JSON syntax / to generate classes.\r
126 \r
127 Usage: pbjs <filename> [options] [> outFile]\r
128 \r
129 Options:\r
130   --help, -h        Show help  [boolean]\r
131   --version, -v     Show version number  [boolean]\r
132   --source, -s      Specifies the source format. Valid formats are:\r
133 \r
134                        json       Plain JSON descriptor\r
135                        proto      Plain .proto descriptor\r
136 \r
137   --target, -t      Specifies the target format. Valid formats are:\r
138 \r
139                        amd        Runtime structures as AMD module\r
140                        commonjs   Runtime structures as CommonJS module\r
141                        js         Runtime structures\r
142                        json       Plain JSON descriptor\r
143                        proto      Plain .proto descriptor\r
144 \r
145   --using, -u       Specifies an option to apply to the volatile builder\r
146                     loading the source, e.g. convertFieldsToCamelCase.\r
147   --min, -m         Minifies the output.  [default: false]\r
148   --path, -p        Adds a directory to the include path.\r
149   --legacy, -l      Includes legacy descriptors from google/protobuf/ if\r
150                     explicitly referenced.  [default: false]\r
151   --quiet, -q       Suppresses any informatory output to stderr.  [default: false]\r
152   --use, -i         Specifies an option to apply to the emitted builder\r
153                     utilized by your program, e.g. populateAccessors.\r
154   --exports, -e     Specifies the namespace to export. Defaults to export\r
155                     the root namespace.\r
156   --dependency, -d  Library dependency to use when generating classes.\r
157                     Defaults to 'protobufjs' for CommonJS, 'ProtoBuf' for\r
158                     AMD modules and 'dcodeIO.ProtoBuf' for classes.\r
159 ```\r
160 \r
161 Documentation\r
162 -------------\r
163 * [Read the official protobuf guide](https://developers.google.com/protocol-buffers/docs/overview)\r
164 * [Read the API docs](http://htmlpreview.github.io/?https://raw.githubusercontent.com/dcodeIO/protobuf.js/ProtoBuf5/docs/ProtoBuf.html)\r
165 * [Check out the examples](https://github.com/dcodeIO/protobuf.js/tree/ProtoBuf5/examples)\r
166 \r
167 Tests\r
168 -----\r
169 * [View source](https://github.com/dcodeIO/protobuf.js/blob/ProtoBuf5/tests/suite.js)\r
170 \r
171 Downloads\r
172 ---------\r
173 * [Distributions](https://github.com/dcodeIO/protobuf.js/tree/ProtoBuf5/dist)\r
174 * [ZIP-Archive](https://github.com/dcodeIO/protobuf.js/archive/ProtoBuf5.zip)\r
175 * [Tarball](https://github.com/dcodeIO/protobuf.js/tarball/ProtoBuf5)\r
176 \r
177 CDN usage\r
178 ---------\r
179 ```html\r
180 <script src="//cdn.rawgit.com/dcodeIO/protobuf.js/5.0.1/dist/protobuf.min.js"></script>\r
181 ```\r
182 With the version pointing to the exact [release](https://github.com/dcodeIO/protobuf.js/releases) your project depends upon.\r
183 \r
184 **License:** [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\r