Permalink
Browse files

Added Namespace#lookupType and Namespace#lookupService (throw instead…

… of returning null), see #544
  • Loading branch information...
dcodeIO committed Dec 11, 2016
1 parent b8bce03 commit 01365ba9116ca1649b682635bb29814657c4133c
@@ -7,7 +7,7 @@ var path = require("path"),
var protobuf = require("../..");
json_module.description = "JSON representation as a module (AMD, CommonJS, global)"
json_module.description = "JSON representation as a module"
function json_module(root, options, callback) {
@@ -12,7 +12,7 @@ var path = require("path"),
var protobuf = require("../..");
static_module_target.description = "Static code without reflection as a module (AMD, CommonJS, global)";
static_module_target.description = "Static code without reflection as a module";
function static_module_target(root, options, callback) {
require("./static")(root, options, function(err, output) {

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 +45 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -267,3 +267,31 @@ NamespacePrototype.lookup = function lookup(path, parentAlreadyChecked) {
return null;
return this.parent.lookup(path);
};
/**
* Looks up the {@link Type|type} at the specified path, relative to this namespace.
* Besides its signature, this methods differs from {@link Namespace#lookup} in that it throws instead of returning `null`.
* @param {string|string[]} path Path to look up
* @returns {Type} Looked up type
* @throws {Error} If `path` does not point to a type
*/
NamespacePrototype.lookupType = function lookupType(path) {
var found = this.lookup(path);
if (!(found instanceof Type))
throw Error("no such type");
return found;
};
/**
* Looks up the {@link Service|service} at the specified path, relative to this namespace.
* Besides its signature, this methods differs from {@link Namespace#lookup} in that it throws instead of returning `null`.
* @param {string|string[]} path Path to look up
* @returns {Service} Looked up service
* @throws {Error} If `path` does not point to a service
*/
NamespacePrototype.lookupService = function lookupService(path) {
var found = this.lookup(path);
if (!(found instanceof Service))
throw Error("no such service");
return found;
};
@@ -1,6 +1,6 @@
/*
* protobuf.js v6.1.0 TypeScript definitions
* Generated Sun, 11 Dec 2016 12:37:58 UTC
* Generated Sun, 11 Dec 2016 23:22:51 UTC
*/
declare module "protobufjs" {
@@ -774,6 +774,24 @@ declare module "protobufjs" {
*/
lookup(path: (string|string[]), parentAlreadyChecked?: boolean): ReflectionObject;
/**
* Looks up the {@link Type|type} at the specified path, relative to this namespace.
* Besides its signature, this methods differs from {@link Namespace#lookup} in that it throws instead of returning `null`.
* @param {string|string[]} path Path to look up
* @returns {Type} Looked up type
* @throws {Error} If `path` does not point to a type
*/
lookupType(path: (string|string[])): Type;
/**
* Looks up the {@link Service|service} at the specified path, relative to this namespace.
* Besides its signature, this methods differs from {@link Namespace#lookup} in that it throws instead of returning `null`.
* @param {string|string[]} path Path to look up
* @returns {Service} Looked up service
* @throws {Error} If `path` does not point to a service
*/
lookupService(path: (string|string[])): Service;
}
/**
@@ -926,6 +944,14 @@ declare module "protobufjs" {
*/
oneof: string[];
/**
* Fields that belong to this oneof as an array for iteration.
* @name OneOf#fieldsArray
* @type {Field[]}
* @readonly
*/
fieldsArray: Field[];
/**
* Tests if the specified JSON object describes a oneof.
* @param {*} json JSON object
@@ -1745,6 +1771,14 @@ declare module "protobufjs" {
}
/**
* Fast 64 bit floats for buffers.
* @memberof util
* @namespace
*/
module f64 {
}
/**
* Constructs new long bits.
* @classdesc Helper class for working with the low and high bits of a 64 bit value.

0 comments on commit 01365ba

Please sign in to comment.