Update checked-in dependencies
This commit is contained in:
parent
47d5364431
commit
9dfa165835
185 changed files with 8301 additions and 3605 deletions
174
node_modules/long/README.md
generated
vendored
174
node_modules/long/README.md
generated
vendored
|
|
@ -1,13 +1,11 @@
|
|||
long.js
|
||||
=======
|
||||
# long.js
|
||||
|
||||
A Long class for representing a 64 bit two's-complement integer value derived from the [Closure Library](https://github.com/google/closure-library)
|
||||
for stand-alone use and extended with unsigned support.
|
||||
|
||||
[](https://github.com/dcodeIO/long.js/actions/workflows/test.yml) [](https://github.com/dcodeIO/long.js/actions/workflows/publish.yml) [](https://www.npmjs.com/package/long)
|
||||
|
||||
Background
|
||||
----------
|
||||
## Background
|
||||
|
||||
As of [ECMA-262 5th Edition](http://ecma262-5.com/ELS5_HTML.htm#Section_8.5), "all the positive and negative integers
|
||||
whose magnitude is no greater than 2<sup>53</sup> are representable in the Number type", which is "representing the
|
||||
|
|
@ -24,8 +22,7 @@ the Number type but first convert each such value to one of 2<sup>32</sup> integ
|
|||
In some use cases, however, it is required to be able to reliably work with and perform bitwise operations on the full
|
||||
64 bits. This is where long.js comes into play.
|
||||
|
||||
Usage
|
||||
-----
|
||||
## Usage
|
||||
|
||||
The package exports an ECMAScript module with an UMD fallback.
|
||||
|
||||
|
|
@ -45,239 +42,236 @@ Note that mixing ESM and CommonJS is not recommended as it yields different clas
|
|||
|
||||
### Usage with a CDN
|
||||
|
||||
* From GitHub via [jsDelivr](https://www.jsdelivr.com):<br />
|
||||
`https://cdn.jsdelivr.net/gh/dcodeIO/long.js@TAG/index.js` (ESM)
|
||||
* From npm via [jsDelivr](https://www.jsdelivr.com):<br />
|
||||
`https://cdn.jsdelivr.net/npm/long@VERSION/index.js` (ESM)<br />
|
||||
`https://cdn.jsdelivr.net/npm/long@VERSION/umd/index.js` (UMD)
|
||||
* From npm via [unpkg](https://unpkg.com):<br />
|
||||
`https://unpkg.com/long@VERSION/index.js` (ESM)<br />
|
||||
`https://unpkg.com/long@VERSION/umd/index.js` (UMD)
|
||||
- From GitHub via [jsDelivr](https://www.jsdelivr.com):<br />
|
||||
`https://cdn.jsdelivr.net/gh/dcodeIO/long.js@TAG/index.js` (ESM)
|
||||
- From npm via [jsDelivr](https://www.jsdelivr.com):<br />
|
||||
`https://cdn.jsdelivr.net/npm/long@VERSION/index.js` (ESM)<br />
|
||||
`https://cdn.jsdelivr.net/npm/long@VERSION/umd/index.js` (UMD)
|
||||
- From npm via [unpkg](https://unpkg.com):<br />
|
||||
`https://unpkg.com/long@VERSION/index.js` (ESM)<br />
|
||||
`https://unpkg.com/long@VERSION/umd/index.js` (UMD)
|
||||
|
||||
Replace `TAG` respectively `VERSION` with a [specific version](https://github.com/dcodeIO/long.js/releases) or omit it (not recommended in production) to use main/latest.
|
||||
Replace `TAG` respectively `VERSION` with a [specific version](https://github.com/dcodeIO/long.js/releases) or omit it (not recommended in production) to use main/latest.
|
||||
|
||||
API
|
||||
---
|
||||
## API
|
||||
|
||||
### Constructor
|
||||
|
||||
* new **Long**(low: `number`, high?: `number`, unsigned?: `boolean`)<br />
|
||||
Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers. See the from* functions below for more convenient ways of constructing Longs.
|
||||
- new **Long**(low: `number`, high?: `number`, unsigned?: `boolean`)<br />
|
||||
Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as _signed_ integers. See the from\* functions below for more convenient ways of constructing Longs.
|
||||
|
||||
### Fields
|
||||
|
||||
* Long#**low**: `number`<br />
|
||||
- Long#**low**: `number`<br />
|
||||
The low 32 bits as a signed value.
|
||||
|
||||
* Long#**high**: `number`<br />
|
||||
- Long#**high**: `number`<br />
|
||||
The high 32 bits as a signed value.
|
||||
|
||||
* Long#**unsigned**: `boolean`<br />
|
||||
- Long#**unsigned**: `boolean`<br />
|
||||
Whether unsigned or not.
|
||||
|
||||
### Constants
|
||||
|
||||
* Long.**ZERO**: `Long`<br />
|
||||
- Long.**ZERO**: `Long`<br />
|
||||
Signed zero.
|
||||
|
||||
* Long.**ONE**: `Long`<br />
|
||||
- Long.**ONE**: `Long`<br />
|
||||
Signed one.
|
||||
|
||||
* Long.**NEG_ONE**: `Long`<br />
|
||||
- Long.**NEG_ONE**: `Long`<br />
|
||||
Signed negative one.
|
||||
|
||||
* Long.**UZERO**: `Long`<br />
|
||||
- Long.**UZERO**: `Long`<br />
|
||||
Unsigned zero.
|
||||
|
||||
* Long.**UONE**: `Long`<br />
|
||||
- Long.**UONE**: `Long`<br />
|
||||
Unsigned one.
|
||||
|
||||
* Long.**MAX_VALUE**: `Long`<br />
|
||||
- Long.**MAX_VALUE**: `Long`<br />
|
||||
Maximum signed value.
|
||||
|
||||
* Long.**MIN_VALUE**: `Long`<br />
|
||||
- Long.**MIN_VALUE**: `Long`<br />
|
||||
Minimum signed value.
|
||||
|
||||
* Long.**MAX_UNSIGNED_VALUE**: `Long`<br />
|
||||
- Long.**MAX_UNSIGNED_VALUE**: `Long`<br />
|
||||
Maximum unsigned value.
|
||||
|
||||
### Utility
|
||||
|
||||
* type **LongLike**: `Long | number | bigint | string`<br />
|
||||
- type **LongLike**: `Long | number | bigint | string`<br />
|
||||
Any value or object that either is or can be converted to a Long.
|
||||
|
||||
* Long.**isLong**(obj: `any`): `boolean`<br />
|
||||
- Long.**isLong**(obj: `any`): `boolean`<br />
|
||||
Tests if the specified object is a Long.
|
||||
|
||||
* Long.**fromBits**(lowBits: `number`, highBits: `number`, unsigned?: `boolean`): `Long`<br />
|
||||
- Long.**fromBits**(lowBits: `number`, highBits: `number`, unsigned?: `boolean`): `Long`<br />
|
||||
Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits.
|
||||
|
||||
* Long.**fromBytes**(bytes: `number[]`, unsigned?: `boolean`, le?: `boolean`): `Long`<br />
|
||||
- Long.**fromBytes**(bytes: `number[]`, unsigned?: `boolean`, le?: `boolean`): `Long`<br />
|
||||
Creates a Long from its byte representation.
|
||||
|
||||
* Long.**fromBytesLE**(bytes: `number[]`, unsigned?: `boolean`): `Long`<br />
|
||||
- Long.**fromBytesLE**(bytes: `number[]`, unsigned?: `boolean`): `Long`<br />
|
||||
Creates a Long from its little endian byte representation.
|
||||
|
||||
* Long.**fromBytesBE**(bytes: `number[]`, unsigned?: `boolean`): `Long`<br />
|
||||
- Long.**fromBytesBE**(bytes: `number[]`, unsigned?: `boolean`): `Long`<br />
|
||||
Creates a Long from its big endian byte representation.
|
||||
|
||||
* Long.**fromInt**(value: `number`, unsigned?: `boolean`): `Long`<br />
|
||||
- Long.**fromInt**(value: `number`, unsigned?: `boolean`): `Long`<br />
|
||||
Returns a Long representing the given 32 bit integer value.
|
||||
|
||||
* Long.**fromNumber**(value: `number`, unsigned?: `boolean`): `Long`<br />
|
||||
- Long.**fromNumber**(value: `number`, unsigned?: `boolean`): `Long`<br />
|
||||
Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
|
||||
|
||||
* Long.**fromBigInt**(value: `bigint`, unsigned?: `boolean`): `Long`<br />
|
||||
- Long.**fromBigInt**(value: `bigint`, unsigned?: `boolean`): `Long`<br />
|
||||
Returns a Long representing the given big integer.
|
||||
|
||||
* Long.**fromString**(str: `string`, unsigned?: `boolean`, radix?: `number`)<br />
|
||||
- Long.**fromString**(str: `string`, unsigned?: `boolean`, radix?: `number`)<br />
|
||||
Long.**fromString**(str: `string`, radix: `number`)<br />
|
||||
Returns a Long representation of the given string, written using the specified radix.
|
||||
|
||||
* Long.**fromValue**(val: `LongLike`, unsigned?: `boolean`): `Long`<br />
|
||||
Converts the specified value to a Long using the appropriate from* function for its type.
|
||||
- Long.**fromValue**(val: `LongLike`, unsigned?: `boolean`): `Long`<br />
|
||||
Converts the specified value to a Long using the appropriate from\* function for its type.
|
||||
|
||||
### Methods
|
||||
|
||||
* Long#**add**(addend: `LongLike`): `Long`<br />
|
||||
- Long#**add**(addend: `LongLike`): `Long`<br />
|
||||
Returns the sum of this and the specified Long.
|
||||
|
||||
* Long#**and**(other: `LongLike`): `Long`<br />
|
||||
- Long#**and**(other: `LongLike`): `Long`<br />
|
||||
Returns the bitwise AND of this Long and the specified.
|
||||
|
||||
* Long#**compare**/**comp**(other: `LongLike`): `number`<br />
|
||||
- Long#**compare**/**comp**(other: `LongLike`): `number`<br />
|
||||
Compares this Long's value with the specified's. Returns `0` if they are the same, `1` if the this is greater and `-1` if the given one is greater.
|
||||
|
||||
* Long#**divide**/**div**(divisor: `LongLike`): `Long`<br />
|
||||
- Long#**divide**/**div**(divisor: `LongLike`): `Long`<br />
|
||||
Returns this Long divided by the specified.
|
||||
|
||||
* Long#**equals**/**eq**(other: `LongLike`): `boolean`<br />
|
||||
- Long#**equals**/**eq**(other: `LongLike`): `boolean`<br />
|
||||
Tests if this Long's value equals the specified's.
|
||||
|
||||
* Long#**getHighBits**(): `number`<br />
|
||||
- Long#**getHighBits**(): `number`<br />
|
||||
Gets the high 32 bits as a signed integer.
|
||||
|
||||
* Long#**getHighBitsUnsigned**(): `number`<br />
|
||||
- Long#**getHighBitsUnsigned**(): `number`<br />
|
||||
Gets the high 32 bits as an unsigned integer.
|
||||
|
||||
* Long#**getLowBits**(): `number`<br />
|
||||
- Long#**getLowBits**(): `number`<br />
|
||||
Gets the low 32 bits as a signed integer.
|
||||
|
||||
* Long#**getLowBitsUnsigned**(): `number`<br />
|
||||
- Long#**getLowBitsUnsigned**(): `number`<br />
|
||||
Gets the low 32 bits as an unsigned integer.
|
||||
|
||||
* Long#**getNumBitsAbs**(): `number`<br />
|
||||
- Long#**getNumBitsAbs**(): `number`<br />
|
||||
Gets the number of bits needed to represent the absolute value of this Long.
|
||||
|
||||
* Long#**greaterThan**/**gt**(other: `LongLike`): `boolean`<br />
|
||||
- Long#**greaterThan**/**gt**(other: `LongLike`): `boolean`<br />
|
||||
Tests if this Long's value is greater than the specified's.
|
||||
|
||||
* Long#**greaterThanOrEqual**/**gte**/**ge**(other: `LongLike`): `boolean`<br />
|
||||
- Long#**greaterThanOrEqual**/**gte**/**ge**(other: `LongLike`): `boolean`<br />
|
||||
Tests if this Long's value is greater than or equal the specified's.
|
||||
|
||||
* Long#**isEven**(): `boolean`<br />
|
||||
- Long#**isEven**(): `boolean`<br />
|
||||
Tests if this Long's value is even.
|
||||
|
||||
* Long#**isNegative**(): `boolean`<br />
|
||||
- Long#**isNegative**(): `boolean`<br />
|
||||
Tests if this Long's value is negative.
|
||||
|
||||
* Long#**isOdd**(): `boolean`<br />
|
||||
- Long#**isOdd**(): `boolean`<br />
|
||||
Tests if this Long's value is odd.
|
||||
|
||||
* Long#**isPositive**(): `boolean`<br />
|
||||
- Long#**isPositive**(): `boolean`<br />
|
||||
Tests if this Long's value is positive or zero.
|
||||
|
||||
* Long#**isSafeInteger**(): `boolean`<br />
|
||||
- Long#**isSafeInteger**(): `boolean`<br />
|
||||
Tests if this Long can be safely represented as a JavaScript number.
|
||||
|
||||
* Long#**isZero**/**eqz**(): `boolean`<br />
|
||||
- Long#**isZero**/**eqz**(): `boolean`<br />
|
||||
Tests if this Long's value equals zero.
|
||||
|
||||
* Long#**lessThan**/**lt**(other: `LongLike`): `boolean`<br />
|
||||
- Long#**lessThan**/**lt**(other: `LongLike`): `boolean`<br />
|
||||
Tests if this Long's value is less than the specified's.
|
||||
|
||||
* Long#**lessThanOrEqual**/**lte**/**le**(other: `LongLike`): `boolean`<br />
|
||||
- Long#**lessThanOrEqual**/**lte**/**le**(other: `LongLike`): `boolean`<br />
|
||||
Tests if this Long's value is less than or equal the specified's.
|
||||
|
||||
* Long#**modulo**/**mod**/**rem**(divisor: `LongLike`): `Long`<br />
|
||||
- Long#**modulo**/**mod**/**rem**(divisor: `LongLike`): `Long`<br />
|
||||
Returns this Long modulo the specified.
|
||||
|
||||
* Long#**multiply**/**mul**(multiplier: `LongLike`): `Long`<br />
|
||||
- Long#**multiply**/**mul**(multiplier: `LongLike`): `Long`<br />
|
||||
Returns the product of this and the specified Long.
|
||||
|
||||
* Long#**negate**/**neg**(): `Long`<br />
|
||||
- Long#**negate**/**neg**(): `Long`<br />
|
||||
Negates this Long's value.
|
||||
|
||||
* Long#**not**(): `Long`<br />
|
||||
- Long#**not**(): `Long`<br />
|
||||
Returns the bitwise NOT of this Long.
|
||||
|
||||
* Long#**countLeadingZeros**/**clz**(): `number`<br />
|
||||
- Long#**countLeadingZeros**/**clz**(): `number`<br />
|
||||
Returns count leading zeros of this Long.
|
||||
|
||||
* Long#**countTrailingZeros**/**ctz**(): `number`<br />
|
||||
- Long#**countTrailingZeros**/**ctz**(): `number`<br />
|
||||
Returns count trailing zeros of this Long.
|
||||
|
||||
* Long#**notEquals**/**neq**/**ne**(other: `LongLike`): `boolean`<br />
|
||||
- Long#**notEquals**/**neq**/**ne**(other: `LongLike`): `boolean`<br />
|
||||
Tests if this Long's value differs from the specified's.
|
||||
|
||||
* Long#**or**(other: `LongLike`): `Long`<br />
|
||||
- Long#**or**(other: `LongLike`): `Long`<br />
|
||||
Returns the bitwise OR of this Long and the specified.
|
||||
|
||||
* Long#**shiftLeft**/**shl**(numBits: `Long | number`): `Long`<br />
|
||||
- Long#**shiftLeft**/**shl**(numBits: `Long | number`): `Long`<br />
|
||||
Returns this Long with bits shifted to the left by the given amount.
|
||||
|
||||
* Long#**shiftRight**/**shr**(numBits: `Long | number`): `Long`<br />
|
||||
- Long#**shiftRight**/**shr**(numBits: `Long | number`): `Long`<br />
|
||||
Returns this Long with bits arithmetically shifted to the right by the given amount.
|
||||
|
||||
* Long#**shiftRightUnsigned**/**shru**/**shr_u**(numBits: `Long | number`): `Long`<br />
|
||||
- Long#**shiftRightUnsigned**/**shru**/**shr_u**(numBits: `Long | number`): `Long`<br />
|
||||
Returns this Long with bits logically shifted to the right by the given amount.
|
||||
|
||||
* Long#**rotateLeft**/**rotl**(numBits: `Long | number`): `Long`<br />
|
||||
- Long#**rotateLeft**/**rotl**(numBits: `Long | number`): `Long`<br />
|
||||
Returns this Long with bits rotated to the left by the given amount.
|
||||
|
||||
* Long#**rotateRight**/**rotr**(numBits: `Long | number`): `Long`<br />
|
||||
- Long#**rotateRight**/**rotr**(numBits: `Long | number`): `Long`<br />
|
||||
Returns this Long with bits rotated to the right by the given amount.
|
||||
|
||||
* Long#**subtract**/**sub**(subtrahend: `LongLike`): `Long`<br />
|
||||
- Long#**subtract**/**sub**(subtrahend: `LongLike`): `Long`<br />
|
||||
Returns the difference of this and the specified Long.
|
||||
|
||||
* Long#**toBytes**(le?: `boolean`): `number[]`<br />
|
||||
- Long#**toBytes**(le?: `boolean`): `number[]`<br />
|
||||
Converts this Long to its byte representation.
|
||||
|
||||
* Long#**toBytesLE**(): `number[]`<br />
|
||||
- Long#**toBytesLE**(): `number[]`<br />
|
||||
Converts this Long to its little endian byte representation.
|
||||
|
||||
* Long#**toBytesBE**(): `number[]`<br />
|
||||
- Long#**toBytesBE**(): `number[]`<br />
|
||||
Converts this Long to its big endian byte representation.
|
||||
|
||||
* Long#**toInt**(): `number`<br />
|
||||
- Long#**toInt**(): `number`<br />
|
||||
Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
|
||||
|
||||
* Long#**toNumber**(): `number`<br />
|
||||
- Long#**toNumber**(): `number`<br />
|
||||
Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
|
||||
|
||||
* Long#**toBigInt**(): `bigint`<br />
|
||||
- Long#**toBigInt**(): `bigint`<br />
|
||||
Converts the Long to its big integer representation.
|
||||
|
||||
* Long#**toSigned**(): `Long`<br />
|
||||
- Long#**toSigned**(): `Long`<br />
|
||||
Converts this Long to signed.
|
||||
|
||||
* Long#**toString**(radix?: `number`): `string`<br />
|
||||
- Long#**toString**(radix?: `number`): `string`<br />
|
||||
Converts the Long to a string written in the specified radix.
|
||||
|
||||
* Long#**toUnsigned**(): `Long`<br />
|
||||
- Long#**toUnsigned**(): `Long`<br />
|
||||
Converts this Long to unsigned.
|
||||
|
||||
* Long#**xor**(other: `Long | number | string`): `Long`<br />
|
||||
- Long#**xor**(other: `Long | number | string`): `Long`<br />
|
||||
Returns the bitwise XOR of this Long and the given one.
|
||||
|
||||
WebAssembly support
|
||||
-------------------
|
||||
## WebAssembly support
|
||||
|
||||
[WebAssembly](http://webassembly.org) supports 64-bit integer arithmetic out of the box, hence a [tiny WebAssembly module](./wasm.wat) is used to compute operations like multiplication, division and remainder more efficiently (slow operations like division are around twice as fast), falling back to floating point based computations in JavaScript where WebAssembly is not yet supported, e.g., in older versions of node.
|
||||
|
||||
Building
|
||||
--------
|
||||
## Building
|
||||
|
||||
Building the UMD fallback:
|
||||
|
||||
|
|
|
|||
2
node_modules/long/index.d.ts
generated
vendored
2
node_modules/long/index.d.ts
generated
vendored
|
|
@ -1,2 +1,2 @@
|
|||
import { Long } from './types.js';
|
||||
import { Long } from "./types.js";
|
||||
export default Long;
|
||||
|
|
|
|||
552
node_modules/long/index.js
generated
vendored
552
node_modules/long/index.js
generated
vendored
|
|
@ -21,69 +21,84 @@
|
|||
// WebAssembly optimizations to do native i64 multiplication and divide
|
||||
var wasm = null;
|
||||
try {
|
||||
wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
|
||||
// \0asm
|
||||
0, 97, 115, 109,
|
||||
// version 1
|
||||
1, 0, 0, 0,
|
||||
wasm = new WebAssembly.Instance(
|
||||
new WebAssembly.Module(
|
||||
new Uint8Array([
|
||||
// \0asm
|
||||
0, 97, 115, 109,
|
||||
// version 1
|
||||
1, 0, 0, 0,
|
||||
|
||||
// section "type"
|
||||
1, 13, 2,
|
||||
// 0, () => i32
|
||||
96, 0, 1, 127,
|
||||
// 1, (i32, i32, i32, i32) => i32
|
||||
96, 4, 127, 127, 127, 127, 1, 127,
|
||||
// section "type"
|
||||
1, 13, 2,
|
||||
// 0, () => i32
|
||||
96, 0, 1, 127,
|
||||
// 1, (i32, i32, i32, i32) => i32
|
||||
96, 4, 127, 127, 127, 127, 1, 127,
|
||||
|
||||
// section "function"
|
||||
3, 7, 6,
|
||||
// 0, type 0
|
||||
0,
|
||||
// 1, type 1
|
||||
1,
|
||||
// 2, type 1
|
||||
1,
|
||||
// 3, type 1
|
||||
1,
|
||||
// 4, type 1
|
||||
1,
|
||||
// 5, type 1
|
||||
1,
|
||||
// section "function"
|
||||
3, 7, 6,
|
||||
// 0, type 0
|
||||
0,
|
||||
// 1, type 1
|
||||
1,
|
||||
// 2, type 1
|
||||
1,
|
||||
// 3, type 1
|
||||
1,
|
||||
// 4, type 1
|
||||
1,
|
||||
// 5, type 1
|
||||
1,
|
||||
|
||||
// section "global"
|
||||
6, 6, 1,
|
||||
// 0, "high", mutable i32
|
||||
127, 1, 65, 0, 11,
|
||||
// section "global"
|
||||
6, 6, 1,
|
||||
// 0, "high", mutable i32
|
||||
127, 1, 65, 0, 11,
|
||||
|
||||
// section "export"
|
||||
7, 50, 6,
|
||||
// 0, "mul"
|
||||
3, 109, 117, 108, 0, 1,
|
||||
// 1, "div_s"
|
||||
5, 100, 105, 118, 95, 115, 0, 2,
|
||||
// 2, "div_u"
|
||||
5, 100, 105, 118, 95, 117, 0, 3,
|
||||
// 3, "rem_s"
|
||||
5, 114, 101, 109, 95, 115, 0, 4,
|
||||
// 4, "rem_u"
|
||||
5, 114, 101, 109, 95, 117, 0, 5,
|
||||
// 5, "get_high"
|
||||
8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0,
|
||||
// section "export"
|
||||
7, 50, 6,
|
||||
// 0, "mul"
|
||||
3, 109, 117, 108, 0, 1,
|
||||
// 1, "div_s"
|
||||
5, 100, 105, 118, 95, 115, 0, 2,
|
||||
// 2, "div_u"
|
||||
5, 100, 105, 118, 95, 117, 0, 3,
|
||||
// 3, "rem_s"
|
||||
5, 114, 101, 109, 95, 115, 0, 4,
|
||||
// 4, "rem_u"
|
||||
5, 114, 101, 109, 95, 117, 0, 5,
|
||||
// 5, "get_high"
|
||||
8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0,
|
||||
|
||||
// section "code"
|
||||
10, 191, 1, 6,
|
||||
// 0, "get_high"
|
||||
4, 0, 35, 0, 11,
|
||||
// 1, "mul"
|
||||
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,
|
||||
// 2, "div_s"
|
||||
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,
|
||||
// 3, "div_u"
|
||||
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,
|
||||
// 4, "rem_s"
|
||||
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,
|
||||
// 5, "rem_u"
|
||||
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
|
||||
])), {}).exports;
|
||||
// section "code"
|
||||
10, 191, 1, 6,
|
||||
// 0, "get_high"
|
||||
4, 0, 35, 0, 11,
|
||||
// 1, "mul"
|
||||
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,
|
||||
// 2, "div_s"
|
||||
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,
|
||||
// 3, "div_u"
|
||||
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,
|
||||
// 4, "rem_s"
|
||||
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,
|
||||
// 5, "rem_u"
|
||||
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,
|
||||
]),
|
||||
),
|
||||
{},
|
||||
).exports;
|
||||
} catch {
|
||||
// no wasm support :(
|
||||
}
|
||||
|
|
@ -99,7 +114,6 @@ try {
|
|||
* @constructor
|
||||
*/
|
||||
function Long(low, high, unsigned) {
|
||||
|
||||
/**
|
||||
* The low 32 bits as a signed value.
|
||||
* @type {number}
|
||||
|
|
@ -199,25 +213,21 @@ function fromInt(value, unsigned) {
|
|||
var obj, cachedObj, cache;
|
||||
if (unsigned) {
|
||||
value >>>= 0;
|
||||
if (cache = (0 <= value && value < 256)) {
|
||||
if ((cache = 0 <= value && value < 256)) {
|
||||
cachedObj = UINT_CACHE[value];
|
||||
if (cachedObj)
|
||||
return cachedObj;
|
||||
if (cachedObj) return cachedObj;
|
||||
}
|
||||
obj = fromBits(value, 0, true);
|
||||
if (cache)
|
||||
UINT_CACHE[value] = obj;
|
||||
if (cache) UINT_CACHE[value] = obj;
|
||||
return obj;
|
||||
} else {
|
||||
value |= 0;
|
||||
if (cache = (-128 <= value && value < 128)) {
|
||||
if ((cache = -128 <= value && value < 128)) {
|
||||
cachedObj = INT_CACHE[value];
|
||||
if (cachedObj)
|
||||
return cachedObj;
|
||||
if (cachedObj) return cachedObj;
|
||||
}
|
||||
obj = fromBits(value, value < 0 ? -1 : 0, false);
|
||||
if (cache)
|
||||
INT_CACHE[value] = obj;
|
||||
if (cache) INT_CACHE[value] = obj;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
|
@ -238,22 +248,20 @@ Long.fromInt = fromInt;
|
|||
* @inner
|
||||
*/
|
||||
function fromNumber(value, unsigned) {
|
||||
if (isNaN(value))
|
||||
return unsigned ? UZERO : ZERO;
|
||||
if (isNaN(value)) return unsigned ? UZERO : ZERO;
|
||||
if (unsigned) {
|
||||
if (value < 0)
|
||||
return UZERO;
|
||||
if (value >= TWO_PWR_64_DBL)
|
||||
return MAX_UNSIGNED_VALUE;
|
||||
if (value < 0) return UZERO;
|
||||
if (value >= TWO_PWR_64_DBL) return MAX_UNSIGNED_VALUE;
|
||||
} else {
|
||||
if (value <= -TWO_PWR_63_DBL)
|
||||
return MIN_VALUE;
|
||||
if (value + 1 >= TWO_PWR_63_DBL)
|
||||
return MAX_VALUE;
|
||||
if (value <= -TWO_PWR_63_DBL) return MIN_VALUE;
|
||||
if (value + 1 >= TWO_PWR_63_DBL) return MAX_VALUE;
|
||||
}
|
||||
if (value < 0)
|
||||
return fromNumber(-value, unsigned).neg();
|
||||
return fromBits((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
|
||||
if (value < 0) return fromNumber(-value, unsigned).neg();
|
||||
return fromBits(
|
||||
value % TWO_PWR_32_DBL | 0,
|
||||
(value / TWO_PWR_32_DBL) | 0,
|
||||
unsigned,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -304,24 +312,26 @@ var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
|
|||
* @inner
|
||||
*/
|
||||
function fromString(str, unsigned, radix) {
|
||||
if (str.length === 0)
|
||||
throw Error('empty string');
|
||||
if (typeof unsigned === 'number') {
|
||||
if (str.length === 0) throw Error("empty string");
|
||||
if (typeof unsigned === "number") {
|
||||
// For goog.math.long compatibility
|
||||
radix = unsigned;
|
||||
unsigned = false;
|
||||
} else {
|
||||
unsigned = !!unsigned;
|
||||
}
|
||||
if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
|
||||
if (
|
||||
str === "NaN" ||
|
||||
str === "Infinity" ||
|
||||
str === "+Infinity" ||
|
||||
str === "-Infinity"
|
||||
)
|
||||
return unsigned ? UZERO : ZERO;
|
||||
radix = radix || 10;
|
||||
if (radix < 2 || 36 < radix)
|
||||
throw RangeError('radix');
|
||||
if (radix < 2 || 36 < radix) throw RangeError("radix");
|
||||
|
||||
var p;
|
||||
if ((p = str.indexOf('-')) > 0)
|
||||
throw Error('interior hyphen');
|
||||
if ((p = str.indexOf("-")) > 0) throw Error("interior hyphen");
|
||||
else if (p === 0) {
|
||||
return fromString(str.substring(1), unsigned, radix).neg();
|
||||
}
|
||||
|
|
@ -364,12 +374,14 @@ Long.fromString = fromString;
|
|||
* @inner
|
||||
*/
|
||||
function fromValue(val, unsigned) {
|
||||
if (typeof val === 'number')
|
||||
return fromNumber(val, unsigned);
|
||||
if (typeof val === 'string')
|
||||
return fromString(val, unsigned);
|
||||
if (typeof val === "number") return fromNumber(val, unsigned);
|
||||
if (typeof val === "string") return fromString(val, unsigned);
|
||||
// Throws for non-objects, converts non-instanceof Long:
|
||||
return fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned);
|
||||
return fromBits(
|
||||
val.low,
|
||||
val.high,
|
||||
typeof unsigned === "boolean" ? unsigned : val.unsigned,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -490,7 +502,7 @@ Long.NEG_ONE = NEG_ONE;
|
|||
* @type {!Long}
|
||||
* @inner
|
||||
*/
|
||||
var MAX_VALUE = fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
|
||||
var MAX_VALUE = fromBits(0xffffffff | 0, 0x7fffffff | 0, false);
|
||||
|
||||
/**
|
||||
* Maximum signed value.
|
||||
|
|
@ -502,7 +514,7 @@ Long.MAX_VALUE = MAX_VALUE;
|
|||
* @type {!Long}
|
||||
* @inner
|
||||
*/
|
||||
var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
|
||||
var MAX_UNSIGNED_VALUE = fromBits(0xffffffff | 0, 0xffffffff | 0, true);
|
||||
|
||||
/**
|
||||
* Maximum unsigned value.
|
||||
|
|
@ -544,7 +556,7 @@ LongPrototype.toInt = function toInt() {
|
|||
*/
|
||||
LongPrototype.toNumber = function toNumber() {
|
||||
if (this.unsigned)
|
||||
return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0);
|
||||
return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
|
||||
return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
|
||||
};
|
||||
|
||||
|
|
@ -558,11 +570,10 @@ LongPrototype.toNumber = function toNumber() {
|
|||
*/
|
||||
LongPrototype.toString = function toString(radix) {
|
||||
radix = radix || 10;
|
||||
if (radix < 2 || 36 < radix)
|
||||
throw RangeError('radix');
|
||||
if (this.isZero())
|
||||
return '0';
|
||||
if (this.isNegative()) { // Unsigned Longs are never negative
|
||||
if (radix < 2 || 36 < radix) throw RangeError("radix");
|
||||
if (this.isZero()) return "0";
|
||||
if (this.isNegative()) {
|
||||
// Unsigned Longs are never negative
|
||||
if (this.eq(MIN_VALUE)) {
|
||||
// We need to change the Long value before it can be negated, so we remove
|
||||
// the bottom-most digit in this base and then recurse to do the rest.
|
||||
|
|
@ -570,26 +581,23 @@ LongPrototype.toString = function toString(radix) {
|
|||
div = this.div(radixLong),
|
||||
rem1 = div.mul(radixLong).sub(this);
|
||||
return div.toString(radix) + rem1.toInt().toString(radix);
|
||||
} else
|
||||
return '-' + this.neg().toString(radix);
|
||||
} else return "-" + this.neg().toString(radix);
|
||||
}
|
||||
|
||||
// Do several (6) digits each time through the loop, so as to
|
||||
// minimize the calls to the very expensive emulated div.
|
||||
var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned),
|
||||
rem = this;
|
||||
var result = '';
|
||||
var result = "";
|
||||
while (true) {
|
||||
var remDiv = rem.div(radixToPower),
|
||||
intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0,
|
||||
digits = intval.toString(radix);
|
||||
rem = remDiv;
|
||||
if (rem.isZero())
|
||||
return digits + result;
|
||||
if (rem.isZero()) return digits + result;
|
||||
else {
|
||||
while (digits.length < 6)
|
||||
digits = '0' + digits;
|
||||
result = '' + digits + result;
|
||||
while (digits.length < 6) digits = "0" + digits;
|
||||
result = "" + digits + result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -636,12 +644,11 @@ LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
|
|||
* @returns {number}
|
||||
*/
|
||||
LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
|
||||
if (this.isNegative()) // Unsigned Longs are never negative
|
||||
if (this.isNegative())
|
||||
// Unsigned Longs are never negative
|
||||
return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
|
||||
var val = this.high != 0 ? this.high : this.low;
|
||||
for (var bit = 31; bit > 0; bit--)
|
||||
if ((val & (1 << bit)) != 0)
|
||||
break;
|
||||
for (var bit = 31; bit > 0; bit--) if ((val & (1 << bit)) != 0) break;
|
||||
return this.high != 0 ? bit + 33 : bit + 1;
|
||||
};
|
||||
|
||||
|
|
@ -719,9 +726,12 @@ LongPrototype.isEven = function isEven() {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
LongPrototype.equals = function equals(other) {
|
||||
if (!isLong(other))
|
||||
other = fromValue(other);
|
||||
if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1)
|
||||
if (!isLong(other)) other = fromValue(other);
|
||||
if (
|
||||
this.unsigned !== other.unsigned &&
|
||||
this.high >>> 31 === 1 &&
|
||||
other.high >>> 31 === 1
|
||||
)
|
||||
return false;
|
||||
return this.high === other.high && this.low === other.low;
|
||||
};
|
||||
|
|
@ -856,21 +866,19 @@ LongPrototype.ge = LongPrototype.greaterThanOrEqual;
|
|||
* if the given one is greater
|
||||
*/
|
||||
LongPrototype.compare = function compare(other) {
|
||||
if (!isLong(other))
|
||||
other = fromValue(other);
|
||||
if (this.eq(other))
|
||||
return 0;
|
||||
if (!isLong(other)) other = fromValue(other);
|
||||
if (this.eq(other)) return 0;
|
||||
var thisNeg = this.isNegative(),
|
||||
otherNeg = other.isNegative();
|
||||
if (thisNeg && !otherNeg)
|
||||
return -1;
|
||||
if (!thisNeg && otherNeg)
|
||||
return 1;
|
||||
if (thisNeg && !otherNeg) return -1;
|
||||
if (!thisNeg && otherNeg) return 1;
|
||||
// At this point the sign bits are the same
|
||||
if (!this.unsigned)
|
||||
return this.sub(other).isNegative() ? -1 : 1;
|
||||
if (!this.unsigned) return this.sub(other).isNegative() ? -1 : 1;
|
||||
// Both are positive if at least one is unsigned
|
||||
return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
|
||||
return other.high >>> 0 > this.high >>> 0 ||
|
||||
(other.high === this.high && other.low >>> 0 > this.low >>> 0)
|
||||
? -1
|
||||
: 1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -888,8 +896,7 @@ LongPrototype.comp = LongPrototype.compare;
|
|||
* @returns {!Long} Negated Long
|
||||
*/
|
||||
LongPrototype.negate = function negate() {
|
||||
if (!this.unsigned && this.eq(MIN_VALUE))
|
||||
return MIN_VALUE;
|
||||
if (!this.unsigned && this.eq(MIN_VALUE)) return MIN_VALUE;
|
||||
return this.not().add(ONE);
|
||||
};
|
||||
|
||||
|
|
@ -907,33 +914,35 @@ LongPrototype.neg = LongPrototype.negate;
|
|||
* @returns {!Long} Sum
|
||||
*/
|
||||
LongPrototype.add = function add(addend) {
|
||||
if (!isLong(addend))
|
||||
addend = fromValue(addend);
|
||||
if (!isLong(addend)) addend = fromValue(addend);
|
||||
|
||||
// Divide each number into 4 chunks of 16 bits, and then sum the chunks.
|
||||
|
||||
var a48 = this.high >>> 16;
|
||||
var a32 = this.high & 0xFFFF;
|
||||
var a32 = this.high & 0xffff;
|
||||
var a16 = this.low >>> 16;
|
||||
var a00 = this.low & 0xFFFF;
|
||||
var a00 = this.low & 0xffff;
|
||||
|
||||
var b48 = addend.high >>> 16;
|
||||
var b32 = addend.high & 0xFFFF;
|
||||
var b32 = addend.high & 0xffff;
|
||||
var b16 = addend.low >>> 16;
|
||||
var b00 = addend.low & 0xFFFF;
|
||||
var b00 = addend.low & 0xffff;
|
||||
|
||||
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
||||
var c48 = 0,
|
||||
c32 = 0,
|
||||
c16 = 0,
|
||||
c00 = 0;
|
||||
c00 += a00 + b00;
|
||||
c16 += c00 >>> 16;
|
||||
c00 &= 0xFFFF;
|
||||
c00 &= 0xffff;
|
||||
c16 += a16 + b16;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c16 &= 0xffff;
|
||||
c32 += a32 + b32;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 &= 0xffff;
|
||||
c48 += a48 + b48;
|
||||
c48 &= 0xFFFF;
|
||||
c48 &= 0xffff;
|
||||
return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
|
||||
};
|
||||
|
||||
|
|
@ -944,8 +953,7 @@ LongPrototype.add = function add(addend) {
|
|||
* @returns {!Long} Difference
|
||||
*/
|
||||
LongPrototype.subtract = function subtract(subtrahend) {
|
||||
if (!isLong(subtrahend))
|
||||
subtrahend = fromValue(subtrahend);
|
||||
if (!isLong(subtrahend)) subtrahend = fromValue(subtrahend);
|
||||
return this.add(subtrahend.neg());
|
||||
};
|
||||
|
||||
|
|
@ -964,34 +972,23 @@ LongPrototype.sub = LongPrototype.subtract;
|
|||
* @returns {!Long} Product
|
||||
*/
|
||||
LongPrototype.multiply = function multiply(multiplier) {
|
||||
if (this.isZero())
|
||||
return this;
|
||||
if (!isLong(multiplier))
|
||||
multiplier = fromValue(multiplier);
|
||||
if (this.isZero()) return this;
|
||||
if (!isLong(multiplier)) multiplier = fromValue(multiplier);
|
||||
|
||||
// use wasm support if present
|
||||
if (wasm) {
|
||||
var low = wasm["mul"](this.low,
|
||||
this.high,
|
||||
multiplier.low,
|
||||
multiplier.high);
|
||||
var low = wasm["mul"](this.low, this.high, multiplier.low, multiplier.high);
|
||||
return fromBits(low, wasm["get_high"](), this.unsigned);
|
||||
}
|
||||
|
||||
if (multiplier.isZero())
|
||||
return this.unsigned ? UZERO : ZERO;
|
||||
if (this.eq(MIN_VALUE))
|
||||
return multiplier.isOdd() ? MIN_VALUE : ZERO;
|
||||
if (multiplier.eq(MIN_VALUE))
|
||||
return this.isOdd() ? MIN_VALUE : ZERO;
|
||||
if (multiplier.isZero()) return this.unsigned ? UZERO : ZERO;
|
||||
if (this.eq(MIN_VALUE)) return multiplier.isOdd() ? MIN_VALUE : ZERO;
|
||||
if (multiplier.eq(MIN_VALUE)) return this.isOdd() ? MIN_VALUE : ZERO;
|
||||
|
||||
if (this.isNegative()) {
|
||||
if (multiplier.isNegative())
|
||||
return this.neg().mul(multiplier.neg());
|
||||
else
|
||||
return this.neg().mul(multiplier).neg();
|
||||
} else if (multiplier.isNegative())
|
||||
return this.mul(multiplier.neg()).neg();
|
||||
if (multiplier.isNegative()) return this.neg().mul(multiplier.neg());
|
||||
else return this.neg().mul(multiplier).neg();
|
||||
} else if (multiplier.isNegative()) return this.mul(multiplier.neg()).neg();
|
||||
|
||||
// If both longs are small, use float multiplication
|
||||
if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24))
|
||||
|
|
@ -1001,36 +998,39 @@ LongPrototype.multiply = function multiply(multiplier) {
|
|||
// We can skip products that would overflow.
|
||||
|
||||
var a48 = this.high >>> 16;
|
||||
var a32 = this.high & 0xFFFF;
|
||||
var a32 = this.high & 0xffff;
|
||||
var a16 = this.low >>> 16;
|
||||
var a00 = this.low & 0xFFFF;
|
||||
var a00 = this.low & 0xffff;
|
||||
|
||||
var b48 = multiplier.high >>> 16;
|
||||
var b32 = multiplier.high & 0xFFFF;
|
||||
var b32 = multiplier.high & 0xffff;
|
||||
var b16 = multiplier.low >>> 16;
|
||||
var b00 = multiplier.low & 0xFFFF;
|
||||
var b00 = multiplier.low & 0xffff;
|
||||
|
||||
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
||||
var c48 = 0,
|
||||
c32 = 0,
|
||||
c16 = 0,
|
||||
c00 = 0;
|
||||
c00 += a00 * b00;
|
||||
c16 += c00 >>> 16;
|
||||
c00 &= 0xFFFF;
|
||||
c00 &= 0xffff;
|
||||
c16 += a16 * b00;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c16 &= 0xffff;
|
||||
c16 += a00 * b16;
|
||||
c32 += c16 >>> 16;
|
||||
c16 &= 0xFFFF;
|
||||
c16 &= 0xffff;
|
||||
c32 += a32 * b00;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 &= 0xffff;
|
||||
c32 += a16 * b16;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 &= 0xffff;
|
||||
c32 += a00 * b32;
|
||||
c48 += c32 >>> 16;
|
||||
c32 &= 0xFFFF;
|
||||
c32 &= 0xffff;
|
||||
c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
|
||||
c48 &= 0xFFFF;
|
||||
c48 &= 0xffff;
|
||||
return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
|
||||
};
|
||||
|
||||
|
|
@ -1050,19 +1050,20 @@ LongPrototype.mul = LongPrototype.multiply;
|
|||
* @returns {!Long} Quotient
|
||||
*/
|
||||
LongPrototype.divide = function divide(divisor) {
|
||||
if (!isLong(divisor))
|
||||
divisor = fromValue(divisor);
|
||||
if (divisor.isZero())
|
||||
throw Error('division by zero');
|
||||
if (!isLong(divisor)) divisor = fromValue(divisor);
|
||||
if (divisor.isZero()) throw Error("division by zero");
|
||||
|
||||
// use wasm support if present
|
||||
if (wasm) {
|
||||
// guard against signed division overflow: the largest
|
||||
// negative number / -1 would be 1 larger than the largest
|
||||
// positive number, due to two's complement.
|
||||
if (!this.unsigned &&
|
||||
if (
|
||||
!this.unsigned &&
|
||||
this.high === -0x80000000 &&
|
||||
divisor.low === -1 && divisor.high === -1) {
|
||||
divisor.low === -1 &&
|
||||
divisor.high === -1
|
||||
) {
|
||||
// be consistent with non-wasm code path
|
||||
return this;
|
||||
}
|
||||
|
|
@ -1070,22 +1071,20 @@ LongPrototype.divide = function divide(divisor) {
|
|||
this.low,
|
||||
this.high,
|
||||
divisor.low,
|
||||
divisor.high
|
||||
divisor.high,
|
||||
);
|
||||
return fromBits(low, wasm["get_high"](), this.unsigned);
|
||||
}
|
||||
|
||||
if (this.isZero())
|
||||
return this.unsigned ? UZERO : ZERO;
|
||||
if (this.isZero()) return this.unsigned ? UZERO : ZERO;
|
||||
var approx, rem, res;
|
||||
if (!this.unsigned) {
|
||||
// This section is only relevant for signed longs and is derived from the
|
||||
// closure library as a whole.
|
||||
if (this.eq(MIN_VALUE)) {
|
||||
if (divisor.eq(ONE) || divisor.eq(NEG_ONE))
|
||||
return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
|
||||
else if (divisor.eq(MIN_VALUE))
|
||||
return ONE;
|
||||
return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
|
||||
else if (divisor.eq(MIN_VALUE)) return ONE;
|
||||
else {
|
||||
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
|
||||
var halfThis = this.shr(1);
|
||||
|
|
@ -1098,23 +1097,19 @@ LongPrototype.divide = function divide(divisor) {
|
|||
return res;
|
||||
}
|
||||
}
|
||||
} else if (divisor.eq(MIN_VALUE))
|
||||
return this.unsigned ? UZERO : ZERO;
|
||||
} else if (divisor.eq(MIN_VALUE)) return this.unsigned ? UZERO : ZERO;
|
||||
if (this.isNegative()) {
|
||||
if (divisor.isNegative())
|
||||
return this.neg().div(divisor.neg());
|
||||
if (divisor.isNegative()) return this.neg().div(divisor.neg());
|
||||
return this.neg().div(divisor).neg();
|
||||
} else if (divisor.isNegative())
|
||||
return this.div(divisor.neg()).neg();
|
||||
} else if (divisor.isNegative()) return this.div(divisor.neg()).neg();
|
||||
res = ZERO;
|
||||
} else {
|
||||
// The algorithm below has not been made for unsigned longs. It's therefore
|
||||
// required to take special care of the MSB prior to running it.
|
||||
if (!divisor.unsigned)
|
||||
divisor = divisor.toUnsigned();
|
||||
if (divisor.gt(this))
|
||||
return UZERO;
|
||||
if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true
|
||||
if (!divisor.unsigned) divisor = divisor.toUnsigned();
|
||||
if (divisor.gt(this)) return UZERO;
|
||||
if (divisor.gt(this.shru(1)))
|
||||
// 15 >>> 1 = 7 ; with divisor = 8 ; true
|
||||
return UONE;
|
||||
res = UZERO;
|
||||
}
|
||||
|
|
@ -1133,8 +1128,7 @@ LongPrototype.divide = function divide(divisor) {
|
|||
// We will tweak the approximate result by changing it in the 48-th digit or
|
||||
// the smallest non-fractional digit, whichever is larger.
|
||||
var log2 = Math.ceil(Math.log(approx) / Math.LN2),
|
||||
delta = (log2 <= 48) ? 1 : pow_dbl(2, log2 - 48),
|
||||
|
||||
delta = log2 <= 48 ? 1 : pow_dbl(2, log2 - 48),
|
||||
// Decrease the approximation until it is smaller than the remainder. Note
|
||||
// that if it is too large, the product overflows and is negative.
|
||||
approxRes = fromNumber(approx),
|
||||
|
|
@ -1147,8 +1141,7 @@ LongPrototype.divide = function divide(divisor) {
|
|||
|
||||
// We know the answer can't be zero... and actually, zero would cause
|
||||
// infinite recursion since we would make no progress.
|
||||
if (approxRes.isZero())
|
||||
approxRes = ONE;
|
||||
if (approxRes.isZero()) approxRes = ONE;
|
||||
|
||||
res = res.add(approxRes);
|
||||
rem = rem.sub(approxRem);
|
||||
|
|
@ -1171,8 +1164,7 @@ LongPrototype.div = LongPrototype.divide;
|
|||
* @returns {!Long} Remainder
|
||||
*/
|
||||
LongPrototype.modulo = function modulo(divisor) {
|
||||
if (!isLong(divisor))
|
||||
divisor = fromValue(divisor);
|
||||
if (!isLong(divisor)) divisor = fromValue(divisor);
|
||||
|
||||
// use wasm support if present
|
||||
if (wasm) {
|
||||
|
|
@ -1180,7 +1172,7 @@ LongPrototype.modulo = function modulo(divisor) {
|
|||
this.low,
|
||||
this.high,
|
||||
divisor.low,
|
||||
divisor.high
|
||||
divisor.high,
|
||||
);
|
||||
return fromBits(low, wasm["get_high"](), this.unsigned);
|
||||
}
|
||||
|
|
@ -1254,8 +1246,7 @@ LongPrototype.ctz = LongPrototype.countTrailingZeros;
|
|||
* @returns {!Long}
|
||||
*/
|
||||
LongPrototype.and = function and(other) {
|
||||
if (!isLong(other))
|
||||
other = fromValue(other);
|
||||
if (!isLong(other)) other = fromValue(other);
|
||||
return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
|
||||
};
|
||||
|
||||
|
|
@ -1266,8 +1257,7 @@ LongPrototype.and = function and(other) {
|
|||
* @returns {!Long}
|
||||
*/
|
||||
LongPrototype.or = function or(other) {
|
||||
if (!isLong(other))
|
||||
other = fromValue(other);
|
||||
if (!isLong(other)) other = fromValue(other);
|
||||
return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
|
||||
};
|
||||
|
||||
|
|
@ -1278,8 +1268,7 @@ LongPrototype.or = function or(other) {
|
|||
* @returns {!Long}
|
||||
*/
|
||||
LongPrototype.xor = function xor(other) {
|
||||
if (!isLong(other))
|
||||
other = fromValue(other);
|
||||
if (!isLong(other)) other = fromValue(other);
|
||||
return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
|
||||
};
|
||||
|
||||
|
|
@ -1290,14 +1279,15 @@ LongPrototype.xor = function xor(other) {
|
|||
* @returns {!Long} Shifted Long
|
||||
*/
|
||||
LongPrototype.shiftLeft = function shiftLeft(numBits) {
|
||||
if (isLong(numBits))
|
||||
numBits = numBits.toInt();
|
||||
if ((numBits &= 63) === 0)
|
||||
return this;
|
||||
if (isLong(numBits)) numBits = numBits.toInt();
|
||||
if ((numBits &= 63) === 0) return this;
|
||||
else if (numBits < 32)
|
||||
return fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);
|
||||
else
|
||||
return fromBits(0, this.low << (numBits - 32), this.unsigned);
|
||||
return fromBits(
|
||||
this.low << numBits,
|
||||
(this.high << numBits) | (this.low >>> (32 - numBits)),
|
||||
this.unsigned,
|
||||
);
|
||||
else return fromBits(0, this.low << (numBits - 32), this.unsigned);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1315,14 +1305,20 @@ LongPrototype.shl = LongPrototype.shiftLeft;
|
|||
* @returns {!Long} Shifted Long
|
||||
*/
|
||||
LongPrototype.shiftRight = function shiftRight(numBits) {
|
||||
if (isLong(numBits))
|
||||
numBits = numBits.toInt();
|
||||
if ((numBits &= 63) === 0)
|
||||
return this;
|
||||
if (isLong(numBits)) numBits = numBits.toInt();
|
||||
if ((numBits &= 63) === 0) return this;
|
||||
else if (numBits < 32)
|
||||
return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);
|
||||
return fromBits(
|
||||
(this.low >>> numBits) | (this.high << (32 - numBits)),
|
||||
this.high >> numBits,
|
||||
this.unsigned,
|
||||
);
|
||||
else
|
||||
return fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);
|
||||
return fromBits(
|
||||
this.high >> (numBits - 32),
|
||||
this.high >= 0 ? 0 : -1,
|
||||
this.unsigned,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1342,7 +1338,12 @@ LongPrototype.shr = LongPrototype.shiftRight;
|
|||
LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
|
||||
if (isLong(numBits)) numBits = numBits.toInt();
|
||||
if ((numBits &= 63) === 0) return this;
|
||||
if (numBits < 32) return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >>> numBits, this.unsigned);
|
||||
if (numBits < 32)
|
||||
return fromBits(
|
||||
(this.low >>> numBits) | (this.high << (32 - numBits)),
|
||||
this.high >>> numBits,
|
||||
this.unsigned,
|
||||
);
|
||||
if (numBits === 32) return fromBits(this.high, 0, this.unsigned);
|
||||
return fromBits(this.high >>> (numBits - 32), 0, this.unsigned);
|
||||
};
|
||||
|
|
@ -1375,13 +1376,21 @@ LongPrototype.rotateLeft = function rotateLeft(numBits) {
|
|||
if ((numBits &= 63) === 0) return this;
|
||||
if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
|
||||
if (numBits < 32) {
|
||||
b = (32 - numBits);
|
||||
return fromBits(((this.low << numBits) | (this.high >>> b)), ((this.high << numBits) | (this.low >>> b)), this.unsigned);
|
||||
b = 32 - numBits;
|
||||
return fromBits(
|
||||
(this.low << numBits) | (this.high >>> b),
|
||||
(this.high << numBits) | (this.low >>> b),
|
||||
this.unsigned,
|
||||
);
|
||||
}
|
||||
numBits -= 32;
|
||||
b = (32 - numBits);
|
||||
return fromBits(((this.high << numBits) | (this.low >>> b)), ((this.low << numBits) | (this.high >>> b)), this.unsigned);
|
||||
}
|
||||
b = 32 - numBits;
|
||||
return fromBits(
|
||||
(this.high << numBits) | (this.low >>> b),
|
||||
(this.low << numBits) | (this.high >>> b),
|
||||
this.unsigned,
|
||||
);
|
||||
};
|
||||
/**
|
||||
* Returns this Long with bits rotated to the left by the given amount. This is an alias of {@link Long#rotateLeft}.
|
||||
* @function
|
||||
|
|
@ -1402,13 +1411,21 @@ LongPrototype.rotateRight = function rotateRight(numBits) {
|
|||
if ((numBits &= 63) === 0) return this;
|
||||
if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
|
||||
if (numBits < 32) {
|
||||
b = (32 - numBits);
|
||||
return fromBits(((this.high << b) | (this.low >>> numBits)), ((this.low << b) | (this.high >>> numBits)), this.unsigned);
|
||||
b = 32 - numBits;
|
||||
return fromBits(
|
||||
(this.high << b) | (this.low >>> numBits),
|
||||
(this.low << b) | (this.high >>> numBits),
|
||||
this.unsigned,
|
||||
);
|
||||
}
|
||||
numBits -= 32;
|
||||
b = (32 - numBits);
|
||||
return fromBits(((this.low << b) | (this.high >>> numBits)), ((this.high << b) | (this.low >>> numBits)), this.unsigned);
|
||||
}
|
||||
b = 32 - numBits;
|
||||
return fromBits(
|
||||
(this.low << b) | (this.high >>> numBits),
|
||||
(this.high << b) | (this.low >>> numBits),
|
||||
this.unsigned,
|
||||
);
|
||||
};
|
||||
/**
|
||||
* Returns this Long with bits rotated to the right by the given amount. This is an alias of {@link Long#rotateRight}.
|
||||
* @function
|
||||
|
|
@ -1423,8 +1440,7 @@ LongPrototype.rotr = LongPrototype.rotateRight;
|
|||
* @returns {!Long} Signed long
|
||||
*/
|
||||
LongPrototype.toSigned = function toSigned() {
|
||||
if (!this.unsigned)
|
||||
return this;
|
||||
if (!this.unsigned) return this;
|
||||
return fromBits(this.low, this.high, false);
|
||||
};
|
||||
|
||||
|
|
@ -1434,8 +1450,7 @@ LongPrototype.toSigned = function toSigned() {
|
|||
* @returns {!Long} Unsigned long
|
||||
*/
|
||||
LongPrototype.toUnsigned = function toUnsigned() {
|
||||
if (this.unsigned)
|
||||
return this;
|
||||
if (this.unsigned) return this;
|
||||
return fromBits(this.low, this.high, true);
|
||||
};
|
||||
|
||||
|
|
@ -1459,13 +1474,13 @@ LongPrototype.toBytesLE = function toBytesLE() {
|
|||
lo = this.low;
|
||||
return [
|
||||
lo & 0xff,
|
||||
lo >>> 8 & 0xff,
|
||||
lo >>> 16 & 0xff,
|
||||
(lo >>> 8) & 0xff,
|
||||
(lo >>> 16) & 0xff,
|
||||
lo >>> 24,
|
||||
hi & 0xff,
|
||||
hi >>> 8 & 0xff,
|
||||
hi >>> 16 & 0xff,
|
||||
hi >>> 24
|
||||
(hi >>> 8) & 0xff,
|
||||
(hi >>> 16) & 0xff,
|
||||
hi >>> 24,
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -1479,13 +1494,13 @@ LongPrototype.toBytesBE = function toBytesBE() {
|
|||
lo = this.low;
|
||||
return [
|
||||
hi >>> 24,
|
||||
hi >>> 16 & 0xff,
|
||||
hi >>> 8 & 0xff,
|
||||
(hi >>> 16) & 0xff,
|
||||
(hi >>> 8) & 0xff,
|
||||
hi & 0xff,
|
||||
lo >>> 24,
|
||||
lo >>> 16 & 0xff,
|
||||
lo >>> 8 & 0xff,
|
||||
lo & 0xff
|
||||
(lo >>> 16) & 0xff,
|
||||
(lo >>> 8) & 0xff,
|
||||
lo & 0xff,
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -1497,7 +1512,9 @@ LongPrototype.toBytesBE = function toBytesBE() {
|
|||
* @returns {Long} The corresponding Long value
|
||||
*/
|
||||
Long.fromBytes = function fromBytes(bytes, unsigned, le) {
|
||||
return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
|
||||
return le
|
||||
? Long.fromBytesLE(bytes, unsigned)
|
||||
: Long.fromBytesBE(bytes, unsigned);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1508,15 +1525,9 @@ Long.fromBytes = function fromBytes(bytes, unsigned, le) {
|
|||
*/
|
||||
Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
|
||||
return new Long(
|
||||
bytes[0] |
|
||||
bytes[1] << 8 |
|
||||
bytes[2] << 16 |
|
||||
bytes[3] << 24,
|
||||
bytes[4] |
|
||||
bytes[5] << 8 |
|
||||
bytes[6] << 16 |
|
||||
bytes[7] << 24,
|
||||
unsigned
|
||||
bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24),
|
||||
bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24),
|
||||
unsigned,
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -1528,21 +1539,14 @@ Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
|
|||
*/
|
||||
Long.fromBytesBE = function fromBytesBE(bytes, unsigned) {
|
||||
return new Long(
|
||||
bytes[4] << 24 |
|
||||
bytes[5] << 16 |
|
||||
bytes[6] << 8 |
|
||||
bytes[7],
|
||||
bytes[0] << 24 |
|
||||
bytes[1] << 16 |
|
||||
bytes[2] << 8 |
|
||||
bytes[3],
|
||||
unsigned
|
||||
(bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7],
|
||||
(bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3],
|
||||
unsigned,
|
||||
);
|
||||
};
|
||||
|
||||
// Support conversion to/from BigInt where available
|
||||
if (typeof BigInt === "function") {
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given big integer.
|
||||
* @function
|
||||
|
|
@ -1558,10 +1562,9 @@ if (typeof BigInt === "function") {
|
|||
|
||||
// Override
|
||||
Long.fromValue = function fromValueWithBigInt(value, unsigned) {
|
||||
if (typeof value === "bigint")
|
||||
return fromBigInt(value, unsigned);
|
||||
if (typeof value === "bigint") return fromBigInt(value, unsigned);
|
||||
return fromValue(value, unsigned);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the Long to its big integer representation.
|
||||
|
|
@ -1571,9 +1574,8 @@ if (typeof BigInt === "function") {
|
|||
LongPrototype.toBigInt = function toBigInt() {
|
||||
var lowBigInt = BigInt(this.low >>> 0);
|
||||
var highBigInt = BigInt(this.unsigned ? this.high >>> 0 : this.high);
|
||||
return highBigInt << BigInt(32) | lowBigInt;
|
||||
return (highBigInt << BigInt(32)) | lowBigInt;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export default Long;
|
||||
|
|
|
|||
14
node_modules/long/package.json
generated
vendored
14
node_modules/long/package.json
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "long",
|
||||
"version": "5.3.0",
|
||||
"version": "5.3.1",
|
||||
"author": "Daniel Wirtz <dcode@dcode.io>",
|
||||
"description": "A Long class for representing a 64-bit two's-complement integer value.",
|
||||
"repository": {
|
||||
|
|
@ -32,23 +32,27 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "esm2umd Long index.js > umd/index.js",
|
||||
"build": "node scripts/build.js",
|
||||
"lint": "prettier --check .",
|
||||
"format": "prettier --write .",
|
||||
"test": "npm run test:unit && npm run test:typescript",
|
||||
"test:unit": "node tests",
|
||||
"test:typescript": "tsc --project tests/typescript/tsconfig.esnext.json && tsc --project tests/typescript/tsconfig.nodenext.json && tsc --project tests/typescript/tsconfig.commonjs.json"
|
||||
"test:typescript": "tsc --project tests/typescript/tsconfig.esnext.json && tsc --project tests/typescript/tsconfig.nodenext.json && tsc --project tests/typescript/tsconfig.commonjs.json && tsc --project tests/typescript/tsconfig.global.json"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"types.d.ts",
|
||||
"umd/index.js",
|
||||
"umd/index.d.ts",
|
||||
"umd/types.d.ts",
|
||||
"umd/package.json",
|
||||
"types.d.ts",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"esm2umd": "^0.2.2",
|
||||
"esm2umd": "^0.3.0",
|
||||
"prettier": "^3.5.0",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
node_modules/long/types.d.ts
generated
vendored
13
node_modules/long/types.d.ts
generated
vendored
|
|
@ -1,4 +1,13 @@
|
|||
type LongLike = Long | number | bigint | string | { low: number; high: number; unsigned: boolean };
|
||||
// Common type definitions for both the ESM and UMD variants. The ESM variant
|
||||
// reexports the Long class as its default export, whereas the UMD variant makes
|
||||
// the Long class a whole-module export with a global variable fallback.
|
||||
|
||||
type LongLike =
|
||||
| Long
|
||||
| number
|
||||
| bigint
|
||||
| string
|
||||
| { low: number; high: number; unsigned: boolean };
|
||||
|
||||
export declare class Long {
|
||||
/**
|
||||
|
|
@ -87,7 +96,7 @@ export declare class Long {
|
|||
static fromString(
|
||||
str: string,
|
||||
unsigned?: boolean | number,
|
||||
radix?: number
|
||||
radix?: number,
|
||||
): Long;
|
||||
|
||||
/**
|
||||
|
|
|
|||
3
node_modules/long/umd/index.d.ts
generated
vendored
3
node_modules/long/umd/index.d.ts
generated
vendored
|
|
@ -1,2 +1,3 @@
|
|||
import { Long } from '../types.js';
|
||||
import { Long } from "./types.js";
|
||||
export = Long;
|
||||
export as namespace Long;
|
||||
|
|
|
|||
3037
node_modules/long/umd/index.js
generated
vendored
3037
node_modules/long/umd/index.js
generated
vendored
File diff suppressed because it is too large
Load diff
474
node_modules/long/umd/types.d.ts
generated
vendored
Normal file
474
node_modules/long/umd/types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,474 @@
|
|||
// Common type definitions for both the ESM and UMD variants. The ESM variant
|
||||
// reexports the Long class as its default export, whereas the UMD variant makes
|
||||
// the Long class a whole-module export with a global variable fallback.
|
||||
|
||||
type LongLike =
|
||||
| Long
|
||||
| number
|
||||
| bigint
|
||||
| string
|
||||
| { low: number; high: number; unsigned: boolean };
|
||||
|
||||
export declare class Long {
|
||||
/**
|
||||
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as signed integers. See the from* functions below for more convenient ways of constructing Longs.
|
||||
*/
|
||||
constructor(low: number, high?: number, unsigned?: boolean);
|
||||
|
||||
/**
|
||||
* Maximum unsigned value.
|
||||
*/
|
||||
static MAX_UNSIGNED_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Maximum signed value.
|
||||
*/
|
||||
static MAX_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Minimum signed value.
|
||||
*/
|
||||
static MIN_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Signed negative one.
|
||||
*/
|
||||
static NEG_ONE: Long;
|
||||
|
||||
/**
|
||||
* Signed one.
|
||||
*/
|
||||
static ONE: Long;
|
||||
|
||||
/**
|
||||
* Unsigned one.
|
||||
*/
|
||||
static UONE: Long;
|
||||
|
||||
/**
|
||||
* Unsigned zero.
|
||||
*/
|
||||
static UZERO: Long;
|
||||
|
||||
/**
|
||||
* Signed zero
|
||||
*/
|
||||
static ZERO: Long;
|
||||
|
||||
/**
|
||||
* The high 32 bits as a signed value.
|
||||
*/
|
||||
high: number;
|
||||
|
||||
/**
|
||||
* The low 32 bits as a signed value.
|
||||
*/
|
||||
low: number;
|
||||
|
||||
/**
|
||||
* Whether unsigned or not.
|
||||
*/
|
||||
unsigned: boolean;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits.
|
||||
*/
|
||||
static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given 32 bit integer value.
|
||||
*/
|
||||
static fromInt(value: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
|
||||
*/
|
||||
static fromNumber(value: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given big integer value.
|
||||
*/
|
||||
static fromBigInt(value: bigint, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representation of the given string, written using the specified radix.
|
||||
*/
|
||||
static fromString(
|
||||
str: string,
|
||||
unsigned?: boolean | number,
|
||||
radix?: number,
|
||||
): Long;
|
||||
|
||||
/**
|
||||
* Creates a Long from its byte representation.
|
||||
*/
|
||||
static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Creates a Long from its little endian byte representation.
|
||||
*/
|
||||
static fromBytesLE(bytes: number[], unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Creates a Long from its big endian byte representation.
|
||||
*/
|
||||
static fromBytesBE(bytes: number[], unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Tests if the specified object is a Long.
|
||||
*/
|
||||
static isLong(obj: any): obj is Long;
|
||||
|
||||
/**
|
||||
* Converts the specified value to a Long.
|
||||
*/
|
||||
static fromValue(val: LongLike, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns the sum of this and the specified Long.
|
||||
*/
|
||||
add(addend: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise AND of this Long and the specified.
|
||||
*/
|
||||
and(other: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Compares this Long's value with the specified's.
|
||||
*/
|
||||
compare(other: LongLike): number;
|
||||
|
||||
/**
|
||||
* Compares this Long's value with the specified's.
|
||||
*/
|
||||
comp(other: LongLike): number;
|
||||
|
||||
/**
|
||||
* Returns this Long divided by the specified.
|
||||
*/
|
||||
divide(divisor: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long divided by the specified.
|
||||
*/
|
||||
div(divisor: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals the specified's.
|
||||
*/
|
||||
equals(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals the specified's.
|
||||
*/
|
||||
eq(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Gets the high 32 bits as a signed integer.
|
||||
*/
|
||||
getHighBits(): number;
|
||||
|
||||
/**
|
||||
* Gets the high 32 bits as an unsigned integer.
|
||||
*/
|
||||
getHighBitsUnsigned(): number;
|
||||
|
||||
/**
|
||||
* Gets the low 32 bits as a signed integer.
|
||||
*/
|
||||
getLowBits(): number;
|
||||
|
||||
/**
|
||||
* Gets the low 32 bits as an unsigned integer.
|
||||
*/
|
||||
getLowBitsUnsigned(): number;
|
||||
|
||||
/**
|
||||
* Gets the number of bits needed to represent the absolute value of this Long.
|
||||
*/
|
||||
getNumBitsAbs(): number;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than the specified's.
|
||||
*/
|
||||
greaterThan(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than the specified's.
|
||||
*/
|
||||
gt(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than or equal the specified's.
|
||||
*/
|
||||
greaterThanOrEqual(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than or equal the specified's.
|
||||
*/
|
||||
gte(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than or equal the specified's.
|
||||
*/
|
||||
ge(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is even.
|
||||
*/
|
||||
isEven(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is negative.
|
||||
*/
|
||||
isNegative(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is odd.
|
||||
*/
|
||||
isOdd(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is positive or zero.
|
||||
*/
|
||||
isPositive(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long can be safely represented as a JavaScript number.
|
||||
*/
|
||||
isSafeInteger(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals zero.
|
||||
*/
|
||||
isZero(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals zero.
|
||||
*/
|
||||
eqz(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than the specified's.
|
||||
*/
|
||||
lessThan(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than the specified's.
|
||||
*/
|
||||
lt(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than or equal the specified's.
|
||||
*/
|
||||
lessThanOrEqual(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than or equal the specified's.
|
||||
*/
|
||||
lte(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than or equal the specified's.
|
||||
*/
|
||||
le(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Returns this Long modulo the specified.
|
||||
*/
|
||||
modulo(other: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long modulo the specified.
|
||||
*/
|
||||
mod(other: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long modulo the specified.
|
||||
*/
|
||||
rem(other: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns the product of this and the specified Long.
|
||||
*/
|
||||
multiply(multiplier: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns the product of this and the specified Long.
|
||||
*/
|
||||
mul(multiplier: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Negates this Long's value.
|
||||
*/
|
||||
negate(): Long;
|
||||
|
||||
/**
|
||||
* Negates this Long's value.
|
||||
*/
|
||||
neg(): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise NOT of this Long.
|
||||
*/
|
||||
not(): Long;
|
||||
|
||||
/**
|
||||
* Returns count leading zeros of this Long.
|
||||
*/
|
||||
countLeadingZeros(): number;
|
||||
|
||||
/**
|
||||
* Returns count leading zeros of this Long.
|
||||
*/
|
||||
clz(): number;
|
||||
|
||||
/**
|
||||
* Returns count trailing zeros of this Long.
|
||||
*/
|
||||
countTrailingZeros(): number;
|
||||
|
||||
/**
|
||||
* Returns count trailing zeros of this Long.
|
||||
*/
|
||||
ctz(): number;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value differs from the specified's.
|
||||
*/
|
||||
notEquals(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value differs from the specified's.
|
||||
*/
|
||||
neq(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value differs from the specified's.
|
||||
*/
|
||||
ne(other: LongLike): boolean;
|
||||
|
||||
/**
|
||||
* Returns the bitwise OR of this Long and the specified.
|
||||
*/
|
||||
or(other: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits shifted to the left by the given amount.
|
||||
*/
|
||||
shiftLeft(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits shifted to the left by the given amount.
|
||||
*/
|
||||
shl(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits arithmetically shifted to the right by the given amount.
|
||||
*/
|
||||
shiftRight(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits arithmetically shifted to the right by the given amount.
|
||||
*/
|
||||
shr(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits logically shifted to the right by the given amount.
|
||||
*/
|
||||
shiftRightUnsigned(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits logically shifted to the right by the given amount.
|
||||
*/
|
||||
shru(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits logically shifted to the right by the given amount.
|
||||
*/
|
||||
shr_u(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits rotated to the left by the given amount.
|
||||
*/
|
||||
rotateLeft(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits rotated to the left by the given amount.
|
||||
*/
|
||||
rotl(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits rotated to the right by the given amount.
|
||||
*/
|
||||
rotateRight(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits rotated to the right by the given amount.
|
||||
*/
|
||||
rotr(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns the difference of this and the specified Long.
|
||||
*/
|
||||
subtract(subtrahend: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Returns the difference of this and the specified Long.
|
||||
*/
|
||||
sub(subtrahend: LongLike): Long;
|
||||
|
||||
/**
|
||||
* Converts the Long to a big integer.
|
||||
*/
|
||||
toBigInt(): bigint;
|
||||
|
||||
/**
|
||||
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
|
||||
*/
|
||||
toInt(): number;
|
||||
|
||||
/**
|
||||
* Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
|
||||
*/
|
||||
toNumber(): number;
|
||||
|
||||
/**
|
||||
* Converts this Long to its byte representation.
|
||||
*/
|
||||
|
||||
toBytes(le?: boolean): number[];
|
||||
|
||||
/**
|
||||
* Converts this Long to its little endian byte representation.
|
||||
*/
|
||||
|
||||
toBytesLE(): number[];
|
||||
|
||||
/**
|
||||
* Converts this Long to its big endian byte representation.
|
||||
*/
|
||||
|
||||
toBytesBE(): number[];
|
||||
|
||||
/**
|
||||
* Converts this Long to signed.
|
||||
*/
|
||||
toSigned(): Long;
|
||||
|
||||
/**
|
||||
* Converts the Long to a string written in the specified radix.
|
||||
*/
|
||||
toString(radix?: number): string;
|
||||
|
||||
/**
|
||||
* Converts this Long to unsigned.
|
||||
*/
|
||||
toUnsigned(): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise XOR of this Long and the given one.
|
||||
*/
|
||||
xor(other: LongLike): Long;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue