@depup/apollo__protobufjs 1.2.7-depup.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.
- package/LICENSE +39 -0
- package/README.md +32 -0
- package/bin/pbjs +6 -0
- package/bin/pbts +6 -0
- package/changes.json +14 -0
- package/cli/LICENSE +33 -0
- package/cli/README.md +11 -0
- package/cli/bin/pbjs +6 -0
- package/cli/bin/pbts +6 -0
- package/cli/index.d.ts +3 -0
- package/cli/index.js +3 -0
- package/cli/lib/tsd-jsdoc/LICENSE +21 -0
- package/cli/lib/tsd-jsdoc/README.md +23 -0
- package/cli/lib/tsd-jsdoc/plugin.js +21 -0
- package/cli/lib/tsd-jsdoc/publish.js +693 -0
- package/cli/lib/tsd-jsdoc.json +18 -0
- package/cli/package.json +7 -0
- package/cli/package.standalone.json +32 -0
- package/cli/pbjs.d.ts +9 -0
- package/cli/pbjs.js +331 -0
- package/cli/pbts.d.ts +9 -0
- package/cli/pbts.js +198 -0
- package/cli/targets/json-module.js +38 -0
- package/cli/targets/json.js +8 -0
- package/cli/targets/proto.js +326 -0
- package/cli/targets/proto2.js +10 -0
- package/cli/targets/proto3.js +10 -0
- package/cli/targets/static-module.js +29 -0
- package/cli/targets/static.js +709 -0
- package/cli/util.js +183 -0
- package/cli/wrappers/amd.js +7 -0
- package/cli/wrappers/closure.js +7 -0
- package/cli/wrappers/commonjs.js +7 -0
- package/cli/wrappers/default.js +15 -0
- package/cli/wrappers/es6.js +5 -0
- package/dist/README.md +31 -0
- package/dist/light/README.md +31 -0
- package/dist/light/protobuf.js +7198 -0
- package/dist/light/protobuf.js.map +1 -0
- package/dist/light/protobuf.min.js +7 -0
- package/dist/light/protobuf.min.js.map +1 -0
- package/dist/minimal/README.md +31 -0
- package/dist/minimal/protobuf.js +2675 -0
- package/dist/minimal/protobuf.js.map +1 -0
- package/dist/minimal/protobuf.min.js +7 -0
- package/dist/minimal/protobuf.min.js.map +1 -0
- package/dist/protobuf.js +8775 -0
- package/dist/protobuf.js.map +1 -0
- package/dist/protobuf.min.js +7 -0
- package/dist/protobuf.min.js.map +1 -0
- package/ext/debug/README.md +4 -0
- package/ext/debug/index.js +71 -0
- package/ext/descriptor/README.md +72 -0
- package/ext/descriptor/index.d.ts +191 -0
- package/ext/descriptor/index.js +1052 -0
- package/ext/descriptor/test.js +54 -0
- package/google/LICENSE +27 -0
- package/google/README.md +1 -0
- package/google/api/annotations.json +83 -0
- package/google/api/annotations.proto +11 -0
- package/google/api/http.json +86 -0
- package/google/api/http.proto +31 -0
- package/google/protobuf/api.json +118 -0
- package/google/protobuf/api.proto +34 -0
- package/google/protobuf/descriptor.json +739 -0
- package/google/protobuf/descriptor.proto +286 -0
- package/google/protobuf/source_context.json +20 -0
- package/google/protobuf/source_context.proto +7 -0
- package/google/protobuf/type.json +202 -0
- package/google/protobuf/type.proto +89 -0
- package/index.d.ts +2628 -0
- package/index.js +4 -0
- package/light.d.ts +2 -0
- package/light.js +4 -0
- package/minimal.d.ts +2 -0
- package/minimal.js +4 -0
- package/package.json +147 -0
- package/scripts/postinstall.js +35 -0
- package/src/common.js +399 -0
- package/src/converter.js +304 -0
- package/src/decoder.js +106 -0
- package/src/encoder.js +119 -0
- package/src/enum.js +181 -0
- package/src/field.js +379 -0
- package/src/index-light.js +104 -0
- package/src/index-minimal.js +36 -0
- package/src/index.js +12 -0
- package/src/mapfield.js +126 -0
- package/src/message.js +139 -0
- package/src/method.js +151 -0
- package/src/namespace.js +433 -0
- package/src/object.js +200 -0
- package/src/oneof.js +203 -0
- package/src/parse.js +761 -0
- package/src/reader.js +405 -0
- package/src/reader_buffer.js +44 -0
- package/src/root.js +353 -0
- package/src/roots.js +18 -0
- package/src/rpc/service.js +142 -0
- package/src/rpc.js +36 -0
- package/src/service.js +167 -0
- package/src/tokenize.js +397 -0
- package/src/type.js +589 -0
- package/src/types.js +196 -0
- package/src/typescript.jsdoc +22 -0
- package/src/util/longbits.js +200 -0
- package/src/util/minimal.js +406 -0
- package/src/util.js +178 -0
- package/src/verifier.js +191 -0
- package/src/wrappers.js +83 -0
- package/src/writer.js +459 -0
- package/src/writer_buffer.js +81 -0
- package/tsconfig.json +7 -0
package/src/types.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Common type constants.
|
|
5
|
+
* @namespace
|
|
6
|
+
*/
|
|
7
|
+
var types = exports;
|
|
8
|
+
|
|
9
|
+
var util = require("./util");
|
|
10
|
+
|
|
11
|
+
var s = [
|
|
12
|
+
"double", // 0
|
|
13
|
+
"float", // 1
|
|
14
|
+
"int32", // 2
|
|
15
|
+
"uint32", // 3
|
|
16
|
+
"sint32", // 4
|
|
17
|
+
"fixed32", // 5
|
|
18
|
+
"sfixed32", // 6
|
|
19
|
+
"int64", // 7
|
|
20
|
+
"uint64", // 8
|
|
21
|
+
"sint64", // 9
|
|
22
|
+
"fixed64", // 10
|
|
23
|
+
"sfixed64", // 11
|
|
24
|
+
"bool", // 12
|
|
25
|
+
"string", // 13
|
|
26
|
+
"bytes" // 14
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
function bake(values, offset) {
|
|
30
|
+
var i = 0, o = {};
|
|
31
|
+
offset |= 0;
|
|
32
|
+
while (i < values.length) o[s[i + offset]] = values[i++];
|
|
33
|
+
return o;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Basic type wire types.
|
|
38
|
+
* @type {Object.<string,number>}
|
|
39
|
+
* @const
|
|
40
|
+
* @property {number} double=1 Fixed64 wire type
|
|
41
|
+
* @property {number} float=5 Fixed32 wire type
|
|
42
|
+
* @property {number} int32=0 Varint wire type
|
|
43
|
+
* @property {number} uint32=0 Varint wire type
|
|
44
|
+
* @property {number} sint32=0 Varint wire type
|
|
45
|
+
* @property {number} fixed32=5 Fixed32 wire type
|
|
46
|
+
* @property {number} sfixed32=5 Fixed32 wire type
|
|
47
|
+
* @property {number} int64=0 Varint wire type
|
|
48
|
+
* @property {number} uint64=0 Varint wire type
|
|
49
|
+
* @property {number} sint64=0 Varint wire type
|
|
50
|
+
* @property {number} fixed64=1 Fixed64 wire type
|
|
51
|
+
* @property {number} sfixed64=1 Fixed64 wire type
|
|
52
|
+
* @property {number} bool=0 Varint wire type
|
|
53
|
+
* @property {number} string=2 Ldelim wire type
|
|
54
|
+
* @property {number} bytes=2 Ldelim wire type
|
|
55
|
+
*/
|
|
56
|
+
types.basic = bake([
|
|
57
|
+
/* double */ 1,
|
|
58
|
+
/* float */ 5,
|
|
59
|
+
/* int32 */ 0,
|
|
60
|
+
/* uint32 */ 0,
|
|
61
|
+
/* sint32 */ 0,
|
|
62
|
+
/* fixed32 */ 5,
|
|
63
|
+
/* sfixed32 */ 5,
|
|
64
|
+
/* int64 */ 0,
|
|
65
|
+
/* uint64 */ 0,
|
|
66
|
+
/* sint64 */ 0,
|
|
67
|
+
/* fixed64 */ 1,
|
|
68
|
+
/* sfixed64 */ 1,
|
|
69
|
+
/* bool */ 0,
|
|
70
|
+
/* string */ 2,
|
|
71
|
+
/* bytes */ 2
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Basic type defaults.
|
|
76
|
+
* @type {Object.<string,*>}
|
|
77
|
+
* @const
|
|
78
|
+
* @property {number} double=0 Double default
|
|
79
|
+
* @property {number} float=0 Float default
|
|
80
|
+
* @property {number} int32=0 Int32 default
|
|
81
|
+
* @property {number} uint32=0 Uint32 default
|
|
82
|
+
* @property {number} sint32=0 Sint32 default
|
|
83
|
+
* @property {number} fixed32=0 Fixed32 default
|
|
84
|
+
* @property {number} sfixed32=0 Sfixed32 default
|
|
85
|
+
* @property {number} int64=0 Int64 default
|
|
86
|
+
* @property {number} uint64=0 Uint64 default
|
|
87
|
+
* @property {number} sint64=0 Sint32 default
|
|
88
|
+
* @property {number} fixed64=0 Fixed64 default
|
|
89
|
+
* @property {number} sfixed64=0 Sfixed64 default
|
|
90
|
+
* @property {boolean} bool=false Bool default
|
|
91
|
+
* @property {string} string="" String default
|
|
92
|
+
* @property {Array.<number>} bytes=Array(0) Bytes default
|
|
93
|
+
* @property {null} message=null Message default
|
|
94
|
+
*/
|
|
95
|
+
types.defaults = bake([
|
|
96
|
+
/* double */ 0,
|
|
97
|
+
/* float */ 0,
|
|
98
|
+
/* int32 */ 0,
|
|
99
|
+
/* uint32 */ 0,
|
|
100
|
+
/* sint32 */ 0,
|
|
101
|
+
/* fixed32 */ 0,
|
|
102
|
+
/* sfixed32 */ 0,
|
|
103
|
+
/* int64 */ 0,
|
|
104
|
+
/* uint64 */ 0,
|
|
105
|
+
/* sint64 */ 0,
|
|
106
|
+
/* fixed64 */ 0,
|
|
107
|
+
/* sfixed64 */ 0,
|
|
108
|
+
/* bool */ false,
|
|
109
|
+
/* string */ "",
|
|
110
|
+
/* bytes */ util.emptyArray,
|
|
111
|
+
/* message */ null
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Basic long type wire types.
|
|
116
|
+
* @type {Object.<string,number>}
|
|
117
|
+
* @const
|
|
118
|
+
* @property {number} int64=0 Varint wire type
|
|
119
|
+
* @property {number} uint64=0 Varint wire type
|
|
120
|
+
* @property {number} sint64=0 Varint wire type
|
|
121
|
+
* @property {number} fixed64=1 Fixed64 wire type
|
|
122
|
+
* @property {number} sfixed64=1 Fixed64 wire type
|
|
123
|
+
*/
|
|
124
|
+
types.long = bake([
|
|
125
|
+
/* int64 */ 0,
|
|
126
|
+
/* uint64 */ 0,
|
|
127
|
+
/* sint64 */ 0,
|
|
128
|
+
/* fixed64 */ 1,
|
|
129
|
+
/* sfixed64 */ 1
|
|
130
|
+
], 7);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Allowed types for map keys with their associated wire type.
|
|
134
|
+
* @type {Object.<string,number>}
|
|
135
|
+
* @const
|
|
136
|
+
* @property {number} int32=0 Varint wire type
|
|
137
|
+
* @property {number} uint32=0 Varint wire type
|
|
138
|
+
* @property {number} sint32=0 Varint wire type
|
|
139
|
+
* @property {number} fixed32=5 Fixed32 wire type
|
|
140
|
+
* @property {number} sfixed32=5 Fixed32 wire type
|
|
141
|
+
* @property {number} int64=0 Varint wire type
|
|
142
|
+
* @property {number} uint64=0 Varint wire type
|
|
143
|
+
* @property {number} sint64=0 Varint wire type
|
|
144
|
+
* @property {number} fixed64=1 Fixed64 wire type
|
|
145
|
+
* @property {number} sfixed64=1 Fixed64 wire type
|
|
146
|
+
* @property {number} bool=0 Varint wire type
|
|
147
|
+
* @property {number} string=2 Ldelim wire type
|
|
148
|
+
*/
|
|
149
|
+
types.mapKey = bake([
|
|
150
|
+
/* int32 */ 0,
|
|
151
|
+
/* uint32 */ 0,
|
|
152
|
+
/* sint32 */ 0,
|
|
153
|
+
/* fixed32 */ 5,
|
|
154
|
+
/* sfixed32 */ 5,
|
|
155
|
+
/* int64 */ 0,
|
|
156
|
+
/* uint64 */ 0,
|
|
157
|
+
/* sint64 */ 0,
|
|
158
|
+
/* fixed64 */ 1,
|
|
159
|
+
/* sfixed64 */ 1,
|
|
160
|
+
/* bool */ 0,
|
|
161
|
+
/* string */ 2
|
|
162
|
+
], 2);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Allowed types for packed repeated fields with their associated wire type.
|
|
166
|
+
* @type {Object.<string,number>}
|
|
167
|
+
* @const
|
|
168
|
+
* @property {number} double=1 Fixed64 wire type
|
|
169
|
+
* @property {number} float=5 Fixed32 wire type
|
|
170
|
+
* @property {number} int32=0 Varint wire type
|
|
171
|
+
* @property {number} uint32=0 Varint wire type
|
|
172
|
+
* @property {number} sint32=0 Varint wire type
|
|
173
|
+
* @property {number} fixed32=5 Fixed32 wire type
|
|
174
|
+
* @property {number} sfixed32=5 Fixed32 wire type
|
|
175
|
+
* @property {number} int64=0 Varint wire type
|
|
176
|
+
* @property {number} uint64=0 Varint wire type
|
|
177
|
+
* @property {number} sint64=0 Varint wire type
|
|
178
|
+
* @property {number} fixed64=1 Fixed64 wire type
|
|
179
|
+
* @property {number} sfixed64=1 Fixed64 wire type
|
|
180
|
+
* @property {number} bool=0 Varint wire type
|
|
181
|
+
*/
|
|
182
|
+
types.packed = bake([
|
|
183
|
+
/* double */ 1,
|
|
184
|
+
/* float */ 5,
|
|
185
|
+
/* int32 */ 0,
|
|
186
|
+
/* uint32 */ 0,
|
|
187
|
+
/* sint32 */ 0,
|
|
188
|
+
/* fixed32 */ 5,
|
|
189
|
+
/* sfixed32 */ 5,
|
|
190
|
+
/* int64 */ 0,
|
|
191
|
+
/* uint64 */ 0,
|
|
192
|
+
/* sint64 */ 0,
|
|
193
|
+
/* fixed64 */ 1,
|
|
194
|
+
/* sfixed64 */ 1,
|
|
195
|
+
/* bool */ 0
|
|
196
|
+
]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructor type.
|
|
3
|
+
* @interface Constructor
|
|
4
|
+
* @extends Function
|
|
5
|
+
* @template T
|
|
6
|
+
* @tstype new(...params: any[]): T; prototype: T;
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Properties type.
|
|
11
|
+
* @typedef Properties
|
|
12
|
+
* @template T
|
|
13
|
+
* @type {Object.<string,*>}
|
|
14
|
+
* @tstype { [P in keyof T]?: T[P] }
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Type that is convertible to array.
|
|
19
|
+
* @interface ToArray
|
|
20
|
+
* @template T
|
|
21
|
+
* @tstype toArray(): T[];
|
|
22
|
+
*/
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = LongBits;
|
|
3
|
+
|
|
4
|
+
var util = require("../util/minimal");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Constructs new long bits.
|
|
8
|
+
* @classdesc Helper class for working with the low and high bits of a 64 bit value.
|
|
9
|
+
* @memberof util
|
|
10
|
+
* @constructor
|
|
11
|
+
* @param {number} lo Low 32 bits, unsigned
|
|
12
|
+
* @param {number} hi High 32 bits, unsigned
|
|
13
|
+
*/
|
|
14
|
+
function LongBits(lo, hi) {
|
|
15
|
+
|
|
16
|
+
// note that the casts below are theoretically unnecessary as of today, but older statically
|
|
17
|
+
// generated converter code might still call the ctor with signed 32bits. kept for compat.
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Low bits.
|
|
21
|
+
* @type {number}
|
|
22
|
+
*/
|
|
23
|
+
this.lo = lo >>> 0;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* High bits.
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
this.hi = hi >>> 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Zero bits.
|
|
34
|
+
* @memberof util.LongBits
|
|
35
|
+
* @type {util.LongBits}
|
|
36
|
+
*/
|
|
37
|
+
var zero = LongBits.zero = new LongBits(0, 0);
|
|
38
|
+
|
|
39
|
+
zero.toNumber = function() { return 0; };
|
|
40
|
+
zero.zzEncode = zero.zzDecode = function() { return this; };
|
|
41
|
+
zero.length = function() { return 1; };
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Zero hash.
|
|
45
|
+
* @memberof util.LongBits
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
48
|
+
var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Constructs new long bits from the specified number.
|
|
52
|
+
* @param {number} value Value
|
|
53
|
+
* @returns {util.LongBits} Instance
|
|
54
|
+
*/
|
|
55
|
+
LongBits.fromNumber = function fromNumber(value) {
|
|
56
|
+
if (value === 0)
|
|
57
|
+
return zero;
|
|
58
|
+
var sign = value < 0;
|
|
59
|
+
if (sign)
|
|
60
|
+
value = -value;
|
|
61
|
+
var lo = value >>> 0,
|
|
62
|
+
hi = (value - lo) / 4294967296 >>> 0;
|
|
63
|
+
if (sign) {
|
|
64
|
+
hi = ~hi >>> 0;
|
|
65
|
+
lo = ~lo >>> 0;
|
|
66
|
+
if (++lo > 4294967295) {
|
|
67
|
+
lo = 0;
|
|
68
|
+
if (++hi > 4294967295)
|
|
69
|
+
hi = 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return new LongBits(lo, hi);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Constructs new long bits from a number, long or string.
|
|
77
|
+
* @param {number|string} value Value
|
|
78
|
+
* @returns {util.LongBits} Instance
|
|
79
|
+
*/
|
|
80
|
+
LongBits.from = function from(value) {
|
|
81
|
+
if (typeof value === "number")
|
|
82
|
+
return LongBits.fromNumber(value);
|
|
83
|
+
if (util.isString(value)) {
|
|
84
|
+
/* istanbul ignore else */
|
|
85
|
+
if (util.Long)
|
|
86
|
+
value = util.Long.fromString(value);
|
|
87
|
+
else
|
|
88
|
+
return LongBits.fromNumber(parseInt(value, 10));
|
|
89
|
+
}
|
|
90
|
+
return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Converts this long bits to a possibly unsafe JavaScript number.
|
|
95
|
+
* @param {boolean} [unsigned=false] Whether unsigned or not
|
|
96
|
+
* @returns {number} Possibly unsafe number
|
|
97
|
+
*/
|
|
98
|
+
LongBits.prototype.toNumber = function toNumber(unsigned) {
|
|
99
|
+
if (!unsigned && this.hi >>> 31) {
|
|
100
|
+
var lo = ~this.lo + 1 >>> 0,
|
|
101
|
+
hi = ~this.hi >>> 0;
|
|
102
|
+
if (!lo)
|
|
103
|
+
hi = hi + 1 >>> 0;
|
|
104
|
+
return -(lo + hi * 4294967296);
|
|
105
|
+
}
|
|
106
|
+
return this.lo + this.hi * 4294967296;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
* Converts this long bits to a long.
|
|
111
|
+
* @param {boolean} [unsigned=false] Whether unsigned or not
|
|
112
|
+
* @returns {Long} Long
|
|
113
|
+
*/
|
|
114
|
+
LongBits.prototype.toLong = function toLong(unsigned) {
|
|
115
|
+
return util.Long
|
|
116
|
+
? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
|
|
117
|
+
/* istanbul ignore next */
|
|
118
|
+
: { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
var charCodeAt = String.prototype.charCodeAt;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Constructs new long bits from the specified 8 characters long hash.
|
|
125
|
+
* @param {string} hash Hash
|
|
126
|
+
* @returns {util.LongBits} Bits
|
|
127
|
+
*/
|
|
128
|
+
LongBits.fromHash = function fromHash(hash) {
|
|
129
|
+
if (hash === zeroHash)
|
|
130
|
+
return zero;
|
|
131
|
+
return new LongBits(
|
|
132
|
+
( charCodeAt.call(hash, 0)
|
|
133
|
+
| charCodeAt.call(hash, 1) << 8
|
|
134
|
+
| charCodeAt.call(hash, 2) << 16
|
|
135
|
+
| charCodeAt.call(hash, 3) << 24) >>> 0
|
|
136
|
+
,
|
|
137
|
+
( charCodeAt.call(hash, 4)
|
|
138
|
+
| charCodeAt.call(hash, 5) << 8
|
|
139
|
+
| charCodeAt.call(hash, 6) << 16
|
|
140
|
+
| charCodeAt.call(hash, 7) << 24) >>> 0
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Converts this long bits to a 8 characters long hash.
|
|
146
|
+
* @returns {string} Hash
|
|
147
|
+
*/
|
|
148
|
+
LongBits.prototype.toHash = function toHash() {
|
|
149
|
+
return String.fromCharCode(
|
|
150
|
+
this.lo & 255,
|
|
151
|
+
this.lo >>> 8 & 255,
|
|
152
|
+
this.lo >>> 16 & 255,
|
|
153
|
+
this.lo >>> 24 ,
|
|
154
|
+
this.hi & 255,
|
|
155
|
+
this.hi >>> 8 & 255,
|
|
156
|
+
this.hi >>> 16 & 255,
|
|
157
|
+
this.hi >>> 24
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Zig-zag encodes this long bits.
|
|
163
|
+
* @returns {util.LongBits} `this`
|
|
164
|
+
*/
|
|
165
|
+
LongBits.prototype.zzEncode = function zzEncode() {
|
|
166
|
+
var mask = this.hi >> 31;
|
|
167
|
+
this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
|
|
168
|
+
this.lo = ( this.lo << 1 ^ mask) >>> 0;
|
|
169
|
+
return this;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Zig-zag decodes this long bits.
|
|
174
|
+
* @returns {util.LongBits} `this`
|
|
175
|
+
*/
|
|
176
|
+
LongBits.prototype.zzDecode = function zzDecode() {
|
|
177
|
+
var mask = -(this.lo & 1);
|
|
178
|
+
this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
|
|
179
|
+
this.hi = ( this.hi >>> 1 ^ mask) >>> 0;
|
|
180
|
+
return this;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Calculates the length of this longbits when encoded as a varint.
|
|
185
|
+
* @returns {number} Length
|
|
186
|
+
*/
|
|
187
|
+
LongBits.prototype.length = function length() {
|
|
188
|
+
var part0 = this.lo,
|
|
189
|
+
part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
|
|
190
|
+
part2 = this.hi >>> 24;
|
|
191
|
+
return part2 === 0
|
|
192
|
+
? part1 === 0
|
|
193
|
+
? part0 < 16384
|
|
194
|
+
? part0 < 128 ? 1 : 2
|
|
195
|
+
: part0 < 2097152 ? 3 : 4
|
|
196
|
+
: part1 < 16384
|
|
197
|
+
? part1 < 128 ? 5 : 6
|
|
198
|
+
: part1 < 2097152 ? 7 : 8
|
|
199
|
+
: part2 < 128 ? 9 : 10;
|
|
200
|
+
};
|