Permalink
Browse files

Lazily resolve (some) cyclic dependencies, see #560

  • Loading branch information...
dcodeIO committed Dec 15, 2016
1 parent 9b7b92a commit 9c769504e0ffa6cbe0b6f8cdc14f1231bed7ee34

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

Large diffs are not rendered by default.

Oops, something went wrong.

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

Oops, something went wrong.

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

Oops, something went wrong.
BIN -1 Byte (100%) dist/runtime/protobuf.min.js.gz
Binary file not shown.
@@ -7,12 +7,13 @@ var ReflectionObject = require("./object");
/** @alias Field.prototype */
var FieldPrototype = ReflectionObject.extend(Field);
var Type = require("./type"),
Enum = require("./enum"),
MapField = require("./mapfield"),
var Enum = require("./enum"),
types = require("./types"),
util = require("./util");
var Type, // cyclic
MapField; // cyclic
var _TypeError = util._TypeError;
/**
@@ -193,8 +194,11 @@ Field.testJSON = function testJSON(json) {
* @throws {TypeError} If arguments are invalid
*/
Field.fromJSON = function fromJSON(name, json) {
if (json.keyType !== undefined)
if (json.keyType !== undefined) {
if (!MapField)
MapField = require("./mapfield");
return MapField.fromJSON(name, json);
}
return new Field(name, json.id, json.type, json.rule, json.extend, json.options);
};
@@ -225,6 +229,8 @@ FieldPrototype.resolve = function resolve() {
// if not a basic type, resolve it
if (typeDefault === undefined) {
var resolved = this.parent.lookup(this.type);
if (!Type)
Type = require("./type");
if (resolved instanceof Type) {
this.resolvedType = resolved;
typeDefault = null;
@@ -117,7 +117,6 @@ protobuf.configure = configure;
* @returns {undefined}
*/
function configure() {
util._configure();
Reader._configure();
}
Oops, something went wrong.

0 comments on commit 9c76950

Please sign in to comment.