Permalink
Browse files

Added variations for Root#load, see #527

  • Loading branch information...
dcodeIO committed Dec 7, 2016
1 parent 7c3bf8d commit 9df6a3d4a654c3e122f97d9a594574c7bbb412da

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN +6 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -15,15 +15,15 @@ var Enum = require("../enum"),
/**
* Decodes a message of `this` message's type.
* @param {Reader} reader Reader to decode from
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
* @param {number} [length] Length of the message, if known beforehand
* @returns {Prototype} Populated runtime message
* @this Type
*/
decode.fallback = function decode_fallback(reader, length) {
decode.fallback = function decode_fallback(readerOrBuffer, length) {
/* eslint-disable no-invalid-this, block-scoped-var, no-redeclare */
var fields = this.getFieldsById(),
reader = reader instanceof Reader ? reader : Reader.create(reader),
reader = readerOrBuffer instanceof Reader ? readerOrBuffer : Reader.create(readerOrBuffer),
limit = length === undefined ? reader.len : reader.pos + length,
message = new (this.getCtor())();
while (reader.pos < limit) {
@@ -87,7 +87,7 @@ decode.fallback = function decode_fallback(reader, length) {
/**
* Generates a decoder specific to the specified message type, with an identical signature to {@link codegen.decode.fallback}.
* @param {Type} mtype Message type
* @returns {function(string, ...*):string} {@link codegen} instance
* @returns {CodegenInstance} {@link codegen|Codegen} instance
*/
decode.generate = function decode_generate(mtype) {
/* eslint-disable no-unexpected-multiline */
@@ -95,7 +95,7 @@ encode.fallback = function encode_fallback(message, writer) {
/**
* Generates an encoder specific to the specified message type, with an identical signature to {@link codegen.encode.fallback}.
* @param {Type} mtype Message type
* @returns {function(string, ...*):string} {@link codegen} instance
* @returns {CodegenInstance} {@link codegen|Codegen} instance
*/
encode.generate = function encode_generate(mtype) {
/* eslint-disable no-unexpected-multiline */
@@ -46,7 +46,7 @@ verify.fallback = function verify_fallback(message) {
/**
* Generates a verifier specific to the specified message type, with an identical signature to {@link codegen.verify.fallback}.
* @param {Type} mtype Message type
* @returns {function(string, ...*):string} {@link codegen} instance
* @returns {CodegenInstance} {@link codegen|Codegen} instance
*/
verify.generate = function verify_generate(mtype) {
/* eslint-disable no-unexpected-multiline */
@@ -21,8 +21,8 @@ var _TypeError = util._TypeError;
* @param {string} name Unique name within its namespace
* @param {number} id Unique id within its namespace
* @param {string} type Value type
* @param {string} [rule=optional] Field rule
* @param {string} [extend] Extended type if different from parent
* @param {string|Object} [rule="optional"] Field rule
* @param {string|Object} [extend] Extended type if different from parent
* @param {Object} [options] Declared options
*/
function Field(name, id, type, rule, extend, options) {
@@ -2,7 +2,7 @@
var protobuf = global.protobuf = exports;
/**
* Loads one or multiple .proto or preprocessed .json files into a common root namespace.
* Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
* @param {string|string[]} filename One or multiple files to load
* @param {Root} root Root namespace, defaults to create a new one if omitted.
* @param {function(?Error, Root=)} callback Callback function
@@ -17,9 +17,10 @@ function load(filename, root, callback) {
root = new protobuf.Root();
return root.load(filename, callback);
}
// function load(filename:string, root:Root, callback:function):undefined
/**
* Loads one or multiple .proto or preprocessed .json files into a common root namespace.
* Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
* @name load
* @function
* @param {string|string[]} filename One or multiple files to load
@@ -28,19 +29,19 @@ function load(filename, root, callback) {
* @throws {TypeError} If arguments are invalid
* @variation 2
*/
// function load(filename, callback)
// function load(filename:string, callback:function):undefined
/**
* Loads one or multiple .proto or preprocessed .json files into a common root namespace.
* Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise.
* @name load
* @function
* @param {string|string[]} filename One or multiple files to load
* @param {Root} [root] Root namespace, defaults to create a new one if omitted.
* @returns {Promise<Root>} A promise
* @returns {Promise<Root>} Promise
* @throws {TypeError} If arguments are invalid
* @variation 3
*/
// function load(filename, [root]):Promise
// function load(filename:string, [root:Root]):Promise<Root>
protobuf.load = load;
@@ -55,10 +55,10 @@ Root.fromJSON = function fromJSON(json, root) {
RootPrototype.resolvePath = util.resolvePath;
/**
* Loads one or multiple .proto or preprocessed .json files into this root namespace.
* Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
* @param {string|string[]} filename Names of one or multiple files to load
* @param {function(?Error, Root=)} [callback] Node-style callback function
* @returns {Promise<Root>|undefined} A promise if `callback` has been omitted
* @param {function(?Error, Root=)} callback Node-style callback function
* @returns {undefined}
* @throws {TypeError} If arguments are invalid
*/
RootPrototype.load = function load(filename, callback) {
@@ -155,6 +155,18 @@ RootPrototype.load = function load(filename, callback) {
finish(null);
return undefined;
};
// function load(filename:string, callback:function):undefined
/**
* Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.
* @name Root#load
* @function
* @param {string|string[]} filename Names of one or multiple files to load
* @returns {Promise<Root>} Promise
* @throws {TypeError} If arguments are invalid
* @variation 2
*/
// function load(filename:string):Promise<Root>
/**
* Handles a deferred declaring extension field by creating a sister field to represent it within its extended type.
@@ -3,7 +3,7 @@
/*
* protobuf.js v6.1.0 TypeScript definitions
* Generated Wed, 07 Dec 2016 19:27:57 UTC
* Generated Wed, 07 Dec 2016 21:12:41 UTC
*/
declare module "protobufjs" {
@@ -132,8 +132,8 @@ declare module "protobufjs" {
* @param {string} name Unique name within its namespace
* @param {number} id Unique id within its namespace
* @param {string} type Value type
* @param {string} [rule=optional] Field rule
* @param {string} [extend] Extended type if different from parent
* @param {string|Object} [rule="optional"] Field rule
* @param {string|Object} [extend] Extended type if different from parent
* @param {Object} [options] Declared options
*/
class Field extends ReflectionObject {
@@ -145,11 +145,11 @@ declare module "protobufjs" {
* @param {string} name Unique name within its namespace
* @param {number} id Unique id within its namespace
* @param {string} type Value type
* @param {string} [rule=optional] Field rule
* @param {string} [extend] Extended type if different from parent
* @param {string|Object} [rule="optional"] Field rule
* @param {string|Object} [extend] Extended type if different from parent
* @param {Object} [options] Declared options
*/
constructor(name: string, id: number, type: string, rule?: string, extend?: string, options?: Object);
constructor(name: string, id: number, type: string, rule?: (string|Object), extend?: (string|Object), options?: Object);
/**
* Field rule, if any.
@@ -292,7 +292,7 @@ declare module "protobufjs" {
}
/**
* Loads one or multiple .proto or preprocessed .json files into a common root namespace.
* Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
* @param {string|string[]} filename One or multiple files to load
* @param {Root} root Root namespace, defaults to create a new one if omitted.
* @param {function(?Error, Root=)} callback Callback function
@@ -302,7 +302,7 @@ declare module "protobufjs" {
function load(filename: (string|string[]), root: Root, callback: (() => any)): undefined;
/**
* Loads one or multiple .proto or preprocessed .json files into a common root namespace.
* Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
* @name load
* @function
* @param {string|string[]} filename One or multiple files to load
@@ -314,12 +314,12 @@ declare module "protobufjs" {
function load(filename: (string|string[]), callback: (() => any)): undefined;
/**
* Loads one or multiple .proto or preprocessed .json files into a common root namespace.
* Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise.
* @name load
* @function
* @param {string|string[]} filename One or multiple files to load
* @param {Root} [root] Root namespace, defaults to create a new one if omitted.
* @returns {Promise<Root>} A promise
* @returns {Promise<Root>} Promise
* @throws {TypeError} If arguments are invalid
* @variation 3
*/
@@ -1189,13 +1189,24 @@ declare module "protobufjs" {
resolvePath(origin: string, target: string): string;
/**
* Loads one or multiple .proto or preprocessed .json files into this root namespace.
* Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
* @param {string|string[]} filename Names of one or multiple files to load
* @param {function(?Error, Root=)} [callback] Node-style callback function
* @returns {Promise<Root>|undefined} A promise if `callback` has been omitted
* @param {function(?Error, Root=)} callback Node-style callback function
* @returns {undefined}
* @throws {TypeError} If arguments are invalid
*/
load(filename: (string|string[]), callback: (() => any)): undefined;
/**
* Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.
* @name Root#load
* @function
* @param {string|string[]} filename Names of one or multiple files to load
* @returns {Promise<Root>} Promise
* @throws {TypeError} If arguments are invalid
* @variation 2
*/
load(filename: (string|string[]), callback?: (() => any)): (Promise<Root>|undefined);
load(filename: (string|string[])): Promise<Root>;
}

0 comments on commit 9df6a3d

Please sign in to comment.