Skip to content

Commit ef92da3

Browse files
committed
Docs: Additional notes on ext/descriptor [ci skip]
1 parent 708552b commit ef92da3

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

ext/descriptor/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ Usage
1010
var protobuf = require("protobufjs"),
1111
descriptor = require("protobufjs/ext/descriptor");
1212

13-
var descriptor = ...; // either a FieldDescriptorSet buffer or JSON object
13+
var descriptor = ...; // either a FieldDescriptorSet buffer, a FieldDescriptorSet message instance or a corresponding valid JSON object
1414
var root = protobuf.Root.fromDescriptor(descriptor);
1515
var rootDescriptor = root.toDescriptor("proto3");
1616
```
1717

1818
API
1919
---
2020

21-
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.
21+
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.

ext/descriptor/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as $protobuf from "../..";
22

3-
declare const descriptor: $protobuf.Root;
3+
declare const descriptor: $protobuf.Namespace;
44

55
interface IFileDescriptorSet {
66
file: IFileDescriptorProto[];

ext/descriptor/index.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ var $protobuf = require("..");
44

55
/**
66
* Descriptor extension (ext/descriptor).
7+
* Exports the `.google.protobuf` namespace of the internally used {@link Root} instance containing the types present in descriptor.proto.
78
* @type {Root}
8-
* @tstype $protobuf.Root
9+
* @tstype $protobuf.Namespace
910
* @const
11+
* @see https://github.com/dcodeIO/protobuf.js/tree/master/ext/descriptor
1012
*/
1113
var descriptor = module.exports = $protobuf.Root.fromJSON(require("../google/protobuf/descriptor.json")).lookup(".google.protobuf");
1214

13-
var google = descriptor,
15+
var google = descriptor, // aliased used where `descriptor` is a local var
1416
Root = $protobuf.Root,
1517
Enum = $protobuf.Enum,
1618
Type = $protobuf.Type,
@@ -44,7 +46,7 @@ var google = descriptor,
4446

4547
/**
4648
* Creates a root from a descriptor set.
47-
* @param {Properties<IFileDescriptorSet>|Reader|Uint8Array} descriptor Descriptor
49+
* @param {IFileDescriptorSet|Reader|Uint8Array} descriptor Descriptor
4850
* @returns {Root} Root instance
4951
* @see Part of the {@link descriptor} extension (ext/descriptor)
5052
*/
@@ -144,7 +146,7 @@ var unnamedMessageIndex = 0;
144146

145147
/**
146148
* Creates a type from a descriptor.
147-
* @param {Properties<IDescriptorProto>|Reader|Uint8Array} descriptor Descriptor
149+
* @param {IDescriptorProto|Reader|Uint8Array} descriptor Descriptor
148150
* @param {string} [syntax="proto2"] Syntax
149151
* @returns {Type} Type instance
150152
* @see Part of the {@link descriptor} extension (ext/descriptor)
@@ -520,7 +522,7 @@ var unnamedServiceIndex = 0;
520522

521523
/**
522524
* Creates a service from a descriptor.
523-
* @param {Properties<IServiceDescriptorProto>|Reader|Uint8Array} descriptor Descriptor
525+
* @param {IServiceDescriptorProto|Reader|Uint8Array} descriptor Descriptor
524526
* @returns {Service} Service instance
525527
* @see Part of the {@link descriptor} extension (ext/descriptor)
526528
*/

0 commit comments

Comments
 (0)