@nocobase/plugin-multi-app-manager 0.17.0-alpha.4 → 0.17.0-alpha.6

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,1467 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2009 The Closure Library Authors
4
- * Copyright 2020 Daniel Wirtz / The long.js Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * SPDX-License-Identifier: Apache-2.0
19
- */
20
-
21
- // WebAssembly optimizations to do native i64 multiplication and divide
22
- var wasm = null;
23
- try {
24
- wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
25
- 0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11
26
- ])), {}).exports;
27
- } catch (e) {
28
- // no wasm support :(
29
- }
30
-
31
- /**
32
- * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
33
- * See the from* functions below for more convenient ways of constructing Longs.
34
- * @exports Long
35
- * @class A Long class for representing a 64 bit two's-complement integer value.
36
- * @param {number} low The low (signed) 32 bits of the long
37
- * @param {number} high The high (signed) 32 bits of the long
38
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
39
- * @constructor
40
- */
41
- function Long(low, high, unsigned) {
42
-
43
- /**
44
- * The low 32 bits as a signed value.
45
- * @type {number}
46
- */
47
- this.low = low | 0;
48
-
49
- /**
50
- * The high 32 bits as a signed value.
51
- * @type {number}
52
- */
53
- this.high = high | 0;
54
-
55
- /**
56
- * Whether unsigned or not.
57
- * @type {boolean}
58
- */
59
- this.unsigned = !!unsigned;
60
- }
61
-
62
- // The internal representation of a long is the two given signed, 32-bit values.
63
- // We use 32-bit pieces because these are the size of integers on which
64
- // Javascript performs bit-operations. For operations like addition and
65
- // multiplication, we split each number into 16 bit pieces, which can easily be
66
- // multiplied within Javascript's floating-point representation without overflow
67
- // or change in sign.
68
- //
69
- // In the algorithms below, we frequently reduce the negative case to the
70
- // positive case by negating the input(s) and then post-processing the result.
71
- // Note that we must ALWAYS check specially whether those values are MIN_VALUE
72
- // (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
73
- // a positive number, it overflows back into a negative). Not handling this
74
- // case would often result in infinite recursion.
75
- //
76
- // Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
77
- // methods on which they depend.
78
-
79
- /**
80
- * An indicator used to reliably determine if an object is a Long or not.
81
- * @type {boolean}
82
- * @const
83
- * @private
84
- */
85
- Long.prototype.__isLong__;
86
-
87
- Object.defineProperty(Long.prototype, "__isLong__", { value: true });
88
-
89
- /**
90
- * @function
91
- * @param {*} obj Object
92
- * @returns {boolean}
93
- * @inner
94
- */
95
- function isLong(obj) {
96
- return (obj && obj["__isLong__"]) === true;
97
- }
98
-
99
- /**
100
- * @function
101
- * @param {*} value number
102
- * @returns {number}
103
- * @inner
104
- */
105
- function ctz32(value) {
106
- var c = Math.clz32(value & -value);
107
- return value ? 31 - c : c;
108
- }
109
-
110
- /**
111
- * Tests if the specified object is a Long.
112
- * @function
113
- * @param {*} obj Object
114
- * @returns {boolean}
115
- */
116
- Long.isLong = isLong;
117
-
118
- /**
119
- * A cache of the Long representations of small integer values.
120
- * @type {!Object}
121
- * @inner
122
- */
123
- var INT_CACHE = {};
124
-
125
- /**
126
- * A cache of the Long representations of small unsigned integer values.
127
- * @type {!Object}
128
- * @inner
129
- */
130
- var UINT_CACHE = {};
131
-
132
- /**
133
- * @param {number} value
134
- * @param {boolean=} unsigned
135
- * @returns {!Long}
136
- * @inner
137
- */
138
- function fromInt(value, unsigned) {
139
- var obj, cachedObj, cache;
140
- if (unsigned) {
141
- value >>>= 0;
142
- if (cache = (0 <= value && value < 256)) {
143
- cachedObj = UINT_CACHE[value];
144
- if (cachedObj)
145
- return cachedObj;
146
- }
147
- obj = fromBits(value, 0, true);
148
- if (cache)
149
- UINT_CACHE[value] = obj;
150
- return obj;
151
- } else {
152
- value |= 0;
153
- if (cache = (-128 <= value && value < 128)) {
154
- cachedObj = INT_CACHE[value];
155
- if (cachedObj)
156
- return cachedObj;
157
- }
158
- obj = fromBits(value, value < 0 ? -1 : 0, false);
159
- if (cache)
160
- INT_CACHE[value] = obj;
161
- return obj;
162
- }
163
- }
164
-
165
- /**
166
- * Returns a Long representing the given 32 bit integer value.
167
- * @function
168
- * @param {number} value The 32 bit integer in question
169
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
170
- * @returns {!Long} The corresponding Long value
171
- */
172
- Long.fromInt = fromInt;
173
-
174
- /**
175
- * @param {number} value
176
- * @param {boolean=} unsigned
177
- * @returns {!Long}
178
- * @inner
179
- */
180
- function fromNumber(value, unsigned) {
181
- if (isNaN(value))
182
- return unsigned ? UZERO : ZERO;
183
- if (unsigned) {
184
- if (value < 0)
185
- return UZERO;
186
- if (value >= TWO_PWR_64_DBL)
187
- return MAX_UNSIGNED_VALUE;
188
- } else {
189
- if (value <= -TWO_PWR_63_DBL)
190
- return MIN_VALUE;
191
- if (value + 1 >= TWO_PWR_63_DBL)
192
- return MAX_VALUE;
193
- }
194
- if (value < 0)
195
- return fromNumber(-value, unsigned).neg();
196
- return fromBits((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
197
- }
198
-
199
- /**
200
- * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
201
- * @function
202
- * @param {number} value The number in question
203
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
204
- * @returns {!Long} The corresponding Long value
205
- */
206
- Long.fromNumber = fromNumber;
207
-
208
- /**
209
- * @param {number} lowBits
210
- * @param {number} highBits
211
- * @param {boolean=} unsigned
212
- * @returns {!Long}
213
- * @inner
214
- */
215
- function fromBits(lowBits, highBits, unsigned) {
216
- return new Long(lowBits, highBits, unsigned);
217
- }
218
-
219
- /**
220
- * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
221
- * assumed to use 32 bits.
222
- * @function
223
- * @param {number} lowBits The low 32 bits
224
- * @param {number} highBits The high 32 bits
225
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
226
- * @returns {!Long} The corresponding Long value
227
- */
228
- Long.fromBits = fromBits;
229
-
230
- /**
231
- * @function
232
- * @param {number} base
233
- * @param {number} exponent
234
- * @returns {number}
235
- * @inner
236
- */
237
- var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
238
-
239
- /**
240
- * @param {string} str
241
- * @param {(boolean|number)=} unsigned
242
- * @param {number=} radix
243
- * @returns {!Long}
244
- * @inner
245
- */
246
- function fromString(str, unsigned, radix) {
247
- if (str.length === 0)
248
- throw Error('empty string');
249
- if (typeof unsigned === 'number') {
250
- // For goog.math.long compatibility
251
- radix = unsigned;
252
- unsigned = false;
253
- } else {
254
- unsigned = !!unsigned;
255
- }
256
- if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
257
- return unsigned ? UZERO : ZERO;
258
- radix = radix || 10;
259
- if (radix < 2 || 36 < radix)
260
- throw RangeError('radix');
261
-
262
- var p;
263
- if ((p = str.indexOf('-')) > 0)
264
- throw Error('interior hyphen');
265
- else if (p === 0) {
266
- return fromString(str.substring(1), unsigned, radix).neg();
267
- }
268
-
269
- // Do several (8) digits each time through the loop, so as to
270
- // minimize the calls to the very expensive emulated div.
271
- var radixToPower = fromNumber(pow_dbl(radix, 8));
272
-
273
- var result = ZERO;
274
- for (var i = 0; i < str.length; i += 8) {
275
- var size = Math.min(8, str.length - i),
276
- value = parseInt(str.substring(i, i + size), radix);
277
- if (size < 8) {
278
- var power = fromNumber(pow_dbl(radix, size));
279
- result = result.mul(power).add(fromNumber(value));
280
- } else {
281
- result = result.mul(radixToPower);
282
- result = result.add(fromNumber(value));
283
- }
284
- }
285
- result.unsigned = unsigned;
286
- return result;
287
- }
288
-
289
- /**
290
- * Returns a Long representation of the given string, written using the specified radix.
291
- * @function
292
- * @param {string} str The textual representation of the Long
293
- * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to signed
294
- * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
295
- * @returns {!Long} The corresponding Long value
296
- */
297
- Long.fromString = fromString;
298
-
299
- /**
300
- * @function
301
- * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
302
- * @param {boolean=} unsigned
303
- * @returns {!Long}
304
- * @inner
305
- */
306
- function fromValue(val, unsigned) {
307
- if (typeof val === 'number')
308
- return fromNumber(val, unsigned);
309
- if (typeof val === 'string')
310
- return fromString(val, unsigned);
311
- // Throws for non-objects, converts non-instanceof Long:
312
- return fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned);
313
- }
314
-
315
- /**
316
- * Converts the specified value to a Long using the appropriate from* function for its type.
317
- * @function
318
- * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
319
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
320
- * @returns {!Long}
321
- */
322
- Long.fromValue = fromValue;
323
-
324
- // NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
325
- // no runtime penalty for these.
326
-
327
- /**
328
- * @type {number}
329
- * @const
330
- * @inner
331
- */
332
- var TWO_PWR_16_DBL = 1 << 16;
333
-
334
- /**
335
- * @type {number}
336
- * @const
337
- * @inner
338
- */
339
- var TWO_PWR_24_DBL = 1 << 24;
340
-
341
- /**
342
- * @type {number}
343
- * @const
344
- * @inner
345
- */
346
- var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
347
-
348
- /**
349
- * @type {number}
350
- * @const
351
- * @inner
352
- */
353
- var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
354
-
355
- /**
356
- * @type {number}
357
- * @const
358
- * @inner
359
- */
360
- var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
361
-
362
- /**
363
- * @type {!Long}
364
- * @const
365
- * @inner
366
- */
367
- var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
368
-
369
- /**
370
- * @type {!Long}
371
- * @inner
372
- */
373
- var ZERO = fromInt(0);
374
-
375
- /**
376
- * Signed zero.
377
- * @type {!Long}
378
- */
379
- Long.ZERO = ZERO;
380
-
381
- /**
382
- * @type {!Long}
383
- * @inner
384
- */
385
- var UZERO = fromInt(0, true);
386
-
387
- /**
388
- * Unsigned zero.
389
- * @type {!Long}
390
- */
391
- Long.UZERO = UZERO;
392
-
393
- /**
394
- * @type {!Long}
395
- * @inner
396
- */
397
- var ONE = fromInt(1);
398
-
399
- /**
400
- * Signed one.
401
- * @type {!Long}
402
- */
403
- Long.ONE = ONE;
404
-
405
- /**
406
- * @type {!Long}
407
- * @inner
408
- */
409
- var UONE = fromInt(1, true);
410
-
411
- /**
412
- * Unsigned one.
413
- * @type {!Long}
414
- */
415
- Long.UONE = UONE;
416
-
417
- /**
418
- * @type {!Long}
419
- * @inner
420
- */
421
- var NEG_ONE = fromInt(-1);
422
-
423
- /**
424
- * Signed negative one.
425
- * @type {!Long}
426
- */
427
- Long.NEG_ONE = NEG_ONE;
428
-
429
- /**
430
- * @type {!Long}
431
- * @inner
432
- */
433
- var MAX_VALUE = fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
434
-
435
- /**
436
- * Maximum signed value.
437
- * @type {!Long}
438
- */
439
- Long.MAX_VALUE = MAX_VALUE;
440
-
441
- /**
442
- * @type {!Long}
443
- * @inner
444
- */
445
- var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
446
-
447
- /**
448
- * Maximum unsigned value.
449
- * @type {!Long}
450
- */
451
- Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
452
-
453
- /**
454
- * @type {!Long}
455
- * @inner
456
- */
457
- var MIN_VALUE = fromBits(0, 0x80000000 | 0, false);
458
-
459
- /**
460
- * Minimum signed value.
461
- * @type {!Long}
462
- */
463
- Long.MIN_VALUE = MIN_VALUE;
464
-
465
- /**
466
- * @alias Long.prototype
467
- * @inner
468
- */
469
- var LongPrototype = Long.prototype;
470
-
471
- /**
472
- * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
473
- * @this {!Long}
474
- * @returns {number}
475
- */
476
- LongPrototype.toInt = function toInt() {
477
- return this.unsigned ? this.low >>> 0 : this.low;
478
- };
479
-
480
- /**
481
- * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
482
- * @this {!Long}
483
- * @returns {number}
484
- */
485
- LongPrototype.toNumber = function toNumber() {
486
- if (this.unsigned)
487
- return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0);
488
- return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
489
- };
490
-
491
- /**
492
- * Converts the Long to a string written in the specified radix.
493
- * @this {!Long}
494
- * @param {number=} radix Radix (2-36), defaults to 10
495
- * @returns {string}
496
- * @override
497
- * @throws {RangeError} If `radix` is out of range
498
- */
499
- LongPrototype.toString = function toString(radix) {
500
- radix = radix || 10;
501
- if (radix < 2 || 36 < radix)
502
- throw RangeError('radix');
503
- if (this.isZero())
504
- return '0';
505
- if (this.isNegative()) { // Unsigned Longs are never negative
506
- if (this.eq(MIN_VALUE)) {
507
- // We need to change the Long value before it can be negated, so we remove
508
- // the bottom-most digit in this base and then recurse to do the rest.
509
- var radixLong = fromNumber(radix),
510
- div = this.div(radixLong),
511
- rem1 = div.mul(radixLong).sub(this);
512
- return div.toString(radix) + rem1.toInt().toString(radix);
513
- } else
514
- return '-' + this.neg().toString(radix);
515
- }
516
-
517
- // Do several (6) digits each time through the loop, so as to
518
- // minimize the calls to the very expensive emulated div.
519
- var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned),
520
- rem = this;
521
- var result = '';
522
- while (true) {
523
- var remDiv = rem.div(radixToPower),
524
- intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0,
525
- digits = intval.toString(radix);
526
- rem = remDiv;
527
- if (rem.isZero())
528
- return digits + result;
529
- else {
530
- while (digits.length < 6)
531
- digits = '0' + digits;
532
- result = '' + digits + result;
533
- }
534
- }
535
- };
536
-
537
- /**
538
- * Gets the high 32 bits as a signed integer.
539
- * @this {!Long}
540
- * @returns {number} Signed high bits
541
- */
542
- LongPrototype.getHighBits = function getHighBits() {
543
- return this.high;
544
- };
545
-
546
- /**
547
- * Gets the high 32 bits as an unsigned integer.
548
- * @this {!Long}
549
- * @returns {number} Unsigned high bits
550
- */
551
- LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
552
- return this.high >>> 0;
553
- };
554
-
555
- /**
556
- * Gets the low 32 bits as a signed integer.
557
- * @this {!Long}
558
- * @returns {number} Signed low bits
559
- */
560
- LongPrototype.getLowBits = function getLowBits() {
561
- return this.low;
562
- };
563
-
564
- /**
565
- * Gets the low 32 bits as an unsigned integer.
566
- * @this {!Long}
567
- * @returns {number} Unsigned low bits
568
- */
569
- LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
570
- return this.low >>> 0;
571
- };
572
-
573
- /**
574
- * Gets the number of bits needed to represent the absolute value of this Long.
575
- * @this {!Long}
576
- * @returns {number}
577
- */
578
- LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
579
- if (this.isNegative()) // Unsigned Longs are never negative
580
- return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
581
- var val = this.high != 0 ? this.high : this.low;
582
- for (var bit = 31; bit > 0; bit--)
583
- if ((val & (1 << bit)) != 0)
584
- break;
585
- return this.high != 0 ? bit + 33 : bit + 1;
586
- };
587
-
588
- /**
589
- * Tests if this Long's value equals zero.
590
- * @this {!Long}
591
- * @returns {boolean}
592
- */
593
- LongPrototype.isZero = function isZero() {
594
- return this.high === 0 && this.low === 0;
595
- };
596
-
597
- /**
598
- * Tests if this Long's value equals zero. This is an alias of {@link Long#isZero}.
599
- * @returns {boolean}
600
- */
601
- LongPrototype.eqz = LongPrototype.isZero;
602
-
603
- /**
604
- * Tests if this Long's value is negative.
605
- * @this {!Long}
606
- * @returns {boolean}
607
- */
608
- LongPrototype.isNegative = function isNegative() {
609
- return !this.unsigned && this.high < 0;
610
- };
611
-
612
- /**
613
- * Tests if this Long's value is positive or zero.
614
- * @this {!Long}
615
- * @returns {boolean}
616
- */
617
- LongPrototype.isPositive = function isPositive() {
618
- return this.unsigned || this.high >= 0;
619
- };
620
-
621
- /**
622
- * Tests if this Long's value is odd.
623
- * @this {!Long}
624
- * @returns {boolean}
625
- */
626
- LongPrototype.isOdd = function isOdd() {
627
- return (this.low & 1) === 1;
628
- };
629
-
630
- /**
631
- * Tests if this Long's value is even.
632
- * @this {!Long}
633
- * @returns {boolean}
634
- */
635
- LongPrototype.isEven = function isEven() {
636
- return (this.low & 1) === 0;
637
- };
638
-
639
- /**
640
- * Tests if this Long's value equals the specified's.
641
- * @this {!Long}
642
- * @param {!Long|number|string} other Other value
643
- * @returns {boolean}
644
- */
645
- LongPrototype.equals = function equals(other) {
646
- if (!isLong(other))
647
- other = fromValue(other);
648
- if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1)
649
- return false;
650
- return this.high === other.high && this.low === other.low;
651
- };
652
-
653
- /**
654
- * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.
655
- * @function
656
- * @param {!Long|number|string} other Other value
657
- * @returns {boolean}
658
- */
659
- LongPrototype.eq = LongPrototype.equals;
660
-
661
- /**
662
- * Tests if this Long's value differs from the specified's.
663
- * @this {!Long}
664
- * @param {!Long|number|string} other Other value
665
- * @returns {boolean}
666
- */
667
- LongPrototype.notEquals = function notEquals(other) {
668
- return !this.eq(/* validates */ other);
669
- };
670
-
671
- /**
672
- * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
673
- * @function
674
- * @param {!Long|number|string} other Other value
675
- * @returns {boolean}
676
- */
677
- LongPrototype.neq = LongPrototype.notEquals;
678
-
679
- /**
680
- * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
681
- * @function
682
- * @param {!Long|number|string} other Other value
683
- * @returns {boolean}
684
- */
685
- LongPrototype.ne = LongPrototype.notEquals;
686
-
687
- /**
688
- * Tests if this Long's value is less than the specified's.
689
- * @this {!Long}
690
- * @param {!Long|number|string} other Other value
691
- * @returns {boolean}
692
- */
693
- LongPrototype.lessThan = function lessThan(other) {
694
- return this.comp(/* validates */ other) < 0;
695
- };
696
-
697
- /**
698
- * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.
699
- * @function
700
- * @param {!Long|number|string} other Other value
701
- * @returns {boolean}
702
- */
703
- LongPrototype.lt = LongPrototype.lessThan;
704
-
705
- /**
706
- * Tests if this Long's value is less than or equal the specified's.
707
- * @this {!Long}
708
- * @param {!Long|number|string} other Other value
709
- * @returns {boolean}
710
- */
711
- LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {
712
- return this.comp(/* validates */ other) <= 0;
713
- };
714
-
715
- /**
716
- * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
717
- * @function
718
- * @param {!Long|number|string} other Other value
719
- * @returns {boolean}
720
- */
721
- LongPrototype.lte = LongPrototype.lessThanOrEqual;
722
-
723
- /**
724
- * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
725
- * @function
726
- * @param {!Long|number|string} other Other value
727
- * @returns {boolean}
728
- */
729
- LongPrototype.le = LongPrototype.lessThanOrEqual;
730
-
731
- /**
732
- * Tests if this Long's value is greater than the specified's.
733
- * @this {!Long}
734
- * @param {!Long|number|string} other Other value
735
- * @returns {boolean}
736
- */
737
- LongPrototype.greaterThan = function greaterThan(other) {
738
- return this.comp(/* validates */ other) > 0;
739
- };
740
-
741
- /**
742
- * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
743
- * @function
744
- * @param {!Long|number|string} other Other value
745
- * @returns {boolean}
746
- */
747
- LongPrototype.gt = LongPrototype.greaterThan;
748
-
749
- /**
750
- * Tests if this Long's value is greater than or equal the specified's.
751
- * @this {!Long}
752
- * @param {!Long|number|string} other Other value
753
- * @returns {boolean}
754
- */
755
- LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
756
- return this.comp(/* validates */ other) >= 0;
757
- };
758
-
759
- /**
760
- * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
761
- * @function
762
- * @param {!Long|number|string} other Other value
763
- * @returns {boolean}
764
- */
765
- LongPrototype.gte = LongPrototype.greaterThanOrEqual;
766
-
767
- /**
768
- * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
769
- * @function
770
- * @param {!Long|number|string} other Other value
771
- * @returns {boolean}
772
- */
773
- LongPrototype.ge = LongPrototype.greaterThanOrEqual;
774
-
775
- /**
776
- * Compares this Long's value with the specified's.
777
- * @this {!Long}
778
- * @param {!Long|number|string} other Other value
779
- * @returns {number} 0 if they are the same, 1 if the this is greater and -1
780
- * if the given one is greater
781
- */
782
- LongPrototype.compare = function compare(other) {
783
- if (!isLong(other))
784
- other = fromValue(other);
785
- if (this.eq(other))
786
- return 0;
787
- var thisNeg = this.isNegative(),
788
- otherNeg = other.isNegative();
789
- if (thisNeg && !otherNeg)
790
- return -1;
791
- if (!thisNeg && otherNeg)
792
- return 1;
793
- // At this point the sign bits are the same
794
- if (!this.unsigned)
795
- return this.sub(other).isNegative() ? -1 : 1;
796
- // Both are positive if at least one is unsigned
797
- return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
798
- };
799
-
800
- /**
801
- * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.
802
- * @function
803
- * @param {!Long|number|string} other Other value
804
- * @returns {number} 0 if they are the same, 1 if the this is greater and -1
805
- * if the given one is greater
806
- */
807
- LongPrototype.comp = LongPrototype.compare;
808
-
809
- /**
810
- * Negates this Long's value.
811
- * @this {!Long}
812
- * @returns {!Long} Negated Long
813
- */
814
- LongPrototype.negate = function negate() {
815
- if (!this.unsigned && this.eq(MIN_VALUE))
816
- return MIN_VALUE;
817
- return this.not().add(ONE);
818
- };
819
-
820
- /**
821
- * Negates this Long's value. This is an alias of {@link Long#negate}.
822
- * @function
823
- * @returns {!Long} Negated Long
824
- */
825
- LongPrototype.neg = LongPrototype.negate;
826
-
827
- /**
828
- * Returns the sum of this and the specified Long.
829
- * @this {!Long}
830
- * @param {!Long|number|string} addend Addend
831
- * @returns {!Long} Sum
832
- */
833
- LongPrototype.add = function add(addend) {
834
- if (!isLong(addend))
835
- addend = fromValue(addend);
836
-
837
- // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
838
-
839
- var a48 = this.high >>> 16;
840
- var a32 = this.high & 0xFFFF;
841
- var a16 = this.low >>> 16;
842
- var a00 = this.low & 0xFFFF;
843
-
844
- var b48 = addend.high >>> 16;
845
- var b32 = addend.high & 0xFFFF;
846
- var b16 = addend.low >>> 16;
847
- var b00 = addend.low & 0xFFFF;
848
-
849
- var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
850
- c00 += a00 + b00;
851
- c16 += c00 >>> 16;
852
- c00 &= 0xFFFF;
853
- c16 += a16 + b16;
854
- c32 += c16 >>> 16;
855
- c16 &= 0xFFFF;
856
- c32 += a32 + b32;
857
- c48 += c32 >>> 16;
858
- c32 &= 0xFFFF;
859
- c48 += a48 + b48;
860
- c48 &= 0xFFFF;
861
- return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
862
- };
863
-
864
- /**
865
- * Returns the difference of this and the specified Long.
866
- * @this {!Long}
867
- * @param {!Long|number|string} subtrahend Subtrahend
868
- * @returns {!Long} Difference
869
- */
870
- LongPrototype.subtract = function subtract(subtrahend) {
871
- if (!isLong(subtrahend))
872
- subtrahend = fromValue(subtrahend);
873
- return this.add(subtrahend.neg());
874
- };
875
-
876
- /**
877
- * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
878
- * @function
879
- * @param {!Long|number|string} subtrahend Subtrahend
880
- * @returns {!Long} Difference
881
- */
882
- LongPrototype.sub = LongPrototype.subtract;
883
-
884
- /**
885
- * Returns the product of this and the specified Long.
886
- * @this {!Long}
887
- * @param {!Long|number|string} multiplier Multiplier
888
- * @returns {!Long} Product
889
- */
890
- LongPrototype.multiply = function multiply(multiplier) {
891
- if (this.isZero())
892
- return this;
893
- if (!isLong(multiplier))
894
- multiplier = fromValue(multiplier);
895
-
896
- // use wasm support if present
897
- if (wasm) {
898
- var low = wasm["mul"](this.low,
899
- this.high,
900
- multiplier.low,
901
- multiplier.high);
902
- return fromBits(low, wasm["get_high"](), this.unsigned);
903
- }
904
-
905
- if (multiplier.isZero())
906
- return this.unsigned ? UZERO : ZERO;
907
- if (this.eq(MIN_VALUE))
908
- return multiplier.isOdd() ? MIN_VALUE : ZERO;
909
- if (multiplier.eq(MIN_VALUE))
910
- return this.isOdd() ? MIN_VALUE : ZERO;
911
-
912
- if (this.isNegative()) {
913
- if (multiplier.isNegative())
914
- return this.neg().mul(multiplier.neg());
915
- else
916
- return this.neg().mul(multiplier).neg();
917
- } else if (multiplier.isNegative())
918
- return this.mul(multiplier.neg()).neg();
919
-
920
- // If both longs are small, use float multiplication
921
- if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24))
922
- return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
923
-
924
- // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
925
- // We can skip products that would overflow.
926
-
927
- var a48 = this.high >>> 16;
928
- var a32 = this.high & 0xFFFF;
929
- var a16 = this.low >>> 16;
930
- var a00 = this.low & 0xFFFF;
931
-
932
- var b48 = multiplier.high >>> 16;
933
- var b32 = multiplier.high & 0xFFFF;
934
- var b16 = multiplier.low >>> 16;
935
- var b00 = multiplier.low & 0xFFFF;
936
-
937
- var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
938
- c00 += a00 * b00;
939
- c16 += c00 >>> 16;
940
- c00 &= 0xFFFF;
941
- c16 += a16 * b00;
942
- c32 += c16 >>> 16;
943
- c16 &= 0xFFFF;
944
- c16 += a00 * b16;
945
- c32 += c16 >>> 16;
946
- c16 &= 0xFFFF;
947
- c32 += a32 * b00;
948
- c48 += c32 >>> 16;
949
- c32 &= 0xFFFF;
950
- c32 += a16 * b16;
951
- c48 += c32 >>> 16;
952
- c32 &= 0xFFFF;
953
- c32 += a00 * b32;
954
- c48 += c32 >>> 16;
955
- c32 &= 0xFFFF;
956
- c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
957
- c48 &= 0xFFFF;
958
- return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
959
- };
960
-
961
- /**
962
- * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
963
- * @function
964
- * @param {!Long|number|string} multiplier Multiplier
965
- * @returns {!Long} Product
966
- */
967
- LongPrototype.mul = LongPrototype.multiply;
968
-
969
- /**
970
- * Returns this Long divided by the specified. The result is signed if this Long is signed or
971
- * unsigned if this Long is unsigned.
972
- * @this {!Long}
973
- * @param {!Long|number|string} divisor Divisor
974
- * @returns {!Long} Quotient
975
- */
976
- LongPrototype.divide = function divide(divisor) {
977
- if (!isLong(divisor))
978
- divisor = fromValue(divisor);
979
- if (divisor.isZero())
980
- throw Error('division by zero');
981
-
982
- // use wasm support if present
983
- if (wasm) {
984
- // guard against signed division overflow: the largest
985
- // negative number / -1 would be 1 larger than the largest
986
- // positive number, due to two's complement.
987
- if (!this.unsigned &&
988
- this.high === -0x80000000 &&
989
- divisor.low === -1 && divisor.high === -1) {
990
- // be consistent with non-wasm code path
991
- return this;
992
- }
993
- var low = (this.unsigned ? wasm["div_u"] : wasm["div_s"])(
994
- this.low,
995
- this.high,
996
- divisor.low,
997
- divisor.high
998
- );
999
- return fromBits(low, wasm["get_high"](), this.unsigned);
1000
- }
1001
-
1002
- if (this.isZero())
1003
- return this.unsigned ? UZERO : ZERO;
1004
- var approx, rem, res;
1005
- if (!this.unsigned) {
1006
- // This section is only relevant for signed longs and is derived from the
1007
- // closure library as a whole.
1008
- if (this.eq(MIN_VALUE)) {
1009
- if (divisor.eq(ONE) || divisor.eq(NEG_ONE))
1010
- return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
1011
- else if (divisor.eq(MIN_VALUE))
1012
- return ONE;
1013
- else {
1014
- // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
1015
- var halfThis = this.shr(1);
1016
- approx = halfThis.div(divisor).shl(1);
1017
- if (approx.eq(ZERO)) {
1018
- return divisor.isNegative() ? ONE : NEG_ONE;
1019
- } else {
1020
- rem = this.sub(divisor.mul(approx));
1021
- res = approx.add(rem.div(divisor));
1022
- return res;
1023
- }
1024
- }
1025
- } else if (divisor.eq(MIN_VALUE))
1026
- return this.unsigned ? UZERO : ZERO;
1027
- if (this.isNegative()) {
1028
- if (divisor.isNegative())
1029
- return this.neg().div(divisor.neg());
1030
- return this.neg().div(divisor).neg();
1031
- } else if (divisor.isNegative())
1032
- return this.div(divisor.neg()).neg();
1033
- res = ZERO;
1034
- } else {
1035
- // The algorithm below has not been made for unsigned longs. It's therefore
1036
- // required to take special care of the MSB prior to running it.
1037
- if (!divisor.unsigned)
1038
- divisor = divisor.toUnsigned();
1039
- if (divisor.gt(this))
1040
- return UZERO;
1041
- if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true
1042
- return UONE;
1043
- res = UZERO;
1044
- }
1045
-
1046
- // Repeat the following until the remainder is less than other: find a
1047
- // floating-point that approximates remainder / other *from below*, add this
1048
- // into the result, and subtract it from the remainder. It is critical that
1049
- // the approximate value is less than or equal to the real value so that the
1050
- // remainder never becomes negative.
1051
- rem = this;
1052
- while (rem.gte(divisor)) {
1053
- // Approximate the result of division. This may be a little greater or
1054
- // smaller than the actual value.
1055
- approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
1056
-
1057
- // We will tweak the approximate result by changing it in the 48-th digit or
1058
- // the smallest non-fractional digit, whichever is larger.
1059
- var log2 = Math.ceil(Math.log(approx) / Math.LN2),
1060
- delta = (log2 <= 48) ? 1 : pow_dbl(2, log2 - 48),
1061
-
1062
- // Decrease the approximation until it is smaller than the remainder. Note
1063
- // that if it is too large, the product overflows and is negative.
1064
- approxRes = fromNumber(approx),
1065
- approxRem = approxRes.mul(divisor);
1066
- while (approxRem.isNegative() || approxRem.gt(rem)) {
1067
- approx -= delta;
1068
- approxRes = fromNumber(approx, this.unsigned);
1069
- approxRem = approxRes.mul(divisor);
1070
- }
1071
-
1072
- // We know the answer can't be zero... and actually, zero would cause
1073
- // infinite recursion since we would make no progress.
1074
- if (approxRes.isZero())
1075
- approxRes = ONE;
1076
-
1077
- res = res.add(approxRes);
1078
- rem = rem.sub(approxRem);
1079
- }
1080
- return res;
1081
- };
1082
-
1083
- /**
1084
- * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.
1085
- * @function
1086
- * @param {!Long|number|string} divisor Divisor
1087
- * @returns {!Long} Quotient
1088
- */
1089
- LongPrototype.div = LongPrototype.divide;
1090
-
1091
- /**
1092
- * Returns this Long modulo the specified.
1093
- * @this {!Long}
1094
- * @param {!Long|number|string} divisor Divisor
1095
- * @returns {!Long} Remainder
1096
- */
1097
- LongPrototype.modulo = function modulo(divisor) {
1098
- if (!isLong(divisor))
1099
- divisor = fromValue(divisor);
1100
-
1101
- // use wasm support if present
1102
- if (wasm) {
1103
- var low = (this.unsigned ? wasm["rem_u"] : wasm["rem_s"])(
1104
- this.low,
1105
- this.high,
1106
- divisor.low,
1107
- divisor.high
1108
- );
1109
- return fromBits(low, wasm["get_high"](), this.unsigned);
1110
- }
1111
-
1112
- return this.sub(this.div(divisor).mul(divisor));
1113
- };
1114
-
1115
- /**
1116
- * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
1117
- * @function
1118
- * @param {!Long|number|string} divisor Divisor
1119
- * @returns {!Long} Remainder
1120
- */
1121
- LongPrototype.mod = LongPrototype.modulo;
1122
-
1123
- /**
1124
- * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
1125
- * @function
1126
- * @param {!Long|number|string} divisor Divisor
1127
- * @returns {!Long} Remainder
1128
- */
1129
- LongPrototype.rem = LongPrototype.modulo;
1130
-
1131
- /**
1132
- * Returns the bitwise NOT of this Long.
1133
- * @this {!Long}
1134
- * @returns {!Long}
1135
- */
1136
- LongPrototype.not = function not() {
1137
- return fromBits(~this.low, ~this.high, this.unsigned);
1138
- };
1139
-
1140
- /**
1141
- * Returns count leading zeros of this Long.
1142
- * @this {!Long}
1143
- * @returns {!number}
1144
- */
1145
- LongPrototype.countLeadingZeros = function countLeadingZeros() {
1146
- return this.high ? Math.clz32(this.high) : Math.clz32(this.low) + 32;
1147
- };
1148
-
1149
- /**
1150
- * Returns count leading zeros. This is an alias of {@link Long#countLeadingZeros}.
1151
- * @function
1152
- * @param {!Long}
1153
- * @returns {!number}
1154
- */
1155
- LongPrototype.clz = LongPrototype.countLeadingZeros;
1156
-
1157
- /**
1158
- * Returns count trailing zeros of this Long.
1159
- * @this {!Long}
1160
- * @returns {!number}
1161
- */
1162
- LongPrototype.countTrailingZeros = function countTrailingZeros() {
1163
- return this.low ? ctz32(this.low) : ctz32(this.high) + 32;
1164
- };
1165
-
1166
- /**
1167
- * Returns count trailing zeros. This is an alias of {@link Long#countTrailingZeros}.
1168
- * @function
1169
- * @param {!Long}
1170
- * @returns {!number}
1171
- */
1172
- LongPrototype.ctz = LongPrototype.countTrailingZeros;
1173
-
1174
- /**
1175
- * Returns the bitwise AND of this Long and the specified.
1176
- * @this {!Long}
1177
- * @param {!Long|number|string} other Other Long
1178
- * @returns {!Long}
1179
- */
1180
- LongPrototype.and = function and(other) {
1181
- if (!isLong(other))
1182
- other = fromValue(other);
1183
- return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
1184
- };
1185
-
1186
- /**
1187
- * Returns the bitwise OR of this Long and the specified.
1188
- * @this {!Long}
1189
- * @param {!Long|number|string} other Other Long
1190
- * @returns {!Long}
1191
- */
1192
- LongPrototype.or = function or(other) {
1193
- if (!isLong(other))
1194
- other = fromValue(other);
1195
- return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
1196
- };
1197
-
1198
- /**
1199
- * Returns the bitwise XOR of this Long and the given one.
1200
- * @this {!Long}
1201
- * @param {!Long|number|string} other Other Long
1202
- * @returns {!Long}
1203
- */
1204
- LongPrototype.xor = function xor(other) {
1205
- if (!isLong(other))
1206
- other = fromValue(other);
1207
- return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
1208
- };
1209
-
1210
- /**
1211
- * Returns this Long with bits shifted to the left by the given amount.
1212
- * @this {!Long}
1213
- * @param {number|!Long} numBits Number of bits
1214
- * @returns {!Long} Shifted Long
1215
- */
1216
- LongPrototype.shiftLeft = function shiftLeft(numBits) {
1217
- if (isLong(numBits))
1218
- numBits = numBits.toInt();
1219
- if ((numBits &= 63) === 0)
1220
- return this;
1221
- else if (numBits < 32)
1222
- return fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);
1223
- else
1224
- return fromBits(0, this.low << (numBits - 32), this.unsigned);
1225
- };
1226
-
1227
- /**
1228
- * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
1229
- * @function
1230
- * @param {number|!Long} numBits Number of bits
1231
- * @returns {!Long} Shifted Long
1232
- */
1233
- LongPrototype.shl = LongPrototype.shiftLeft;
1234
-
1235
- /**
1236
- * Returns this Long with bits arithmetically shifted to the right by the given amount.
1237
- * @this {!Long}
1238
- * @param {number|!Long} numBits Number of bits
1239
- * @returns {!Long} Shifted Long
1240
- */
1241
- LongPrototype.shiftRight = function shiftRight(numBits) {
1242
- if (isLong(numBits))
1243
- numBits = numBits.toInt();
1244
- if ((numBits &= 63) === 0)
1245
- return this;
1246
- else if (numBits < 32)
1247
- return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);
1248
- else
1249
- return fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);
1250
- };
1251
-
1252
- /**
1253
- * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
1254
- * @function
1255
- * @param {number|!Long} numBits Number of bits
1256
- * @returns {!Long} Shifted Long
1257
- */
1258
- LongPrototype.shr = LongPrototype.shiftRight;
1259
-
1260
- /**
1261
- * Returns this Long with bits logically shifted to the right by the given amount.
1262
- * @this {!Long}
1263
- * @param {number|!Long} numBits Number of bits
1264
- * @returns {!Long} Shifted Long
1265
- */
1266
- LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
1267
- if (isLong(numBits)) numBits = numBits.toInt();
1268
- if ((numBits &= 63) === 0) return this;
1269
- if (numBits < 32) return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >>> numBits, this.unsigned);
1270
- if (numBits === 32) return fromBits(this.high, 0, this.unsigned);
1271
- return fromBits(this.high >>> (numBits - 32), 0, this.unsigned);
1272
- };
1273
-
1274
- /**
1275
- * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
1276
- * @function
1277
- * @param {number|!Long} numBits Number of bits
1278
- * @returns {!Long} Shifted Long
1279
- */
1280
- LongPrototype.shru = LongPrototype.shiftRightUnsigned;
1281
-
1282
- /**
1283
- * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
1284
- * @function
1285
- * @param {number|!Long} numBits Number of bits
1286
- * @returns {!Long} Shifted Long
1287
- */
1288
- LongPrototype.shr_u = LongPrototype.shiftRightUnsigned;
1289
-
1290
- /**
1291
- * Returns this Long with bits rotated to the left by the given amount.
1292
- * @this {!Long}
1293
- * @param {number|!Long} numBits Number of bits
1294
- * @returns {!Long} Rotated Long
1295
- */
1296
- LongPrototype.rotateLeft = function rotateLeft(numBits) {
1297
- var b;
1298
- if (isLong(numBits)) numBits = numBits.toInt();
1299
- if ((numBits &= 63) === 0) return this;
1300
- if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
1301
- if (numBits < 32) {
1302
- b = (32 - numBits);
1303
- return fromBits(((this.low << numBits) | (this.high >>> b)), ((this.high << numBits) | (this.low >>> b)), this.unsigned);
1304
- }
1305
- numBits -= 32;
1306
- b = (32 - numBits);
1307
- return fromBits(((this.high << numBits) | (this.low >>> b)), ((this.low << numBits) | (this.high >>> b)), this.unsigned);
1308
- }
1309
- /**
1310
- * Returns this Long with bits rotated to the left by the given amount. This is an alias of {@link Long#rotateLeft}.
1311
- * @function
1312
- * @param {number|!Long} numBits Number of bits
1313
- * @returns {!Long} Rotated Long
1314
- */
1315
- LongPrototype.rotl = LongPrototype.rotateLeft;
1316
-
1317
- /**
1318
- * Returns this Long with bits rotated to the right by the given amount.
1319
- * @this {!Long}
1320
- * @param {number|!Long} numBits Number of bits
1321
- * @returns {!Long} Rotated Long
1322
- */
1323
- LongPrototype.rotateRight = function rotateRight(numBits) {
1324
- var b;
1325
- if (isLong(numBits)) numBits = numBits.toInt();
1326
- if ((numBits &= 63) === 0) return this;
1327
- if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
1328
- if (numBits < 32) {
1329
- b = (32 - numBits);
1330
- return fromBits(((this.high << b) | (this.low >>> numBits)), ((this.low << b) | (this.high >>> numBits)), this.unsigned);
1331
- }
1332
- numBits -= 32;
1333
- b = (32 - numBits);
1334
- return fromBits(((this.low << b) | (this.high >>> numBits)), ((this.high << b) | (this.low >>> numBits)), this.unsigned);
1335
- }
1336
- /**
1337
- * Returns this Long with bits rotated to the right by the given amount. This is an alias of {@link Long#rotateRight}.
1338
- * @function
1339
- * @param {number|!Long} numBits Number of bits
1340
- * @returns {!Long} Rotated Long
1341
- */
1342
- LongPrototype.rotr = LongPrototype.rotateRight;
1343
-
1344
- /**
1345
- * Converts this Long to signed.
1346
- * @this {!Long}
1347
- * @returns {!Long} Signed long
1348
- */
1349
- LongPrototype.toSigned = function toSigned() {
1350
- if (!this.unsigned)
1351
- return this;
1352
- return fromBits(this.low, this.high, false);
1353
- };
1354
-
1355
- /**
1356
- * Converts this Long to unsigned.
1357
- * @this {!Long}
1358
- * @returns {!Long} Unsigned long
1359
- */
1360
- LongPrototype.toUnsigned = function toUnsigned() {
1361
- if (this.unsigned)
1362
- return this;
1363
- return fromBits(this.low, this.high, true);
1364
- };
1365
-
1366
- /**
1367
- * Converts this Long to its byte representation.
1368
- * @param {boolean=} le Whether little or big endian, defaults to big endian
1369
- * @this {!Long}
1370
- * @returns {!Array.<number>} Byte representation
1371
- */
1372
- LongPrototype.toBytes = function toBytes(le) {
1373
- return le ? this.toBytesLE() : this.toBytesBE();
1374
- };
1375
-
1376
- /**
1377
- * Converts this Long to its little endian byte representation.
1378
- * @this {!Long}
1379
- * @returns {!Array.<number>} Little endian byte representation
1380
- */
1381
- LongPrototype.toBytesLE = function toBytesLE() {
1382
- var hi = this.high,
1383
- lo = this.low;
1384
- return [
1385
- lo & 0xff,
1386
- lo >>> 8 & 0xff,
1387
- lo >>> 16 & 0xff,
1388
- lo >>> 24,
1389
- hi & 0xff,
1390
- hi >>> 8 & 0xff,
1391
- hi >>> 16 & 0xff,
1392
- hi >>> 24
1393
- ];
1394
- };
1395
-
1396
- /**
1397
- * Converts this Long to its big endian byte representation.
1398
- * @this {!Long}
1399
- * @returns {!Array.<number>} Big endian byte representation
1400
- */
1401
- LongPrototype.toBytesBE = function toBytesBE() {
1402
- var hi = this.high,
1403
- lo = this.low;
1404
- return [
1405
- hi >>> 24,
1406
- hi >>> 16 & 0xff,
1407
- hi >>> 8 & 0xff,
1408
- hi & 0xff,
1409
- lo >>> 24,
1410
- lo >>> 16 & 0xff,
1411
- lo >>> 8 & 0xff,
1412
- lo & 0xff
1413
- ];
1414
- };
1415
-
1416
- /**
1417
- * Creates a Long from its byte representation.
1418
- * @param {!Array.<number>} bytes Byte representation
1419
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1420
- * @param {boolean=} le Whether little or big endian, defaults to big endian
1421
- * @returns {Long} The corresponding Long value
1422
- */
1423
- Long.fromBytes = function fromBytes(bytes, unsigned, le) {
1424
- return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
1425
- };
1426
-
1427
- /**
1428
- * Creates a Long from its little endian byte representation.
1429
- * @param {!Array.<number>} bytes Little endian byte representation
1430
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1431
- * @returns {Long} The corresponding Long value
1432
- */
1433
- Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
1434
- return new Long(
1435
- bytes[0] |
1436
- bytes[1] << 8 |
1437
- bytes[2] << 16 |
1438
- bytes[3] << 24,
1439
- bytes[4] |
1440
- bytes[5] << 8 |
1441
- bytes[6] << 16 |
1442
- bytes[7] << 24,
1443
- unsigned
1444
- );
1445
- };
1446
-
1447
- /**
1448
- * Creates a Long from its big endian byte representation.
1449
- * @param {!Array.<number>} bytes Big endian byte representation
1450
- * @param {boolean=} unsigned Whether unsigned or not, defaults to signed
1451
- * @returns {Long} The corresponding Long value
1452
- */
1453
- Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
1454
- return new Long(
1455
- bytes[4] << 24 |
1456
- bytes[5] << 16 |
1457
- bytes[6] << 8 |
1458
- bytes[7],
1459
- bytes[0] << 24 |
1460
- bytes[1] << 16 |
1461
- bytes[2] << 8 |
1462
- bytes[3],
1463
- unsigned
1464
- );
1465
- };
1466
-
1467
- export default Long;