Skip to content

Commit e6eaa91

Browse files
committed
Added a couple of alternative signatures, protobuf.load returns promise or undefined, aliased Reader/Writer-as-function signature with Reader/Writer.create for typed dialects, see #518
1 parent 060a791 commit e6eaa91

File tree

15 files changed

+104
-67
lines changed

15 files changed

+104
-67
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.vscode/
12
*.log
23
npm-debug.*
34
node_modules/

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "./node_modules/typescript/lib"
3+
}

dist/protobuf.js

Lines changed: 32 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

12 Bytes
Binary file not shown.

dist/protobuf.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var protobuf = global.protobuf = exports;
44
/**
55
* Loads one or multiple .proto or preprocessed .json files into a common root namespace.
66
* @param {string|string[]} filename One or multiple files to load
7-
* @param {Root} [root] Root namespace, defaults to create a new one if omitted.
7+
* @param {Root|function(?Error, Root=)} [root] Root namespace, defaults to create a new one if omitted.
88
* @param {function(?Error, Root=)} [callback] Callback function
9-
* @returns {Promise<Root>|Object} A promise if callback has been omitted, otherwise the protobuf namespace
9+
* @returns {Promise<Root>|undefined} A promise if `callback` has been omitted
1010
* @throws {TypeError} If arguments are invalid
1111
*/
1212
function load(filename, root, callback) {
@@ -15,7 +15,7 @@ function load(filename, root, callback) {
1515
root = new protobuf.Root();
1616
} else if (!root)
1717
root = new protobuf.Root();
18-
return root.load(filename, callback) || protobuf;
18+
return root.load(filename, callback);
1919
}
2020

2121
protobuf.load = load;

src/method.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var _TypeError = util._TypeError;
1919
* @param {string|undefined} type Method type, usually `"rpc"`
2020
* @param {string} requestType Request message type
2121
* @param {string} responseType Response message type
22-
* @param {boolean} [requestStream] Whether the request is streamed
23-
* @param {boolean} [responseStream] Whether the response is streamed
22+
* @param {boolean|Object} [requestStream] Whether the request is streamed
23+
* @param {boolean|Object} [responseStream] Whether the response is streamed
2424
* @param {Object} [options] Declared options
2525
*/
2626
function Method(name, type, requestType, responseType, requestStream, responseStream, options) {

src/oneof.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var _TypeError = util._TypeError;
1616
* @extends ReflectionObject
1717
* @constructor
1818
* @param {string} name Oneof name
19-
* @param {string[]} [fieldNames] Field names
19+
* @param {string[]|Object} [fieldNames] Field names
2020
* @param {Object} [options] Declared options
2121
*/
2222
function OneOf(name, fieldNames, options) {

0 commit comments

Comments
 (0)