Skip to content

Commit

Permalink
Other: Just export the relevant namespace in ext/descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Apr 12, 2017
1 parent fbb9948 commit 6b94336
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions ext/descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
// ...
"use strict";

var protobuf = require("..");

/**
* Descriptor extension.
* @namespace
* @property {Type} FileDescriptorSet Descriptor set describing a root
* @property {Type} DescriptorProto Descriptor describing a type
* @property {Type} FieldDescriptorProto Descriptor describing a field
*/
var descriptor = exports;

var protobuf = require("..");
var descriptor = module.exports = protobuf.Root.fromJSON(require("../google/protobuf/descriptor.json")).lookup(".google.protobuf");

var root = protobuf.Root.fromJSON(require("../google/protobuf/descriptor.json")).resolveAll(),
Root = protobuf.Root,
var Root = protobuf.Root,
Type = protobuf.Type,
Field = protobuf.Field;

// Root
var FileDescriptorSet = descriptor.FileDescriptorSet,
DescriptorProto = descriptor.DescriptorProto,
FieldDescriptorProto = descriptor.FieldDescriptorProto;

/**
* FileDescriptorSet describing a root.
* @type {Type}
*/
descriptor.FileDescriptorSet = root.lookupType(".google.protobuf.FileDescriptorSet");
// Root

/**
* Creates a root from a descriptor set.
Expand All @@ -44,12 +44,6 @@ protobuf.Root.prototype.toDescriptor = function toDescriptorSet() {

// Type

/**
* DescriptorProto describing a type.
* @type {Type}
*/
descriptor.DescriptorProto = root.lookupType(".google.protobuf.DescriptorProto");

/**
* Creates a type from a descriptor.
* @param {DescriptorProto|Reader|Uint8Array} descriptor Descriptor
Expand Down Expand Up @@ -82,12 +76,6 @@ protobuf.Type.prototype.toDescriptor = function toDescriptor() {

// Field

/**
* FieldDescriptorProto describing a field.
* @type {Type}
*/
descriptor.FieldDescriptorProto = root.lookupType(".google.protobuf.FieldDescriptorProto");

/**
* Creates a field from a descriptor.
* @param {FieldDescriptorProto|Reader|Uint8Array} descriptor Descriptor
Expand All @@ -104,5 +92,3 @@ protobuf.Field.fromDescriptor = function fromDescriptor(descriptor) {
protobuf.Field.prototype.toDescriptor = function toDescriptor() {
throw Error("not implemented");
};

// etc.

0 comments on commit 6b94336

Please sign in to comment.