protobufjs 6.11.3 → 7.1.1

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.
Files changed (65) hide show
  1. package/README.md +7 -174
  2. package/dist/light/protobuf.js +77 -29
  3. package/dist/light/protobuf.js.map +1 -1
  4. package/dist/light/protobuf.min.js +3 -3
  5. package/dist/light/protobuf.min.js.map +1 -1
  6. package/dist/minimal/protobuf.js +27 -10
  7. package/dist/minimal/protobuf.js.map +1 -1
  8. package/dist/minimal/protobuf.min.js +3 -3
  9. package/dist/minimal/protobuf.min.js.map +1 -1
  10. package/dist/protobuf.js +163 -61
  11. package/dist/protobuf.js.map +1 -1
  12. package/dist/protobuf.min.js +3 -3
  13. package/dist/protobuf.min.js.map +1 -1
  14. package/index.d.ts +9 -7
  15. package/package.json +12 -31
  16. package/scripts/postinstall.js +0 -3
  17. package/src/converter.js +12 -4
  18. package/src/decoder.js +4 -3
  19. package/src/enum.js +24 -7
  20. package/src/field.js +6 -3
  21. package/src/namespace.js +3 -3
  22. package/src/parse.js +55 -16
  23. package/src/roots.js +1 -1
  24. package/src/tokenize.js +31 -16
  25. package/src/util/minimal.js +24 -7
  26. package/src/wrappers.js +2 -2
  27. package/tsconfig.json +2 -1
  28. package/CHANGELOG.md +0 -1027
  29. package/bin/pbjs +0 -6
  30. package/bin/pbts +0 -6
  31. package/cli/LICENSE +0 -33
  32. package/cli/README.md +0 -174
  33. package/cli/bin/pbjs +0 -6
  34. package/cli/bin/pbts +0 -6
  35. package/cli/index.d.ts +0 -3
  36. package/cli/index.js +0 -3
  37. package/cli/lib/tsd-jsdoc/LICENSE +0 -21
  38. package/cli/lib/tsd-jsdoc/README.md +0 -23
  39. package/cli/lib/tsd-jsdoc/plugin.js +0 -21
  40. package/cli/lib/tsd-jsdoc/publish.js +0 -705
  41. package/cli/lib/tsd-jsdoc.json +0 -18
  42. package/cli/package.json +0 -8
  43. package/cli/package.standalone.json +0 -32
  44. package/cli/pbjs.d.ts +0 -9
  45. package/cli/pbjs.js +0 -330
  46. package/cli/pbts.d.ts +0 -9
  47. package/cli/pbts.js +0 -197
  48. package/cli/targets/json-module.js +0 -38
  49. package/cli/targets/json.js +0 -8
  50. package/cli/targets/proto.js +0 -326
  51. package/cli/targets/proto2.js +0 -10
  52. package/cli/targets/proto3.js +0 -10
  53. package/cli/targets/static-module.js +0 -29
  54. package/cli/targets/static.js +0 -711
  55. package/cli/util.js +0 -183
  56. package/cli/wrappers/amd.js +0 -7
  57. package/cli/wrappers/closure.js +0 -7
  58. package/cli/wrappers/commonjs.js +0 -7
  59. package/cli/wrappers/default.js +0 -15
  60. package/cli/wrappers/es6.js +0 -5
  61. package/dist/README.md +0 -31
  62. package/dist/light/README.md +0 -31
  63. package/dist/minimal/README.md +0 -31
  64. package/package-lock.json +0 -7870
  65. package/scripts/changelog.js +0 -150
