protobufjs 7.1.2 → 7.2.0

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v7.1.0 (c) 2016, daniel wirtz
3
- * compiled thu, 22 sep 2022 17:16:10 utc
2
+ * protobuf.js v7.2.0 (c) 2016, daniel wirtz
3
+ * compiled tue, 24 jan 2023 20:12:01 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -1129,18 +1129,20 @@ var Enum = require(14),
1129
1129
  * @ignore
1130
1130
  */
1131
1131
  function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1132
+ var defaultAlreadyEmitted = false;
1132
1133
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
1133
1134
  if (field.resolvedType) {
1134
1135
  if (field.resolvedType instanceof Enum) { gen
1135
1136
  ("switch(d%s){", prop);
1136
1137
  for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
1137
1138
  // enum unknown values passthrough
1138
- if (values[keys[i]] === field.typeDefault) { gen
1139
+ if (values[keys[i]] === field.typeDefault && !defaultAlreadyEmitted) { gen
1139
1140
  ("default:")
1140
1141
  ("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
1141
1142
  if (!field.repeated) gen // fallback to default value only for
1142
1143
  // arrays, to avoid leaving holes.
1143
1144
  ("break"); // for non-repeated fields, just ignore
1145
+ defaultAlreadyEmitted = true;
1144
1146
  }
1145
1147
  gen
1146
1148
  ("case%j:", keys[i])
@@ -4247,10 +4249,10 @@ Root.prototype.load = function load(filename, options, callback) {
4247
4249
  /* istanbul ignore if */
4248
4250
  if (!callback)
4249
4251
  return;
4250
- var cb = callback;
4251
- callback = null;
4252
4252
  if (sync)
4253
4253
  throw err;
4254
+ var cb = callback;
4255
+ callback = null;
4254
4256
  cb(err, root);
4255
4257
  }
4256
4258