protobufjs 7.1.0 → 7.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/light/protobuf.js +2 -3
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +1 -1
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +1 -1
- package/dist/minimal/protobuf.min.js +1 -1
- package/dist/protobuf.js +2 -3
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +1 -1
- package/dist/protobuf.min.js.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/converter.js +3 -1
- package/src/namespace.js +1 -2
package/index.d.ts
CHANGED
|
@@ -863,7 +863,7 @@ export interface INamespace {
|
|
|
863
863
|
type AnyExtensionField = (IExtensionField|IExtensionMapField);
|
|
864
864
|
|
|
865
865
|
/** Any nested object descriptor. */
|
|
866
|
-
type AnyNestedObject = (IEnum|IType|IService|AnyExtensionField|INamespace);
|
|
866
|
+
type AnyNestedObject = (IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf);
|
|
867
867
|
|
|
868
868
|
/** Base class of all reflection objects. */
|
|
869
869
|
export abstract class ReflectionObject {
|
package/package.json
CHANGED
package/src/converter.js
CHANGED
|
@@ -18,18 +18,20 @@ var Enum = require("./enum"),
|
|
|
18
18
|
* @ignore
|
|
19
19
|
*/
|
|
20
20
|
function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
|
|
21
|
+
var defaultAlreadyEmitted = false;
|
|
21
22
|
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
|
|
22
23
|
if (field.resolvedType) {
|
|
23
24
|
if (field.resolvedType instanceof Enum) { gen
|
|
24
25
|
("switch(d%s){", prop);
|
|
25
26
|
for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
|
|
26
27
|
// enum unknown values passthrough
|
|
27
|
-
if (values[keys[i]] === field.typeDefault) { gen
|
|
28
|
+
if (values[keys[i]] === field.typeDefault && !defaultAlreadyEmitted) { gen
|
|
28
29
|
("default:")
|
|
29
30
|
("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
|
|
30
31
|
if (!field.repeated) gen // fallback to default value only for
|
|
31
32
|
// arrays, to avoid leaving holes.
|
|
32
33
|
("break"); // for non-repeated fields, just ignore
|
|
34
|
+
defaultAlreadyEmitted = true;
|
|
33
35
|
}
|
|
34
36
|
gen
|
|
35
37
|
("case%j:", keys[i])
|
package/src/namespace.js
CHANGED
|
@@ -143,9 +143,8 @@ Object.defineProperty(Namespace.prototype, "nestedArray", {
|
|
|
143
143
|
/**
|
|
144
144
|
* Any nested object descriptor.
|
|
145
145
|
* @typedef AnyNestedObject
|
|
146
|
-
* @type {IEnum|IType|IService|AnyExtensionField|INamespace}
|
|
146
|
+
* @type {IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf}
|
|
147
147
|
*/
|
|
148
|
-
// ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place)
|
|
149
148
|
|
|
150
149
|
/**
|
|
151
150
|
* Converts this namespace to a namespace descriptor.
|