Permalink
Browse files

Docs: Additional notes on ext/descriptor [ci skip]

  • Loading branch information...
dcodeIO committed Apr 12, 2017
1 parent 708552b commit ef92da3768d8746dbfe72e77232f78b879fc811d
Showing with 10 additions and 8 deletions.
  1. +2 −2 ext/descriptor/README.md
  2. +1 −1 ext/descriptor/index.d.ts
  3. +7 −5 ext/descriptor/index.js
@@ -10,12 +10,12 @@ Usage
var protobuf = require("protobufjs"),
descriptor = require("protobufjs/ext/descriptor");
var descriptor = ...; // either a FieldDescriptorSet buffer or JSON object
var descriptor = ...; // either a FieldDescriptorSet buffer, a FieldDescriptorSet message instance or a corresponding valid JSON object
var root = protobuf.Root.fromDescriptor(descriptor);
var rootDescriptor = root.toDescriptor("proto3");
```
API
---
The extension adds `.fromDescriptor(descriptor[, syntax])` and `#toDescriptor([syntax])` methods to reflection objects and exports the internally used `Root` instance that contains the types present in descriptor.proto.
The extension adds `.fromDescriptor(descriptor[, syntax])` and `#toDescriptor([syntax])` methods to reflection objects and exports the `.google.protobuf` namespace of the internally used `Root` instance containing the types present in descriptor.proto.
@@ -1,6 +1,6 @@
import * as $protobuf from "../..";
declare const descriptor: $protobuf.Root;
declare const descriptor: $protobuf.Namespace;
interface IFileDescriptorSet {
file: IFileDescriptorProto[];
@@ -4,13 +4,15 @@ var $protobuf = require("..");
/**
* Descriptor extension (ext/descriptor).
* Exports the `.google.protobuf` namespace of the internally used {@link Root} instance containing the types present in descriptor.proto.
* @type {Root}
* @tstype $protobuf.Root
* @tstype $protobuf.Namespace
* @const
* @see https://github.com/dcodeIO/protobuf.js/tree/master/ext/descriptor
*/
var descriptor = module.exports = $protobuf.Root.fromJSON(require("../google/protobuf/descriptor.json")).lookup(".google.protobuf");
var google = descriptor,
var google = descriptor, // aliased used where `descriptor` is a local var
Root = $protobuf.Root,
Enum = $protobuf.Enum,
Type = $protobuf.Type,
@@ -44,7 +46,7 @@ var google = descriptor,
/**
* Creates a root from a descriptor set.
* @param {Properties<IFileDescriptorSet>|Reader|Uint8Array} descriptor Descriptor
* @param {IFileDescriptorSet|Reader|Uint8Array} descriptor Descriptor
* @returns {Root} Root instance
* @see Part of the {@link descriptor} extension (ext/descriptor)
*/
@@ -144,7 +146,7 @@ var unnamedMessageIndex = 0;
/**
* Creates a type from a descriptor.
* @param {Properties<IDescriptorProto>|Reader|Uint8Array} descriptor Descriptor
* @param {IDescriptorProto|Reader|Uint8Array} descriptor Descriptor
* @param {string} [syntax="proto2"] Syntax
* @returns {Type} Type instance
* @see Part of the {@link descriptor} extension (ext/descriptor)
@@ -520,7 +522,7 @@ var unnamedServiceIndex = 0;
/**
* Creates a service from a descriptor.
* @param {Properties<IServiceDescriptorProto>|Reader|Uint8Array} descriptor Descriptor
* @param {IServiceDescriptorProto|Reader|Uint8Array} descriptor Descriptor
* @returns {Service} Service instance
* @see Part of the {@link descriptor} extension (ext/descriptor)
*/

0 comments on commit ef92da3

Please sign in to comment.