protobufjs 6.8.8 → 6.8.9

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 (104) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +879 -879
  3. package/cli/LICENSE +33 -33
  4. package/cli/README.md +11 -11
  5. package/cli/index.d.ts +3 -3
  6. package/cli/index.js +3 -3
  7. package/cli/lib/tsd-jsdoc/LICENSE +20 -20
  8. package/cli/lib/tsd-jsdoc/README.md +23 -23
  9. package/cli/lib/tsd-jsdoc/plugin.js +21 -21
  10. package/cli/lib/tsd-jsdoc/publish.js +693 -693
  11. package/cli/lib/tsd-jsdoc.json +18 -18
  12. package/cli/package.standalone.json +31 -31
  13. package/cli/pbjs.d.ts +9 -9
  14. package/cli/pbjs.js +329 -329
  15. package/cli/pbts.d.ts +9 -9
  16. package/cli/pbts.js +197 -197
  17. package/cli/targets/json-module.js +38 -38
  18. package/cli/targets/json.js +8 -8
  19. package/cli/targets/proto.js +326 -326
  20. package/cli/targets/proto2.js +10 -10
  21. package/cli/targets/proto3.js +10 -10
  22. package/cli/targets/static-module.js +29 -29
  23. package/cli/targets/static.js +702 -702
  24. package/cli/util.js +183 -183
  25. package/cli/wrappers/amd.js +7 -7
  26. package/cli/wrappers/closure.js +7 -7
  27. package/cli/wrappers/commonjs.js +7 -7
  28. package/cli/wrappers/default.js +15 -15
  29. package/cli/wrappers/es6.js +5 -5
  30. package/dist/README.md +31 -31
  31. package/dist/light/README.md +31 -31
  32. package/dist/light/protobuf.js +6030 -6030
  33. package/dist/light/protobuf.js.map +1 -1
  34. package/dist/light/protobuf.min.js +1 -1
  35. package/dist/light/protobuf.min.js.map +1 -1
  36. package/dist/minimal/README.md +31 -31
  37. package/dist/minimal/protobuf.js +1876 -1876
  38. package/dist/minimal/protobuf.js.map +1 -1
  39. package/dist/minimal/protobuf.min.js +1 -1
  40. package/dist/minimal/protobuf.min.js.map +1 -1
  41. package/dist/protobuf.js +7595 -7595
  42. package/dist/protobuf.js.map +1 -1
  43. package/dist/protobuf.min.js +1 -1
  44. package/dist/protobuf.min.js.map +1 -1
  45. package/ext/debug/README.md +4 -4
  46. package/ext/debug/index.js +71 -71
  47. package/ext/descriptor/README.md +72 -72
  48. package/ext/descriptor/index.js +1052 -1052
  49. package/ext/descriptor/test.js +54 -54
  50. package/google/LICENSE +27 -27
  51. package/google/README.md +1 -1
  52. package/google/api/annotations.proto +10 -10
  53. package/google/protobuf/descriptor.proto +286 -286
  54. package/google/protobuf/source_context.proto +7 -7
  55. package/index.js +4 -4
  56. package/light.d.ts +2 -2
  57. package/light.js +3 -3
  58. package/minimal.d.ts +2 -2
  59. package/minimal.js +4 -4
  60. package/package-lock.json +1748 -642
  61. package/package.json +119 -122
  62. package/scripts/changelog.js +150 -150
  63. package/scripts/postinstall.js +35 -35
  64. package/src/common.js +399 -399
  65. package/src/converter.js +293 -293
  66. package/src/decoder.js +106 -106
  67. package/src/encoder.js +99 -99
  68. package/src/enum.js +181 -181
  69. package/src/field.js +371 -371
  70. package/src/index-light.js +104 -104
  71. package/src/index-minimal.js +36 -36
  72. package/src/index.js +12 -12
  73. package/src/mapfield.js +126 -126
  74. package/src/message.js +138 -138
  75. package/src/method.js +151 -151
  76. package/src/namespace.js +433 -433
  77. package/src/object.js +200 -200
  78. package/src/oneof.js +203 -203
  79. package/src/parse.js +758 -758
  80. package/src/reader.js +405 -405
  81. package/src/reader_buffer.js +44 -44
  82. package/src/root.js +351 -351
  83. package/src/roots.js +18 -18
  84. package/src/rpc/service.js +142 -142
  85. package/src/rpc.js +36 -36
  86. package/src/service.js +167 -167
  87. package/src/tokenize.js +397 -397
  88. package/src/type.js +589 -589
  89. package/src/types.js +196 -196
  90. package/src/typescript.jsdoc +15 -15
  91. package/src/util/longbits.js +200 -200
  92. package/src/util/minimal.js +414 -414
  93. package/src/util.js +178 -178
  94. package/src/verifier.js +176 -176
  95. package/src/wrappers.js +83 -83
  96. package/src/writer.js +459 -459
  97. package/src/writer_buffer.js +81 -81
  98. package/tsconfig.json +6 -6
  99. package/cli/node_modules/os-tmpdir/index.js +0 -25
  100. package/cli/node_modules/os-tmpdir/license +0 -21
  101. package/cli/node_modules/os-tmpdir/readme.md +0 -32
  102. package/cli/node_modules/tmp/LICENSE +0 -21
  103. package/cli/node_modules/tmp/README.md +0 -314
  104. package/cli/node_modules/tmp/lib/tmp.js +0 -611
