index.d.ts 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. declare class Long {
  2. /**
  3. * 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.
  4. */
  5. constructor(low: number, high?: number, unsigned?: boolean);
  6. /**
  7. * Maximum unsigned value.
  8. */
  9. static MAX_UNSIGNED_VALUE: Long;
  10. /**
  11. * Maximum signed value.
  12. */
  13. static MAX_VALUE: Long;
  14. /**
  15. * Minimum signed value.
  16. */
  17. static MIN_VALUE: Long;
  18. /**
  19. * Signed negative one.
  20. */
  21. static NEG_ONE: Long;
  22. /**
  23. * Signed one.
  24. */
  25. static ONE: Long;
  26. /**
  27. * Unsigned one.
  28. */
  29. static UONE: Long;
  30. /**
  31. * Unsigned zero.
  32. */
  33. static UZERO: Long;
  34. /**
  35. * Signed zero
  36. */
  37. static ZERO: Long;
  38. /**
  39. * The high 32 bits as a signed value.
  40. */
  41. high: number;
  42. /**
  43. * The low 32 bits as a signed value.
  44. */
  45. low: number;
  46. /**
  47. * Whether unsigned or not.
  48. */
  49. unsigned: boolean;
  50. /**
  51. * 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.
  52. */
  53. static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
  54. /**
  55. * Returns a Long representing the given 32 bit integer value.
  56. */
  57. static fromInt(value: number, unsigned?: boolean): Long;
  58. /**
  59. * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
  60. */
  61. static fromNumber(value: number, unsigned?: boolean): Long;
  62. /**
  63. * Returns a Long representation of the given string, written using the specified radix.
  64. */
  65. static fromString(str: string, unsigned?: boolean | number, radix?: number): Long;
  66. /**
  67. * Creates a Long from its byte representation.
  68. */
  69. static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long;
  70. /**
  71. * Creates a Long from its little endian byte representation.
  72. */
  73. static fromBytesLE(bytes: number[], unsigned?: boolean): Long;
  74. /**
  75. * Creates a Long from its big endian byte representation.
  76. */
  77. static fromBytesBE(bytes: number[], unsigned?: boolean): Long;
  78. /**
  79. * Tests if the specified object is a Long.
  80. */
  81. static isLong(obj: any): obj is Long;
  82. /**
  83. * Converts the specified value to a Long.
  84. */
  85. static fromValue(val: Long | number | string | { low: number, high: number, unsigned: boolean }, unsigned?: boolean): Long;
  86. /**
  87. * Returns the sum of this and the specified Long.
  88. */
  89. add(addend: number | Long | string): Long;
  90. /**
  91. * Returns the bitwise AND of this Long and the specified.
  92. */
  93. and(other: Long | number | string): Long;
  94. /**
  95. * Compares this Long's value with the specified's.
  96. */
  97. compare(other: Long | number | string): number;
  98. /**
  99. * Compares this Long's value with the specified's.
  100. */
  101. comp(other: Long | number | string): number;
  102. /**
  103. * Returns this Long divided by the specified.
  104. */
  105. divide(divisor: Long | number | string): Long;
  106. /**
  107. * Returns this Long divided by the specified.
  108. */
  109. div(divisor: Long | number | string): Long;
  110. /**
  111. * Tests if this Long's value equals the specified's.
  112. */
  113. equals(other: Long | number | string): boolean;
  114. /**
  115. * Tests if this Long's value equals the specified's.
  116. */
  117. eq(other: Long | number | string): boolean;
  118. /**
  119. * Gets the high 32 bits as a signed integer.
  120. */
  121. getHighBits(): number;
  122. /**
  123. * Gets the high 32 bits as an unsigned integer.
  124. */
  125. getHighBitsUnsigned(): number;
  126. /**
  127. * Gets the low 32 bits as a signed integer.
  128. */
  129. getLowBits(): number;
  130. /**
  131. * Gets the low 32 bits as an unsigned integer.
  132. */
  133. getLowBitsUnsigned(): number;
  134. /**
  135. * Gets the number of bits needed to represent the absolute value of this Long.
  136. */
  137. getNumBitsAbs(): number;
  138. /**
  139. * Tests if this Long's value is greater than the specified's.
  140. */
  141. greaterThan(other: Long | number | string): boolean;
  142. /**
  143. * Tests if this Long's value is greater than the specified's.
  144. */
  145. gt(other: Long | number | string): boolean;
  146. /**
  147. * Tests if this Long's value is greater than or equal the specified's.
  148. */
  149. greaterThanOrEqual(other: Long | number | string): boolean;
  150. /**
  151. * Tests if this Long's value is greater than or equal the specified's.
  152. */
  153. gte(other: Long | number | string): boolean;
  154. /**
  155. * Tests if this Long's value is greater than or equal the specified's.
  156. */
  157. ge(other: Long | number | string): boolean;
  158. /**
  159. * Tests if this Long's value is even.
  160. */
  161. isEven(): boolean;
  162. /**
  163. * Tests if this Long's value is negative.
  164. */
  165. isNegative(): boolean;
  166. /**
  167. * Tests if this Long's value is odd.
  168. */
  169. isOdd(): boolean;
  170. /**
  171. * Tests if this Long's value is positive or zero.
  172. */
  173. isPositive(): boolean;
  174. /**
  175. * Tests if this Long's value equals zero.
  176. */
  177. isZero(): boolean;
  178. /**
  179. * Tests if this Long's value equals zero.
  180. */
  181. eqz(): boolean;
  182. /**
  183. * Tests if this Long's value is less than the specified's.
  184. */
  185. lessThan(other: Long | number | string): boolean;
  186. /**
  187. * Tests if this Long's value is less than the specified's.
  188. */
  189. lt(other: Long | number | string): boolean;
  190. /**
  191. * Tests if this Long's value is less than or equal the specified's.
  192. */
  193. lessThanOrEqual(other: Long | number | string): boolean;
  194. /**
  195. * Tests if this Long's value is less than or equal the specified's.
  196. */
  197. lte(other: Long | number | string): boolean;
  198. /**
  199. * Tests if this Long's value is less than or equal the specified's.
  200. */
  201. le(other: Long | number | string): boolean;
  202. /**
  203. * Returns this Long modulo the specified.
  204. */
  205. modulo(other: Long | number | string): Long;
  206. /**
  207. * Returns this Long modulo the specified.
  208. */
  209. mod(other: Long | number | string): Long;
  210. /**
  211. * Returns this Long modulo the specified.
  212. */
  213. rem(other: Long | number | string): Long;
  214. /**
  215. * Returns the product of this and the specified Long.
  216. */
  217. multiply(multiplier: Long | number | string): Long;
  218. /**
  219. * Returns the product of this and the specified Long.
  220. */
  221. mul(multiplier: Long | number | string): Long;
  222. /**
  223. * Negates this Long's value.
  224. */
  225. negate(): Long;
  226. /**
  227. * Negates this Long's value.
  228. */
  229. neg(): Long;
  230. /**
  231. * Returns the bitwise NOT of this Long.
  232. */
  233. not(): Long;
  234. /**
  235. * Returns count leading zeros of this Long.
  236. */
  237. countLeadingZeros(): number;
  238. /**
  239. * Returns count leading zeros of this Long.
  240. */
  241. clz(): number;
  242. /**
  243. * Returns count trailing zeros of this Long.
  244. */
  245. countTrailingZeros(): number;
  246. /**
  247. * Returns count trailing zeros of this Long.
  248. */
  249. ctz(): number;
  250. /**
  251. * Tests if this Long's value differs from the specified's.
  252. */
  253. notEquals(other: Long | number | string): boolean;
  254. /**
  255. * Tests if this Long's value differs from the specified's.
  256. */
  257. neq(other: Long | number | string): boolean;
  258. /**
  259. * Tests if this Long's value differs from the specified's.
  260. */
  261. ne(other: Long | number | string): boolean;
  262. /**
  263. * Returns the bitwise OR of this Long and the specified.
  264. */
  265. or(other: Long | number | string): Long;
  266. /**
  267. * Returns this Long with bits shifted to the left by the given amount.
  268. */
  269. shiftLeft(numBits: number | Long): Long;
  270. /**
  271. * Returns this Long with bits shifted to the left by the given amount.
  272. */
  273. shl(numBits: number | Long): Long;
  274. /**
  275. * Returns this Long with bits arithmetically shifted to the right by the given amount.
  276. */
  277. shiftRight(numBits: number | Long): Long;
  278. /**
  279. * Returns this Long with bits arithmetically shifted to the right by the given amount.
  280. */
  281. shr(numBits: number | Long): Long;
  282. /**
  283. * Returns this Long with bits logically shifted to the right by the given amount.
  284. */
  285. shiftRightUnsigned(numBits: number | Long): Long;
  286. /**
  287. * Returns this Long with bits logically shifted to the right by the given amount.
  288. */
  289. shru(numBits: number | Long): Long;
  290. /**
  291. * Returns this Long with bits logically shifted to the right by the given amount.
  292. */
  293. shr_u(numBits: number | Long): Long;
  294. /**
  295. * Returns this Long with bits rotated to the left by the given amount.
  296. */
  297. rotateLeft(numBits: number | Long): Long;
  298. /**
  299. * Returns this Long with bits rotated to the left by the given amount.
  300. */
  301. rotl(numBits: number | Long): Long;
  302. /**
  303. * Returns this Long with bits rotated to the right by the given amount.
  304. */
  305. rotateRight(numBits: number | Long): Long;
  306. /**
  307. * Returns this Long with bits rotated to the right by the given amount.
  308. */
  309. rotr(numBits: number | Long): Long;
  310. /**
  311. * Returns the difference of this and the specified Long.
  312. */
  313. subtract(subtrahend: number | Long | string): Long;
  314. /**
  315. * Returns the difference of this and the specified Long.
  316. */
  317. sub(subtrahend: number | Long | string): Long;
  318. /**
  319. * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
  320. */
  321. toInt(): number;
  322. /**
  323. * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
  324. */
  325. toNumber(): number;
  326. /**
  327. * Converts this Long to its byte representation.
  328. */
  329. toBytes(le?: boolean): number[];
  330. /**
  331. * Converts this Long to its little endian byte representation.
  332. */
  333. toBytesLE(): number[];
  334. /**
  335. * Converts this Long to its big endian byte representation.
  336. */
  337. toBytesBE(): number[];
  338. /**
  339. * Converts this Long to signed.
  340. */
  341. toSigned(): Long;
  342. /**
  343. * Converts the Long to a string written in the specified radix.
  344. */
  345. toString(radix?: number): string;
  346. /**
  347. * Converts this Long to unsigned.
  348. */
  349. toUnsigned(): Long;
  350. /**
  351. * Returns the bitwise XOR of this Long and the given one.
  352. */
  353. xor(other: Long | number | string): Long;
  354. }
  355. export = Long; // compatible with `import Long from "long"`