protobufjs 8.0.3-experimental → 8.0.4-experimental
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/dist/light/protobuf.js +156 -38
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +2 -2
- package/dist/minimal/protobuf.min.js +2 -2
- package/dist/protobuf.js +187 -49
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/index.d.ts +31 -15
- package/package.json +1 -1
- package/src/enum.js +10 -7
- package/src/field.js +17 -2
- package/src/namespace.js +22 -0
- package/src/object.js +60 -21
- package/src/parse.js +31 -11
- package/src/root.js +3 -3
- package/src/service.js +17 -0
- package/src/type.js +21 -1
- package/src/util.js +4 -2
package/dist/light/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.0.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.0.4-experimental (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 27 mar 2025 04:14:10 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -1730,21 +1730,20 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
|
|
|
1730
1730
|
}
|
|
1731
1731
|
|
|
1732
1732
|
/**
|
|
1733
|
-
*
|
|
1734
|
-
* @returns {Enum} `this`
|
|
1733
|
+
* @override
|
|
1735
1734
|
*/
|
|
1736
|
-
Enum.prototype.
|
|
1737
|
-
|
|
1735
|
+
Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
1736
|
+
var edition = this._edition || edition;
|
|
1737
|
+
ReflectionObject.prototype._resolveFeatures.call(this, edition);
|
|
1738
1738
|
|
|
1739
|
-
|
|
1739
|
+
Object.keys(this._valuesProtoFeatures).forEach(key => {
|
|
1740
1740
|
var parentFeaturesCopy = Object.assign({}, this._features);
|
|
1741
1741
|
this._valuesFeatures[key] = Object.assign(parentFeaturesCopy, this._valuesProtoFeatures[key] || {});
|
|
1742
|
-
}
|
|
1742
|
+
});
|
|
1743
1743
|
|
|
1744
1744
|
return this;
|
|
1745
1745
|
};
|
|
1746
1746
|
|
|
1747
|
-
|
|
1748
1747
|
/**
|
|
1749
1748
|
* Enum descriptor.
|
|
1750
1749
|
* @interface IEnum
|
|
@@ -1762,6 +1761,9 @@ Enum.prototype.resolve = function resolve() {
|
|
|
1762
1761
|
Enum.fromJSON = function fromJSON(name, json) {
|
|
1763
1762
|
var enm = new Enum(name, json.values, json.options, json.comment, json.comments);
|
|
1764
1763
|
enm.reserved = json.reserved;
|
|
1764
|
+
if (json.edition)
|
|
1765
|
+
enm._edition = json.edition;
|
|
1766
|
+
enm._defaultEdition = "proto3"; // For backwards-compatibility.
|
|
1765
1767
|
return enm;
|
|
1766
1768
|
};
|
|
1767
1769
|
|
|
@@ -1773,6 +1775,7 @@ Enum.fromJSON = function fromJSON(name, json) {
|
|
|
1773
1775
|
Enum.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
1774
1776
|
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
1775
1777
|
return util.toObject([
|
|
1778
|
+
"edition" , this._editionToJSON(),
|
|
1776
1779
|
"options" , this.options,
|
|
1777
1780
|
"valuesOptions" , this.valuesOptions,
|
|
1778
1781
|
"values" , this.values,
|
|
@@ -1923,7 +1926,11 @@ var ruleRe = /^required|optional|repeated$/;
|
|
|
1923
1926
|
* @throws {TypeError} If arguments are invalid
|
|
1924
1927
|
*/
|
|
1925
1928
|
Field.fromJSON = function fromJSON(name, json) {
|
|
1926
|
-
|
|
1929
|
+
var field = new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment);
|
|
1930
|
+
if (json.edition)
|
|
1931
|
+
field._edition = json.edition;
|
|
1932
|
+
field._defaultEdition = "proto3"; // For backwards-compatibility.
|
|
1933
|
+
return field;
|
|
1927
1934
|
};
|
|
1928
1935
|
|
|
1929
1936
|
/**
|
|
@@ -2164,6 +2171,7 @@ Field.prototype.setOption = function setOption(name, value, ifNotSet) {
|
|
|
2164
2171
|
Field.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
2165
2172
|
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
2166
2173
|
return util.toObject([
|
|
2174
|
+
"edition" , this._editionToJSON(),
|
|
2167
2175
|
"rule" , this.rule !== "optional" && this.rule || undefined,
|
|
2168
2176
|
"type" , this.type,
|
|
2169
2177
|
"id" , this.id,
|
|
@@ -2248,9 +2256,12 @@ Field.prototype.resolve = function resolve() {
|
|
|
2248
2256
|
* @returns {object} The feature values to override
|
|
2249
2257
|
*/
|
|
2250
2258
|
Field.prototype._inferLegacyProtoFeatures = function _inferLegacyProtoFeatures(edition) {
|
|
2251
|
-
if (edition)
|
|
2259
|
+
if (edition !== "proto2" && edition !== "proto3") {
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
2252
2262
|
|
|
2253
2263
|
var features = {};
|
|
2264
|
+
this.resolve();
|
|
2254
2265
|
if (this.rule === "required") {
|
|
2255
2266
|
features.field_presence = "LEGACY_REQUIRED";
|
|
2256
2267
|
}
|
|
@@ -2265,6 +2276,13 @@ Field.prototype._inferLegacyProtoFeatures = function _inferLegacyProtoFeatures(e
|
|
|
2265
2276
|
return features;
|
|
2266
2277
|
};
|
|
2267
2278
|
|
|
2279
|
+
/**
|
|
2280
|
+
* @override
|
|
2281
|
+
*/
|
|
2282
|
+
Field.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
2283
|
+
return ReflectionObject.prototype._resolveFeatures.call(this, this._edition || edition);
|
|
2284
|
+
};
|
|
2285
|
+
|
|
2268
2286
|
/**
|
|
2269
2287
|
* Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).
|
|
2270
2288
|
* @typedef FieldDecorator
|
|
@@ -3136,6 +3154,15 @@ Namespace.prototype.add = function add(object) {
|
|
|
3136
3154
|
}
|
|
3137
3155
|
}
|
|
3138
3156
|
this.nested[object.name] = object;
|
|
3157
|
+
|
|
3158
|
+
if (!(this instanceof Type || this instanceof Service || this instanceof Enum || this instanceof Field)) {
|
|
3159
|
+
// This is a package or a root namespace.
|
|
3160
|
+
if (!object._edition) {
|
|
3161
|
+
// Make sure that some edition is set if it hasn't already been specified.
|
|
3162
|
+
object._edition = object._defaultEdition;
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3139
3166
|
object.onAdd(this);
|
|
3140
3167
|
return clearCache(this);
|
|
3141
3168
|
};
|
|
@@ -3207,6 +3234,19 @@ Namespace.prototype.resolveAll = function resolveAll() {
|
|
|
3207
3234
|
return this;
|
|
3208
3235
|
};
|
|
3209
3236
|
|
|
3237
|
+
/**
|
|
3238
|
+
* @override
|
|
3239
|
+
*/
|
|
3240
|
+
Namespace.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
3241
|
+
var edition = this._edition || edition;
|
|
3242
|
+
|
|
3243
|
+
ReflectionObject.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
3244
|
+
this.nestedArray.forEach(nested => {
|
|
3245
|
+
nested._resolveFeaturesRecursive(edition);
|
|
3246
|
+
});
|
|
3247
|
+
return this;
|
|
3248
|
+
};
|
|
3249
|
+
|
|
3210
3250
|
/**
|
|
3211
3251
|
* Recursively looks up the reflection object matching the specified path in the scope of this namespace.
|
|
3212
3252
|
* @param {string|string[]} path Path to look up
|
|
@@ -3381,14 +3421,23 @@ function ReflectionObject(name, options) {
|
|
|
3381
3421
|
this.name = name;
|
|
3382
3422
|
|
|
3383
3423
|
/**
|
|
3384
|
-
*
|
|
3424
|
+
* The edition specified for this object. Only relevant for top-level objects.
|
|
3425
|
+
* @type {string}
|
|
3385
3426
|
*/
|
|
3386
|
-
this.
|
|
3427
|
+
this._edition = null;
|
|
3387
3428
|
|
|
3388
3429
|
/**
|
|
3389
|
-
*
|
|
3430
|
+
* The default edition to use for this object if none is specified. For legacy reasons,
|
|
3431
|
+
* this is proto2 except in the JSON parsing case where it was proto3.
|
|
3432
|
+
* @type {string}
|
|
3390
3433
|
*/
|
|
3391
|
-
this.
|
|
3434
|
+
this._defaultEdition = "proto2";
|
|
3435
|
+
|
|
3436
|
+
/**
|
|
3437
|
+
* Resolved Features.
|
|
3438
|
+
* @type {object}
|
|
3439
|
+
*/
|
|
3440
|
+
this._features = {};
|
|
3392
3441
|
|
|
3393
3442
|
/**
|
|
3394
3443
|
* Parent namespace.
|
|
@@ -3495,25 +3544,38 @@ ReflectionObject.prototype.onRemove = function onRemove(parent) {
|
|
|
3495
3544
|
ReflectionObject.prototype.resolve = function resolve() {
|
|
3496
3545
|
if (this.resolved)
|
|
3497
3546
|
return this;
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
this._resolveFeatures();
|
|
3547
|
+
if (this instanceof Root) {
|
|
3548
|
+
this._resolveFeaturesRecursive(this._edition);
|
|
3501
3549
|
this.resolved = true;
|
|
3502
3550
|
}
|
|
3503
3551
|
return this;
|
|
3504
3552
|
};
|
|
3505
3553
|
|
|
3554
|
+
/**
|
|
3555
|
+
* Resolves this objects editions features.
|
|
3556
|
+
* @param {string} edition The edition we're currently resolving for.
|
|
3557
|
+
* @returns {ReflectionObject} `this`
|
|
3558
|
+
*/
|
|
3559
|
+
ReflectionObject.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
3560
|
+
return this._resolveFeatures(this._edition || edition);
|
|
3561
|
+
};
|
|
3562
|
+
|
|
3506
3563
|
/**
|
|
3507
3564
|
* Resolves child features from parent features
|
|
3565
|
+
* @param {string} edition The edition we're currently resolving for.
|
|
3508
3566
|
* @returns {undefined}
|
|
3509
3567
|
*/
|
|
3510
|
-
ReflectionObject.prototype._resolveFeatures = function _resolveFeatures() {
|
|
3568
|
+
ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
3511
3569
|
var defaults = {};
|
|
3512
3570
|
|
|
3513
|
-
|
|
3571
|
+
if (!edition) {
|
|
3572
|
+
throw new Error("Unknown edition for " + this.fullName);
|
|
3573
|
+
}
|
|
3574
|
+
|
|
3575
|
+
var protoFeatures = Object.assign(this.options ? Object.assign({}, this.options.features) : {},
|
|
3576
|
+
this._inferLegacyProtoFeatures(edition));
|
|
3514
3577
|
|
|
3515
|
-
|
|
3516
|
-
if (this instanceof Namespace && edition) {
|
|
3578
|
+
if (this._edition) {
|
|
3517
3579
|
// For a namespace marked with a specific edition, reset defaults.
|
|
3518
3580
|
if (edition === "proto2") {
|
|
3519
3581
|
defaults = Object.assign({}, proto2Defaults);
|
|
@@ -3552,7 +3614,6 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures() {
|
|
|
3552
3614
|
* in older editions.
|
|
3553
3615
|
* @param {string|undefined} edition The edition this proto is on, or undefined if pre-editions
|
|
3554
3616
|
* @returns {object} The feature values to override
|
|
3555
|
-
* @abstract
|
|
3556
3617
|
*/
|
|
3557
3618
|
ReflectionObject.prototype._inferLegacyProtoFeatures = function _inferLegacyProtoFeatures(/*edition*/) {
|
|
3558
3619
|
return {};
|
|
@@ -3573,14 +3634,25 @@ ReflectionObject.prototype.getOption = function getOption(name) {
|
|
|
3573
3634
|
* Sets an option.
|
|
3574
3635
|
* @param {string} name Option name
|
|
3575
3636
|
* @param {*} value Option value
|
|
3576
|
-
* @param {boolean} [ifNotSet] Sets the option only if it isn't currently set
|
|
3637
|
+
* @param {boolean|undefined} [ifNotSet] Sets the option only if it isn't currently set
|
|
3577
3638
|
* @returns {ReflectionObject} `this`
|
|
3578
3639
|
*/
|
|
3579
3640
|
ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) {
|
|
3580
|
-
if (!
|
|
3641
|
+
if (!this.options)
|
|
3642
|
+
this.options = {};
|
|
3643
|
+
if (name === "features") {
|
|
3644
|
+
if (ifNotSet) {
|
|
3645
|
+
this.options.features = Object.assign(Object.assign({}, value), this.options.features || {});
|
|
3646
|
+
} else {
|
|
3647
|
+
this.options.features = Object.assign(this.options.features || {}, value);
|
|
3648
|
+
}
|
|
3649
|
+
} else if (/^features\./.test(name)) {
|
|
3650
|
+
util.setProperty(this.options, name, value, ifNotSet);
|
|
3651
|
+
} else if (!ifNotSet || this.options[name] === undefined) {
|
|
3581
3652
|
if (this.getOption(name) !== value) this.resolved = false;
|
|
3582
|
-
|
|
3653
|
+
this.options[name] = value;
|
|
3583
3654
|
}
|
|
3655
|
+
|
|
3584
3656
|
return this;
|
|
3585
3657
|
};
|
|
3586
3658
|
|
|
@@ -3621,12 +3693,6 @@ ReflectionObject.prototype.setParsedOption = function setParsedOption(name, valu
|
|
|
3621
3693
|
parsedOptions.push(newOpt);
|
|
3622
3694
|
}
|
|
3623
3695
|
|
|
3624
|
-
|
|
3625
|
-
if (isFeature) {
|
|
3626
|
-
var features = parsedOptions.find(x => {return Object.prototype.hasOwnProperty.call(x, "features");});
|
|
3627
|
-
this._protoFeatures = features.features || {};
|
|
3628
|
-
}
|
|
3629
|
-
|
|
3630
3696
|
return this;
|
|
3631
3697
|
};
|
|
3632
3698
|
|
|
@@ -3655,6 +3721,19 @@ ReflectionObject.prototype.toString = function toString() {
|
|
|
3655
3721
|
return className;
|
|
3656
3722
|
};
|
|
3657
3723
|
|
|
3724
|
+
/**
|
|
3725
|
+
* Converts the edition this object is pinned to for JSON format.
|
|
3726
|
+
* @returns {string|undefined} The edition string for JSON representation
|
|
3727
|
+
*/
|
|
3728
|
+
ReflectionObject.prototype._editionToJSON = function _editionToJSON() {
|
|
3729
|
+
if (!this._edition || this._edition === "proto3") {
|
|
3730
|
+
// Avoid emitting proto3 since we need to default to it for backwards
|
|
3731
|
+
// compatibility anyway.
|
|
3732
|
+
return undefined;
|
|
3733
|
+
}
|
|
3734
|
+
return this._edition;
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3658
3737
|
// Sets up cyclic dependencies (called in index-light)
|
|
3659
3738
|
ReflectionObject._configure = function(Root_, Namespace_) {
|
|
3660
3739
|
Root = Root_;
|
|
@@ -4395,8 +4474,8 @@ function Root(options) {
|
|
|
4395
4474
|
*/
|
|
4396
4475
|
this.files = [];
|
|
4397
4476
|
|
|
4398
|
-
// Default to proto2 if
|
|
4399
|
-
this.
|
|
4477
|
+
// Default to proto2 if unspecified.
|
|
4478
|
+
this._edition = "proto2";
|
|
4400
4479
|
}
|
|
4401
4480
|
|
|
4402
4481
|
/**
|
|
@@ -4410,7 +4489,7 @@ Root.fromJSON = function fromJSON(json, root) {
|
|
|
4410
4489
|
root = new Root();
|
|
4411
4490
|
if (json.options)
|
|
4412
4491
|
root.setOptions(json.options);
|
|
4413
|
-
return root.addJSON(json.nested);
|
|
4492
|
+
return root.addJSON(json.nested).resolveAll();
|
|
4414
4493
|
};
|
|
4415
4494
|
|
|
4416
4495
|
/**
|
|
@@ -5004,7 +5083,10 @@ Service.fromJSON = function fromJSON(name, json) {
|
|
|
5004
5083
|
service.add(Method.fromJSON(names[i], json.methods[names[i]]));
|
|
5005
5084
|
if (json.nested)
|
|
5006
5085
|
service.addJSON(json.nested);
|
|
5086
|
+
if (json.edition)
|
|
5087
|
+
service._edition = json.edition;
|
|
5007
5088
|
service.comment = json.comment;
|
|
5089
|
+
service._defaultEdition = "proto3"; // For backwards-compatibility.
|
|
5008
5090
|
return service;
|
|
5009
5091
|
};
|
|
5010
5092
|
|
|
@@ -5017,6 +5099,7 @@ Service.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
5017
5099
|
var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
|
|
5018
5100
|
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
5019
5101
|
return util.toObject([
|
|
5102
|
+
"edition" , this._editionToJSON(),
|
|
5020
5103
|
"options" , inherited && inherited.options || undefined,
|
|
5021
5104
|
"methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {},
|
|
5022
5105
|
"nested" , inherited && inherited.nested || undefined,
|
|
@@ -5060,6 +5143,19 @@ Service.prototype.resolveAll = function resolveAll() {
|
|
|
5060
5143
|
return this;
|
|
5061
5144
|
};
|
|
5062
5145
|
|
|
5146
|
+
/**
|
|
5147
|
+
* @override
|
|
5148
|
+
*/
|
|
5149
|
+
Service.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
5150
|
+
var edition = this._edition || edition;
|
|
5151
|
+
|
|
5152
|
+
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
5153
|
+
this.methodsArray.forEach(method => {
|
|
5154
|
+
method._resolveFeaturesRecursive(edition);
|
|
5155
|
+
});
|
|
5156
|
+
return this;
|
|
5157
|
+
};
|
|
5158
|
+
|
|
5063
5159
|
/**
|
|
5064
5160
|
* @override
|
|
5065
5161
|
*/
|
|
@@ -5351,7 +5447,7 @@ function clearCache(type) {
|
|
|
5351
5447
|
* @param {IType} json Message type descriptor
|
|
5352
5448
|
* @returns {Type} Created message type
|
|
5353
5449
|
*/
|
|
5354
|
-
Type.fromJSON = function fromJSON(name, json) {
|
|
5450
|
+
Type.fromJSON = function fromJSON(name, json, nested) {
|
|
5355
5451
|
var type = new Type(name, json.options);
|
|
5356
5452
|
type.extensions = json.extensions;
|
|
5357
5453
|
type.reserved = json.reserved;
|
|
@@ -5389,6 +5485,9 @@ Type.fromJSON = function fromJSON(name, json) {
|
|
|
5389
5485
|
type.group = true;
|
|
5390
5486
|
if (json.comment)
|
|
5391
5487
|
type.comment = json.comment;
|
|
5488
|
+
if (json.edition)
|
|
5489
|
+
type._edition = json.edition;
|
|
5490
|
+
type._defaultEdition = "proto3"; // For backwards-compatibility.
|
|
5392
5491
|
return type;
|
|
5393
5492
|
};
|
|
5394
5493
|
|
|
@@ -5401,6 +5500,7 @@ Type.prototype.toJSON = function toJSON(toJSONOptions) {
|
|
|
5401
5500
|
var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);
|
|
5402
5501
|
var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
|
|
5403
5502
|
return util.toObject([
|
|
5503
|
+
"edition" , this._editionToJSON(),
|
|
5404
5504
|
"options" , inherited && inherited.options || undefined,
|
|
5405
5505
|
"oneofs" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions),
|
|
5406
5506
|
"fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {},
|
|
@@ -5426,6 +5526,22 @@ Type.prototype.resolveAll = function resolveAll() {
|
|
|
5426
5526
|
return this;
|
|
5427
5527
|
};
|
|
5428
5528
|
|
|
5529
|
+
/**
|
|
5530
|
+
* @override
|
|
5531
|
+
*/
|
|
5532
|
+
Type.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(edition) {
|
|
5533
|
+
var edition = this._edition || edition;
|
|
5534
|
+
|
|
5535
|
+
Namespace.prototype._resolveFeaturesRecursive.call(this, edition);
|
|
5536
|
+
this.oneofsArray.forEach(oneof => {
|
|
5537
|
+
oneof._resolveFeatures(edition);
|
|
5538
|
+
});
|
|
5539
|
+
this.fieldsArray.forEach(field => {
|
|
5540
|
+
field._resolveFeatures(edition);
|
|
5541
|
+
});
|
|
5542
|
+
return this;
|
|
5543
|
+
};
|
|
5544
|
+
|
|
5429
5545
|
/**
|
|
5430
5546
|
* @override
|
|
5431
5547
|
*/
|
|
@@ -6078,10 +6194,10 @@ util.decorateEnum = function decorateEnum(object) {
|
|
|
6078
6194
|
* @param {Object.<string,*>} dst Destination object
|
|
6079
6195
|
* @param {string} path dot '.' delimited path of the property to set
|
|
6080
6196
|
* @param {Object} value the value to set
|
|
6081
|
-
* @param {boolean}
|
|
6197
|
+
* @param {boolean|undefined} [ifNotSet] Sets the option only if it isn't currently set
|
|
6082
6198
|
* @returns {Object.<string,*>} Destination object
|
|
6083
6199
|
*/
|
|
6084
|
-
util.setProperty = function setProperty(dst, path, value) {
|
|
6200
|
+
util.setProperty = function setProperty(dst, path, value, ifNotSet) {
|
|
6085
6201
|
function setProp(dst, path, value) {
|
|
6086
6202
|
var part = path.shift();
|
|
6087
6203
|
if (part === "__proto__" || part === "prototype") {
|
|
@@ -6091,6 +6207,8 @@ util.setProperty = function setProperty(dst, path, value) {
|
|
|
6091
6207
|
dst[part] = setProp(dst[part] || {}, path, value);
|
|
6092
6208
|
} else {
|
|
6093
6209
|
var prevValue = dst[part];
|
|
6210
|
+
if (prevValue && ifNotSet)
|
|
6211
|
+
return dst;
|
|
6094
6212
|
if (prevValue)
|
|
6095
6213
|
value = [].concat(prevValue).concat(value);
|
|
6096
6214
|
dst[part] = value;
|