package/src/util.js CHANGED
@@ -1,178 +1,178 @@
1
- "use strict";
2
-
3
- /**
4
- * Various utility functions.
5
- * @namespace
6
- */
7
- var util = module.exports = require("./util/minimal");
8
-
9
- var roots = require("./roots");
10
-
11
- var Type, // cyclic
12
- Enum;
13
-
14
- util.codegen = require("@protobufjs/codegen");
15
- util.fetch = require("@protobufjs/fetch");
16
- util.path = require("@protobufjs/path");
17
-
18
- /**
19
- * Node's fs module if available.
20
- * @type {Object.<string,*>}
21
- */
22
- util.fs = util.inquire("fs");
23
-
24
- /**
25
- * Converts an object's values to an array.
26
- * @param {Object.<string,*>} object Object to convert
27
- * @returns {Array.<*>} Converted array
28
- */
29
- util.toArray = function toArray(object) {
30
- if (object) {
31
- var keys = Object.keys(object),
32
- array = new Array(keys.length),
33
- index = 0;
34
- while (index < keys.length)
35
- array[index] = object[keys[index++]];
36
- return array;
37
- }
38
- return [];
39
- };
40
-
41
- /**
42
- * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values.
43
- * @param {Array.<*>} array Array to convert
44
- * @returns {Object.<string,*>} Converted object
45
- */
46
- util.toObject = function toObject(array) {
47
- var object = {},
48
- index = 0;
49
- while (index < array.length) {
50
- var key = array[index++],
51
- val = array[index++];
52
- if (val !== undefined)
53
- object[key] = val;
54
- }
55
- return object;
56
- };
57
-
58
- var safePropBackslashRe = /\\/g,
59
- safePropQuoteRe = /"/g;
60
-
61
- /**
62
- * Tests whether the specified name is a reserved word in JS.
63
- * @param {string} name Name to test
64
- * @returns {boolean} `true` if reserved, otherwise `false`
65
- */
66
- util.isReserved = function isReserved(name) {
67
- return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name);
68
- };
69
-
70
- /**
71
- * Returns a safe property accessor for the specified property name.
72
- * @param {string} prop Property name
73
- * @returns {string} Safe accessor
74
- */
75
- util.safeProp = function safeProp(prop) {
76
- if (!/^[$\w_]+$/.test(prop) || util.isReserved(prop))
77
- return "[\"" + prop.replace(safePropBackslashRe, "\\\\").replace(safePropQuoteRe, "\\\"") + "\"]";
78
- return "." + prop;
79
- };
80
-
81
- /**
82
- * Converts the first character of a string to upper case.
83
- * @param {string} str String to convert
84
- * @returns {string} Converted string
85
- */
86
- util.ucFirst = function ucFirst(str) {
87
- return str.charAt(0).toUpperCase() + str.substring(1);
88
- };
89
-
90
- var camelCaseRe = /_([a-z])/g;
91
-
92
- /**
93
- * Converts a string to camel case.
94
- * @param {string} str String to convert
95
- * @returns {string} Converted string
96
- */
97
- util.camelCase = function camelCase(str) {
98
- return str.substring(0, 1)
99
- + str.substring(1)
100
- .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); });
101
- };
102
-
103
- /**
104
- * Compares reflected fields by id.
105
- * @param {Field} a First field
106
- * @param {Field} b Second field
107
- * @returns {number} Comparison value
108
- */
109
- util.compareFieldsById = function compareFieldsById(a, b) {
110
- return a.id - b.id;
111
- };
112
-
113
- /**
114
- * Decorator helper for types (TypeScript).
115
- * @param {Constructor<T>} ctor Constructor function
116
- * @param {string} [typeName] Type name, defaults to the constructor's name
117
- * @returns {Type} Reflected type
118
- * @template T extends Message<T>
119
- * @property {Root} root Decorators root
120
- */
121
- util.decorateType = function decorateType(ctor, typeName) {
122
-
123
- /* istanbul ignore if */
124
- if (ctor.$type) {
125
- if (typeName && ctor.$type.name !== typeName) {
126
- util.decorateRoot.remove(ctor.$type);
127
- ctor.$type.name = typeName;
128
- util.decorateRoot.add(ctor.$type);
129
- }
130
- return ctor.$type;
131
- }
132
-
133
- /* istanbul ignore next */
134
- if (!Type)
135
- Type = require("./type");
136
-
137
- var type = new Type(typeName || ctor.name);
138
- util.decorateRoot.add(type);
139
- type.ctor = ctor; // sets up .encode, .decode etc.
140
- Object.defineProperty(ctor, "$type", { value: type, enumerable: false });
141
- Object.defineProperty(ctor.prototype, "$type", { value: type, enumerable: false });
142
- return type;
143
- };
144
-
145
- var decorateEnumIndex = 0;
146
-
147
- /**
148
- * Decorator helper for enums (TypeScript).
149
- * @param {Object} object Enum object
150
- * @returns {Enum} Reflected enum
151
- */
152
- util.decorateEnum = function decorateEnum(object) {
153
-
154
- /* istanbul ignore if */
155
- if (object.$type)
156
- return object.$type;
157
-
158
- /* istanbul ignore next */
159
- if (!Enum)
160
- Enum = require("./enum");
161
-
162
- var enm = new Enum("Enum" + decorateEnumIndex++, object);
163
- util.decorateRoot.add(enm);
164
- Object.defineProperty(object, "$type", { value: enm, enumerable: false });
165
- return enm;
166
- };
167
-
168
- /**
169
- * Decorator root (TypeScript).
170
- * @name util.decorateRoot
171
- * @type {Root}
172
- * @readonly
173
- */
174
- Object.defineProperty(util, "decorateRoot", {
175
- get: function() {
176
- return roots["decorated"] || (roots["decorated"] = new (require("./root"))());
177
- }
178
- });
1
+ "use strict";
2
+
3
+ /**
4
+ * Various utility functions.
5
+ * @namespace
6
+ */
7
+ var util = module.exports = require("./util/minimal");
8
+
9
+ var roots = require("./roots");
10
+
11
+ var Type, // cyclic
12
+ Enum;
13
+
14
+ util.codegen = require("@protobufjs/codegen");
15
+ util.fetch = require("@protobufjs/fetch");
16
+ util.path = require("@protobufjs/path");
17
+
18
+ /**
19
+ * Node's fs module if available.
20
+ * @type {Object.<string,*>}
21
+ */
22
+ util.fs = util.inquire("fs");
23
+
24
+ /**
25
+ * Converts an object's values to an array.
26
+ * @param {Object.<string,*>} object Object to convert
27
+ * @returns {Array.<*>} Converted array
28
+ */
29
+ util.toArray = function toArray(object) {
30
+ if (object) {
31
+ var keys = Object.keys(object),
32
+ array = new Array(keys.length),
33
+ index = 0;
34
+ while (index < keys.length)
35
+ array[index] = object[keys[index++]];
36
+ return array;
37
+ }
38
+ return [];
39
+ };
40
+
41
+ /**
42
+ * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values.
43
+ * @param {Array.<*>} array Array to convert
44
+ * @returns {Object.<string,*>} Converted object
45
+ */
46
+ util.toObject = function toObject(array) {
47
+ var object = {},
48
+ index = 0;
49
+ while (index < array.length) {
50
+ var key = array[index++],
51
+ val = array[index++];
52
+ if (val !== undefined)
53
+ object[key] = val;
54
+ }
55
+ return object;
56
+ };
57
+
58
+ var safePropBackslashRe = /\\/g,
59
+ safePropQuoteRe = /"/g;
60
+
61
+ /**
62
+ * Tests whether the specified name is a reserved word in JS.
63
+ * @param {string} name Name to test
64
+ * @returns {boolean} `true` if reserved, otherwise `false`
65
+ */
66
+ util.isReserved = function isReserved(name) {
67
+ return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name);
68
+ };
69
+
70
+ /**
71
+ * Returns a safe property accessor for the specified property name.
72
+ * @param {string} prop Property name
73
+ * @returns {string} Safe accessor
74
+ */
75
+ util.safeProp = function safeProp(prop) {
76
+ if (!/^[$\w_]+$/.test(prop) || util.isReserved(prop))
77
+ return "[\"" + prop.replace(safePropBackslashRe, "\\\\").replace(safePropQuoteRe, "\\\"") + "\"]";
78
+ return "." + prop;
79
+ };
80
+
81
+ /**
82
+ * Converts the first character of a string to upper case.
83
+ * @param {string} str String to convert
84
+ * @returns {string} Converted string
85
+ */
86
+ util.ucFirst = function ucFirst(str) {
87
+ return str.charAt(0).toUpperCase() + str.substring(1);
88
+ };
89
+
90
+ var camelCaseRe = /_([a-z])/g;
91
+
92
+ /**
93
+ * Converts a string to camel case.
94
+ * @param {string} str String to convert
95
+ * @returns {string} Converted string
96
+ */
97
+ util.camelCase = function camelCase(str) {
98
+ return str.substring(0, 1)
99
+ + str.substring(1)
100
+ .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); });
101
+ };
102
+
103
+ /**
104
+ * Compares reflected fields by id.
105
+ * @param {Field} a First field
106
+ * @param {Field} b Second field
107
+ * @returns {number} Comparison value
108
+ */
109
+ util.compareFieldsById = function compareFieldsById(a, b) {
110
+ return a.id - b.id;
111
+ };
112
+
113
+ /**
114
+ * Decorator helper for types (TypeScript).
115
+ * @param {Constructor<T>} ctor Constructor function
116
+ * @param {string} [typeName] Type name, defaults to the constructor's name
117
+ * @returns {Type} Reflected type
118
+ * @template T extends Message<T>
119
+ * @property {Root} root Decorators root
120
+ */
121
+ util.decorateType = function decorateType(ctor, typeName) {
122
+
123
+ /* istanbul ignore if */
124
+ if (ctor.$type) {
125
+ if (typeName && ctor.$type.name !== typeName) {
126
+ util.decorateRoot.remove(ctor.$type);
127
+ ctor.$type.name = typeName;
128
+ util.decorateRoot.add(ctor.$type);
129
+ }
130
+ return ctor.$type;
131
+ }
132
+
133
+ /* istanbul ignore next */
134
+ if (!Type)
135
+ Type = require("./type");
136
+
137
+ var type = new Type(typeName || ctor.name);
138
+ util.decorateRoot.add(type);
139
+ type.ctor = ctor; // sets up .encode, .decode etc.
140
+ Object.defineProperty(ctor, "$type", { value: type, enumerable: false });
141
+ Object.defineProperty(ctor.prototype, "$type", { value: type, enumerable: false });
142
+ return type;
143
+ };
144
+
145
+ var decorateEnumIndex = 0;
146
+
147
+ /**
148
+ * Decorator helper for enums (TypeScript).
149
+ * @param {Object} object Enum object
150
+ * @returns {Enum} Reflected enum
151
+ */
152
+ util.decorateEnum = function decorateEnum(object) {
153
+
154
+ /* istanbul ignore if */
155
+ if (object.$type)
156
+ return object.$type;
157
+
158
+ /* istanbul ignore next */
159
+ if (!Enum)
160
+ Enum = require("./enum");
161
+
162
+ var enm = new Enum("Enum" + decorateEnumIndex++, object);
163
+ util.decorateRoot.add(enm);
164
+ Object.defineProperty(object, "$type", { value: enm, enumerable: false });
165
+ return enm;
166
+ };
167
+
168
+ /**
169
+ * Decorator root (TypeScript).
170
+ * @name util.decorateRoot
171
+ * @type {Root}
172
+ * @readonly
173
+ */
174
+ Object.defineProperty(util, "decorateRoot", {
175
+ get: function() {
176
+ return roots["decorated"] || (roots["decorated"] = new (require("./root"))());
177
+ }
178
+ });