package/README.md CHANGED
@@ -27,14 +27,6 @@ Contents
27
27
  * [Using services](#using-services)
28
28
  * [Usage with TypeScript](#usage-with-typescript)<br />
29
29
 
30
- * [Command line](#command-line)<br />
31
- How to use the command line utility.
32
-
33
- * [pbjs for JavaScript](#pbjs-for-javascript)
34
- * [pbts for TypeScript](#pbts-for-typescript)
35
- * [Reflection vs. static code](#reflection-vs-static-code)
36
- * [Command line API](#command-line-api)<br />
37
-
38
30
  * [Additional documentation](#additional-documentation)<br />
39
31
  A list of available documentation resources.
40
32
 
@@ -60,6 +52,12 @@ $> npm install protobufjs [--save --save-prefix=~]
60
52
  var protobuf = require("protobufjs");
61
53
  ```
62
54
 
55
+ The command line utility lives in the protobufjs-cli package and must be installed separately:
56
+
57
+ ```
58
+ $> npm install protobufjs-cli [--save --save-prefix=~]
59
+ ```
60
+
63
61
  **Note** that this library's versioning scheme is not semver-compatible for historical reasons. For guaranteed backward compatibility, always depend on `~6.A.B` instead of `^6.A.B` (hence the `--save-prefix` above).
64
62
 
65
63
  ### Browsers
@@ -84,7 +82,7 @@ The library supports CommonJS and AMD loaders and also exports globally as `prot
84
82
 
85
83
  Where bundle size is a factor, there are additional stripped-down versions of the [full library][dist-full] (~19kb gzipped) available that exclude certain functionality:
86
84
 
87
- * When working with JSON descriptors (i.e. generated by [pbjs](#pbjs-for-javascript)) and/or reflection only, see the [light library][dist-light] (~16kb gzipped) that excludes the parser. CommonJS entry point is:
85
+ * When working with JSON descriptors (i.e. generated by [pbjs](cli/README.md#pbjs-for-javascript)) and/or reflection only, see the [light library][dist-light] (~16kb gzipped) that excludes the parser. CommonJS entry point is:
88
86
 
89
87
  ```js
90
88
  var protobuf = require("protobufjs/light");
@@ -597,171 +595,6 @@ Other notes:
597
595
 
598
596
  **ProTip!** Not as pretty, but you can [use decorators in plain JavaScript](https://github.com/dcodeIO/protobuf.js/blob/master/examples/js-decorators.js) as well.
599
597
 
600
- Command line
601
- ------------
602
-
603
- **Note** that moving the CLI to [its own package](./cli) is a work in progress. At the moment, it's still part of the main package.
604
-
605
- The command line interface (CLI) can be used to translate between file formats and to generate static code as well as TypeScript definitions.
606
-
607
- ### pbjs for JavaScript
608
-
609
- ```
610
- Translates between file formats and generates static code.
611
-
612
- -t, --target Specifies the target format. Also accepts a path to require a custom target.
613
-
614
- json JSON representation
615
- json-module JSON representation as a module
616
- proto2 Protocol Buffers, Version 2
617
- proto3 Protocol Buffers, Version 3
618
- static Static code without reflection (non-functional on its own)
619
- static-module Static code without reflection as a module
620
-
621
- -p, --path Adds a directory to the include path.
622
-
623
- -o, --out Saves to a file instead of writing to stdout.
624
-
625
- --sparse Exports only those types referenced from a main file (experimental).
626
-
627
- Module targets only:
628
-
629
- -w, --wrap Specifies the wrapper to use. Also accepts a path to require a custom wrapper.
630
-
631
- default Default wrapper supporting both CommonJS and AMD
632
- commonjs CommonJS wrapper
633
- amd AMD wrapper
634
- es6 ES6 wrapper (implies --es6)
635
- closure A closure adding to protobuf.roots where protobuf is a global
636
-
637
- -r, --root Specifies an alternative protobuf.roots name.
638
-
639
- -l, --lint Linter configuration. Defaults to protobuf.js-compatible rules:
640
-
641
- eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins
642
-
643
- --es6 Enables ES6 syntax (const/let instead of var)
644
-
645
- Proto sources only:
646
-
647
- --keep-case Keeps field casing instead of converting to camel case.
648
-
649
- Static targets only:
650
-
651
- --no-create Does not generate create functions used for reflection compatibility.
652
- --no-encode Does not generate encode functions.
653
- --no-decode Does not generate decode functions.
654
- --no-verify Does not generate verify functions.
655
- --no-convert Does not generate convert functions like from/toObject
656
- --no-delimited Does not generate delimited encode/decode functions.
657
- --no-beautify Does not beautify generated code.
658
- --no-comments Does not output any JSDoc comments.
659
-
660
- --force-long Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.
661
- --force-number Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields.
662
- --force-message Enforces the use of message instances instead of plain objects.
663
-
664
- usage: pbjs [options] file1.proto file2.json ... (or pipe) other | pbjs [options] -
665
- ```
666
-
667
- For production environments it is recommended to bundle all your .proto files to a single .json file, which minimizes the number of network requests and avoids any parser overhead (hint: works with just the **light** library):
668
-
669
- ```
670
- $> pbjs -t json file1.proto file2.proto > bundle.json
671
- ```
672
-
673
- Now, either include this file in your final bundle:
674
-
675
- ```js
676
- var root = protobuf.Root.fromJSON(require("./bundle.json"));
677
- ```
678
-
679
- or load it the usual way:
680
-
681
- ```js
682
- protobuf.load("bundle.json", function(err, root) {
683
- ...
684
- });
685
- ```
686
-
687
- Generated static code, on the other hand, works with just the **minimal** library. For example
688
-
689
- ```
690
- $> pbjs -t static-module -w commonjs -o compiled.js file1.proto file2.proto
691
- ```
692
-
693
- will generate static code for definitions within `file1.proto` and `file2.proto` to a CommonJS module `compiled.js`.
694
-
695
- **ProTip!** Documenting your .proto files with `/** ... */`-blocks or (trailing) `/// ...` lines translates to generated static code.
696
-
697
-
698
- ### pbts for TypeScript
699
-
700
- ```
701
- Generates TypeScript definitions from annotated JavaScript files.
702
-
703
- -o, --out Saves to a file instead of writing to stdout.
704
-
705
- -g, --global Name of the global object in browser environments, if any.
706
-
707
- --no-comments Does not output any JSDoc comments.
708
-
709
- Internal flags:
710
-
711
- -n, --name Wraps everything in a module of the specified name.
712
-
713
- -m, --main Whether building the main library without any imports.
714
-
715
- usage: pbts [options] file1.js file2.js ... (or) other | pbts [options] -
716
- ```
717
-
718
- Picking up on the example above, the following not only generates static code to a CommonJS module `compiled.js` but also its respective TypeScript definitions to `compiled.d.ts`:
719
-
720
- ```
721
- $> pbjs -t static-module -w commonjs -o compiled.js file1.proto file2.proto
722
- $> pbts -o compiled.d.ts compiled.js
723
- ```
724
-
725
- Additionally, TypeScript definitions of static modules are compatible with their reflection-based counterparts (i.e. as exported by JSON modules), as long as the following conditions are met:
726
-
727
- 1. Instead of using `new SomeMessage(...)`, always use `SomeMessage.create(...)` because reflection objects do not provide a constructor.
728
- 2. Types, services and enums must start with an uppercase letter to become available as properties of the reflected types as well (i.e. to be able to use `MyMessage.MyEnum` instead of `root.lookup("MyMessage.MyEnum")`).
729
-
730
- For example, the following generates a JSON module `bundle.js` and a `bundle.d.ts`, but no static code:
731
-
732
- ```
733
- $> pbjs -t json-module -w commonjs -o bundle.js file1.proto file2.proto
734
- $> pbjs -t static-module file1.proto file2.proto | pbts -o bundle.d.ts -
735
- ```
736
-
737
- ### Reflection vs. static code
738
-
739
- While using .proto files directly requires the full library respectively pure reflection/JSON the light library, pretty much all code but the relatively short descriptors is shared.
740
-
741
- Static code, on the other hand, requires just the minimal library, but generates additional source code without any reflection features. This also implies that there is a break-even point where statically generated code becomes larger than descriptor-based code once the amount of code generated exceeds the size of the full respectively light library.
742
-
743
- There is no significant difference performance-wise as the code generated statically is pretty much the same as generated at runtime and both are largely interchangeable as seen in the previous section.
744
-
745
- | Source | Library | Advantages | Tradeoffs
746
- |--------|---------|------------|-----------
747
- | .proto | full | Easily editable<br />Interoperability with other libraries<br />No compile step | Some parsing and possibly network overhead
748
- | JSON | light | Easily editable<br />No parsing overhead<br />Single bundle (no network overhead) | protobuf.js specific<br />Has a compile step
749
- | static | minimal | Works where `eval` access is restricted<br />Fully documented<br />Small footprint for small protos | Can be hard to edit<br />No reflection<br />Has a compile step
750
-
751
- ### Command line API
752
-
753
- Both utilities can be used programmatically by providing command line arguments and a callback to their respective `main` functions:
754
-
755
- ```js
756
- var pbjs = require("protobufjs/cli/pbjs"); // or require("protobufjs/cli").pbjs / .pbts
757
-
758
- pbjs.main([ "--target", "json-module", "path/to/myproto.proto" ], function(err, output) {
759
- if (err)
760
- throw err;
761
- // do something with output
762
- });
763
- ```
764
-
765
598
  Additional documentation
766
599
  ------------------------
767
600
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v6.11.0 (c) 2016, daniel wirtz
3
- * compiled thu, 29 apr 2021 02:20:44 utc
2
+ * protobuf.js v7.1.0 (c) 2016, daniel wirtz
3
+ * compiled fri, 09 sep 2022 03:02:57 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -1134,8 +1134,14 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1134
1134
  if (field.resolvedType instanceof Enum) { gen
1135
1135
  ("switch(d%s){", prop);
1136
1136
  for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
1137
- if (field.repeated && values[keys[i]] === field.typeDefault) gen
1138
- ("default:");
1137
+ // enum unknown values passthrough
1138
+ if (values[keys[i]] === field.typeDefault) { gen
1139
+ ("default:")
1140
+ ("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
1141
+ if (!field.repeated) gen // fallback to default value only for
1142
+ // arrays, to avoid leaving holes.
1143
+ ("break"); // for non-repeated fields, just ignore
1144
+ }
1139
1145
  gen
1140
1146
  ("case%j:", keys[i])
1141
1147
  ("case %i:", values[keys[i]])
@@ -1182,7 +1188,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1182
1188
  case "bytes": gen
1183
1189
  ("if(typeof d%s===\"string\")", prop)
1184
1190
  ("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", prop, prop, prop)
1185
- ("else if(d%s.length)", prop)
1191
+ ("else if(d%s.length >= 0)", prop)
1186
1192
  ("m%s=d%s", prop, prop);
1187
1193
  break;
1188
1194
  case "string": gen
@@ -1267,7 +1273,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
1267
1273
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
1268
1274
  if (field.resolvedType) {
1269
1275
  if (field.resolvedType instanceof Enum) gen
1270
- ("d%s=o.enums===String?types[%i].values[m%s]:m%s", prop, fieldIndex, prop, prop);
1276
+ ("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s", prop, fieldIndex, prop, prop, fieldIndex, prop, prop);
1271
1277
  else gen
1272
1278
  ("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
1273
1279
  } else {
@@ -1439,7 +1445,7 @@ function decoder(mtype) {
1439
1445
  var field = mtype._fieldsArray[i].resolve(),
1440
1446
  type = field.resolvedType instanceof Enum ? "int32" : field.type,
1441
1447
  ref = "m" + util.safeProp(field.name); gen
1442
- ("case %i:", field.id);
1448
+ ("case %i: {", field.id);
1443
1449
 
1444
1450
  // Map fields
1445
1451
  if (field.map) { gen
@@ -1510,8 +1516,9 @@ function decoder(mtype) {
1510
1516
  else gen
1511
1517
  ("%s=r.%s()", ref, type);
1512
1518
  gen
1513
- ("break");
1514
- // Unknown fields
1519
+ ("break")
1520
+ ("}");
1521
+ // Unknown fields
1515
1522
  } gen
1516
1523
  ("default:")
1517
1524
  ("r.skipType(t&7)")
@@ -1656,8 +1663,9 @@ var Namespace = require(21),
1656
1663
  * @param {Object.<string,*>} [options] Declared options
1657
1664
  * @param {string} [comment] The comment for this enum
1658
1665
  * @param {Object.<string,string>} [comments] The value comments for this enum
1666
+ * @param {Object.<string,Object<string,*>>|undefined} [valuesOptions] The value options for this enum
1659
1667
  */
1660
- function Enum(name, values, options, comment, comments) {
1668
+ function Enum(name, values, options, comment, comments, valuesOptions) {
1661
1669
  ReflectionObject.call(this, name, options);
1662
1670
 
1663
1671
  if (values && typeof values !== "object")
@@ -1687,6 +1695,12 @@ function Enum(name, values, options, comment, comments) {
1687
1695
  */
1688
1696
  this.comments = comments || {};
1689
1697
 
1698
+ /**
1699
+ * Values options, if any
1700
+ * @type {Object<string, Object<string, *>>|undefined}
1701
+ */
1702
+ this.valuesOptions = valuesOptions;
1703
+
1690
1704
  /**
1691
1705
  * Reserved ranges, if any.
1692
1706
  * @type {Array.<number[]|string>}
@@ -1731,11 +1745,12 @@ Enum.fromJSON = function fromJSON(name, json) {
1731
1745
  Enum.prototype.toJSON = function toJSON(toJSONOptions) {
1732
1746
  var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
1733
1747
  return util.toObject([
1734
- "options" , this.options,
1735
- "values" , this.values,
1736
- "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
1737
- "comment" , keepComments ? this.comment : undefined,
1738
- "comments" , keepComments ? this.comments : undefined
1748
+ "options" , this.options,
1749
+ "valuesOptions" , this.valuesOptions,
1750
+ "values" , this.values,
1751
+ "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
1752
+ "comment" , keepComments ? this.comment : undefined,
1753
+ "comments" , keepComments ? this.comments : undefined
1739
1754
  ]);
1740
1755
  };
1741
1756
 
@@ -1744,11 +1759,12 @@ Enum.prototype.toJSON = function toJSON(toJSONOptions) {
1744
1759
  * @param {string} name Value name
1745
1760
  * @param {number} id Value id
1746
1761
  * @param {string} [comment] Comment, if any
1762
+ * @param {Object.<string, *>|undefined} [options] Options, if any
1747
1763
  * @returns {Enum} `this`
1748
1764
  * @throws {TypeError} If arguments are invalid
1749
1765
  * @throws {Error} If there is already a value with this name or id
1750
1766
  */
1751
- Enum.prototype.add = function add(name, id, comment) {
1767
+ Enum.prototype.add = function add(name, id, comment, options) {
1752
1768
  // utilized by the parser but not by .fromJSON
1753
1769
 
1754
1770
  if (!util.isString(name))
@@ -1773,6 +1789,12 @@ Enum.prototype.add = function add(name, id, comment) {
1773
1789
  } else
1774
1790
  this.valuesById[this.values[name] = id] = name;
1775
1791
 
1792
+ if (options) {
1793
+ if (this.valuesOptions === undefined)
1794
+ this.valuesOptions = {};
1795
+ this.valuesOptions[name] = options || null;
1796
+ }
1797
+
1776
1798
  this.comments[name] = comment || null;
1777
1799
  return this;
1778
1800
  };
@@ -1796,6 +1818,8 @@ Enum.prototype.remove = function remove(name) {
1796
1818
  delete this.valuesById[val];
1797
1819
  delete this.values[name];
1798
1820
  delete this.comments[name];
1821
+ if (this.valuesOptions)
1822
+ delete this.valuesOptions[name];
1799
1823
 
1800
1824
  return this;
1801
1825
  };
@@ -2091,6 +2115,9 @@ Field.prototype.resolve = function resolve() {
2091
2115
  this.typeDefault = null;
2092
2116
  else // instanceof Enum
2093
2117
  this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined
2118
+ } else if (this.options && this.options.proto3_optional) {
2119
+ // proto3 scalar value marked optional; should default to null
2120
+ this.typeDefault = null;
2094
2121
  }
2095
2122
 
2096
2123
  // use explicitly set default value if present
@@ -2777,7 +2804,8 @@ var ReflectionObject = require(22);
2777
2804
  ((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
2778
2805
 
2779
2806
  var Field = require(15),
2780
- util = require(33);
2807
+ util = require(33),
2808
+ OneOf = require(23);
2781
2809
 
2782
2810
  var Type, // cyclic
2783
2811
  Service,
@@ -2988,7 +3016,7 @@ Namespace.prototype.getEnum = function getEnum(name) {
2988
3016
  */
2989
3017
  Namespace.prototype.add = function add(object) {
2990
3018
 
2991
- if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace))
3019
+ if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof OneOf || object instanceof Enum || object instanceof Service || object instanceof Namespace))
2992
3020
  throw TypeError("object must be a valid nested object");
2993
3021
 
2994
3022
  if (!this.nested)
@@ -3203,7 +3231,7 @@ Namespace._configure = function(Type_, Service_, Enum_) {
3203
3231
  Enum = Enum_;
3204
3232
  };
3205
3233
 
3206
- },{"15":15,"22":22,"33":33}],22:[function(require,module,exports){
3234
+ },{"15":15,"22":22,"23":23,"33":33}],22:[function(require,module,exports){
3207
3235
  "use strict";
3208
3236
  module.exports = ReflectionObject;
3209
3237
 
@@ -4491,7 +4519,7 @@ module.exports = {};
4491
4519
  /**
4492
4520
  * Named roots.
4493
4521
  * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).
4494
- * Can also be used manually to make roots available accross modules.
4522
+ * Can also be used manually to make roots available across modules.
4495
4523
  * @name roots
4496
4524
  * @type {Object.<string,Root>}
4497
4525
  * @example
@@ -5823,6 +5851,9 @@ util.decorateEnum = function decorateEnum(object) {
5823
5851
  util.setProperty = function setProperty(dst, path, value) {
5824
5852
  function setProp(dst, path, value) {
5825
5853
  var part = path.shift();
5854
+ if (part === "__proto__") {
5855
+ return dst;
5856
+ }
5826
5857
  if (path.length > 0) {
5827
5858
  dst[part] = setProp(dst[part] || {}, path, value);
5828
5859
  } else {
@@ -6340,13 +6371,30 @@ function newError(name) {
6340
6371
  merge(this, properties);
6341
6372
  }
6342
6373
 
6343
- (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError;
6344
-
6345
- Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } });
6346
-
6347
- CustomError.prototype.toString = function toString() {
6348
- return this.name + ": " + this.message;
6349
- };
6374
+ CustomError.prototype = Object.create(Error.prototype, {
6375
+ constructor: {
6376
+ value: CustomError,
6377
+ writable: true,
6378
+ enumerable: false,
6379
+ configurable: true,
6380
+ },
6381
+ name: {
6382
+ get() { return name; },
6383
+ set: undefined,
6384
+ enumerable: false,
6385
+ // configurable: false would accurately preserve the behavior of
6386
+ // the original, but I'm guessing that was not intentional.
6387
+ // For an actual error subclass, this property would
6388
+ // be configurable.
6389
+ configurable: true,
6390
+ },
6391
+ toString: {
6392
+ value() { return this.name + ": " + this.message; },
6393
+ writable: true,
6394
+ enumerable: false,
6395
+ configurable: true,
6396
+ },
6397
+ });
6350
6398
 
6351
6399
  return CustomError;
6352
6400
  }
@@ -6710,7 +6758,7 @@ wrappers[".google.protobuf.Any"] = {
6710
6758
  if (type) {
6711
6759
  // type_url does not accept leading "."
6712
6760
  var type_url = object["@type"].charAt(0) === "." ?
6713
- object["@type"].substr(1) : object["@type"];
6761
+ object["@type"].slice(1) : object["@type"];
6714
6762
  // type_url prefix is optional, but path seperator is required
6715
6763
  if (type_url.indexOf("/") === -1) {
6716
6764
  type_url = "/" + type_url;
@@ -6748,7 +6796,7 @@ wrappers[".google.protobuf.Any"] = {
6748
6796
  if (!(message instanceof this.ctor) && message instanceof Message) {
6749
6797
  var object = message.$type.toObject(message, options);
6750
6798
  var messageName = message.$type.fullName[0] === "." ?
6751
- message.$type.fullName.substr(1) : message.$type.fullName;
6799
+ message.$type.fullName.slice(1) : message.$type.fullName;
6752
6800
  // Default to type.googleapis.com prefix if no prefix is used
6753
6801
  if (prefix === "") {
6754
6802
  prefix = googleApi;