@oathompsonjones/mini-games 1.0.6 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TODO.md +6 -0
- package/build/base/board.d.ts +53 -45
- package/build/base/board.js +84 -72
- package/build/base/controller.d.ts +48 -37
- package/build/base/controller.js +32 -26
- package/build/bitBoard/bitBoard.d.ts +37 -34
- package/build/bitBoard/bitBoard.js +15 -12
- package/build/bitBoard/intBitBoard.d.ts +22 -22
- package/build/bitBoard/intBitBoard.js +16 -16
- package/build/bitBoard/longInt.d.ts +47 -40
- package/build/bitBoard/longInt.js +40 -37
- package/build/bitBoard/longIntBitBoard.d.ts +26 -26
- package/build/bitBoard/longIntBitBoard.js +16 -16
- package/build/console.d.ts +2 -3
- package/build/console.js +3 -4
- package/build/games/connect4/board.d.ts +12 -5
- package/build/games/connect4/board.js +12 -6
- package/build/games/connect4/controller.d.ts +18 -11
- package/build/games/connect4/controller.js +20 -12
- package/build/games/tictactoe/board.d.ts +5 -2
- package/build/games/tictactoe/board.js +5 -2
- package/build/games/tictactoe/controller.d.ts +17 -12
- package/build/games/tictactoe/controller.js +19 -13
- package/eslint.config.js +1 -1
- package/package.json +6 -7
- package/patches/eventemitter3@5.0.1.patch +0 -68
|
@@ -3,28 +3,28 @@
|
|
|
3
3
|
export default class IntBitBoard extends BitBoard<number> {
|
|
4
4
|
/**
|
|
5
5
|
* Creates an instance of NumberBitBoard.
|
|
6
|
-
* @param data The data to fill the BitBoard with.
|
|
6
|
+
* @param data - The data to fill the BitBoard with.
|
|
7
7
|
*/
|
|
8
8
|
constructor(data?: number);
|
|
9
9
|
/**
|
|
10
10
|
* Gets the value of a given bit.
|
|
11
|
-
* @param bit The bit to get.
|
|
11
|
+
* @param bit - The bit to get.
|
|
12
12
|
* @returns The value of the bit.
|
|
13
13
|
*/
|
|
14
14
|
getBit(bit: number): 0 | 1;
|
|
15
15
|
/**
|
|
16
16
|
* Sets the value for a given bit to 1.
|
|
17
|
-
* @param bit The bit to set.
|
|
17
|
+
* @param bit - The bit to set.
|
|
18
18
|
*/
|
|
19
19
|
setBit(bit: number): void;
|
|
20
20
|
/**
|
|
21
21
|
* Sets the value for a given bit to 0.
|
|
22
|
-
* @param bit The bit to clear.
|
|
22
|
+
* @param bit - The bit to clear.
|
|
23
23
|
*/
|
|
24
24
|
clearBit(bit: number): void;
|
|
25
25
|
/**
|
|
26
26
|
* Toggles the data for a given bit between 0 and 1.
|
|
27
|
-
* @param bit The bit to toggle.
|
|
27
|
+
* @param bit - The bit to toggle.
|
|
28
28
|
*/
|
|
29
29
|
toggleBit(bit: number): void;
|
|
30
30
|
/** Sets all bits to 0. */
|
|
@@ -33,55 +33,55 @@ export default class IntBitBoard extends BitBoard<number> {
|
|
|
33
33
|
setAll(): void;
|
|
34
34
|
/**
|
|
35
35
|
* Gets a given number of bits.
|
|
36
|
-
* @param LSB The least significant bit to get.
|
|
37
|
-
* @param numberOfBits The number of bits to get.
|
|
38
|
-
* @returns The bits.
|
|
36
|
+
* @param LSB - The least significant bit to get.
|
|
37
|
+
* @param numberOfBits - The number of bits to get.
|
|
38
|
+
* @returns The bits as a number.
|
|
39
39
|
*/
|
|
40
40
|
getBits(LSB: number, numberOfBits: number): number;
|
|
41
41
|
/**
|
|
42
42
|
* Carries out an in-place bitwise and (&) operation on this board and the one provided.
|
|
43
|
-
* @param right The other bitboard.
|
|
43
|
+
* @param right - The other bitboard.
|
|
44
44
|
* @returns The result of the operation.
|
|
45
45
|
*/
|
|
46
|
-
and(right: IntBitBoard | number):
|
|
46
|
+
and(right: IntBitBoard | number): IntBitBoard;
|
|
47
47
|
/**
|
|
48
48
|
* Carries out an in-place bitwise or (|) operation on this board and the one provided.
|
|
49
|
-
* @param right The other bitboard.
|
|
49
|
+
* @param right - The other bitboard.
|
|
50
50
|
* @returns The result of the operation.
|
|
51
51
|
*/
|
|
52
|
-
or(right: IntBitBoard | number):
|
|
52
|
+
or(right: IntBitBoard | number): IntBitBoard;
|
|
53
53
|
/**
|
|
54
54
|
* Carries out an in-place bitwise xor (^) operation on this board and the one provided.
|
|
55
|
-
* @param right The other bitboard.
|
|
55
|
+
* @param right - The other bitboard.
|
|
56
56
|
* @returns The result of the operation.
|
|
57
57
|
*/
|
|
58
|
-
xor(right: IntBitBoard | number):
|
|
58
|
+
xor(right: IntBitBoard | number): IntBitBoard;
|
|
59
59
|
/**
|
|
60
60
|
* Carries out an in-place bitwise not (~) operation on this board.
|
|
61
61
|
* @returns The result of the operation.
|
|
62
62
|
*/
|
|
63
|
-
not():
|
|
63
|
+
not(): IntBitBoard;
|
|
64
64
|
/**
|
|
65
65
|
* Carries out an in-place bitwise left shift (<<) operation on this board.
|
|
66
|
-
* @param shiftAmount The amount to shift by.
|
|
66
|
+
* @param shiftAmount - The amount to shift by.
|
|
67
67
|
* @returns The result of the operation.
|
|
68
68
|
*/
|
|
69
|
-
leftShift(shiftAmount: number):
|
|
69
|
+
leftShift(shiftAmount: number): IntBitBoard;
|
|
70
70
|
/**
|
|
71
71
|
* Carries out an in-place bitwise unsigned right shift (>>>) operation on this board.
|
|
72
|
-
* @param shiftAmount The amount to shift by.
|
|
72
|
+
* @param shiftAmount - The amount to shift by.
|
|
73
73
|
* @returns The result of the operation.
|
|
74
74
|
*/
|
|
75
|
-
rightShift(shiftAmount: number):
|
|
75
|
+
rightShift(shiftAmount: number): IntBitBoard;
|
|
76
76
|
/**
|
|
77
77
|
* Carries out an in-place bitwise arithmetic right shift (>>) operation on this board.
|
|
78
|
-
* @param shiftAmount The amount to shift by.
|
|
78
|
+
* @param shiftAmount - The amount to shift by.
|
|
79
79
|
* @returns The result of the operation.
|
|
80
80
|
*/
|
|
81
|
-
arithmeticRightShift(shiftAmount: number):
|
|
81
|
+
arithmeticRightShift(shiftAmount: number): IntBitBoard;
|
|
82
82
|
/**
|
|
83
83
|
* Checks if the current bitboard is equal to another.
|
|
84
|
-
* @param value The other bitboard.
|
|
84
|
+
* @param value - The other bitboard.
|
|
85
85
|
* @returns Whether or not the bitboards are equal.
|
|
86
86
|
*/
|
|
87
87
|
equals(value: IntBitBoard | number): boolean;
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
export default class IntBitBoard extends BitBoard {
|
|
4
4
|
/**
|
|
5
5
|
* Creates an instance of NumberBitBoard.
|
|
6
|
-
* @param data The data to fill the BitBoard with.
|
|
6
|
+
* @param data - The data to fill the BitBoard with.
|
|
7
7
|
*/
|
|
8
8
|
constructor(data = 0) {
|
|
9
9
|
super(data);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Gets the value of a given bit.
|
|
13
|
-
* @param bit The bit to get.
|
|
13
|
+
* @param bit - The bit to get.
|
|
14
14
|
* @returns The value of the bit.
|
|
15
15
|
*/
|
|
16
16
|
getBit(bit) {
|
|
@@ -18,7 +18,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Sets the value for a given bit to 1.
|
|
21
|
-
* @param bit The bit to set.
|
|
21
|
+
* @param bit - The bit to set.
|
|
22
22
|
*/
|
|
23
23
|
setBit(bit) {
|
|
24
24
|
const mask = 1 << bit;
|
|
@@ -26,7 +26,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Sets the value for a given bit to 0.
|
|
29
|
-
* @param bit The bit to clear.
|
|
29
|
+
* @param bit - The bit to clear.
|
|
30
30
|
*/
|
|
31
31
|
clearBit(bit) {
|
|
32
32
|
const mask = ~(1 << bit);
|
|
@@ -34,7 +34,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Toggles the data for a given bit between 0 and 1.
|
|
37
|
-
* @param bit The bit to toggle.
|
|
37
|
+
* @param bit - The bit to toggle.
|
|
38
38
|
*/
|
|
39
39
|
toggleBit(bit) {
|
|
40
40
|
const mask = 1 << bit;
|
|
@@ -50,9 +50,9 @@ export default class IntBitBoard extends BitBoard {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Gets a given number of bits.
|
|
53
|
-
* @param LSB The least significant bit to get.
|
|
54
|
-
* @param numberOfBits The number of bits to get.
|
|
55
|
-
* @returns The bits.
|
|
53
|
+
* @param LSB - The least significant bit to get.
|
|
54
|
+
* @param numberOfBits - The number of bits to get.
|
|
55
|
+
* @returns The bits as a number.
|
|
56
56
|
*/
|
|
57
57
|
getBits(LSB, numberOfBits) {
|
|
58
58
|
const mask = 2 ** numberOfBits - 1 << LSB;
|
|
@@ -61,7 +61,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Carries out an in-place bitwise and (&) operation on this board and the one provided.
|
|
64
|
-
* @param right The other bitboard.
|
|
64
|
+
* @param right - The other bitboard.
|
|
65
65
|
* @returns The result of the operation.
|
|
66
66
|
*/
|
|
67
67
|
and(right) {
|
|
@@ -69,7 +69,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Carries out an in-place bitwise or (|) operation on this board and the one provided.
|
|
72
|
-
* @param right The other bitboard.
|
|
72
|
+
* @param right - The other bitboard.
|
|
73
73
|
* @returns The result of the operation.
|
|
74
74
|
*/
|
|
75
75
|
or(right) {
|
|
@@ -77,7 +77,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Carries out an in-place bitwise xor (^) operation on this board and the one provided.
|
|
80
|
-
* @param right The other bitboard.
|
|
80
|
+
* @param right - The other bitboard.
|
|
81
81
|
* @returns The result of the operation.
|
|
82
82
|
*/
|
|
83
83
|
xor(right) {
|
|
@@ -92,7 +92,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Carries out an in-place bitwise left shift (<<) operation on this board.
|
|
95
|
-
* @param shiftAmount The amount to shift by.
|
|
95
|
+
* @param shiftAmount - The amount to shift by.
|
|
96
96
|
* @returns The result of the operation.
|
|
97
97
|
*/
|
|
98
98
|
leftShift(shiftAmount) {
|
|
@@ -100,7 +100,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Carries out an in-place bitwise unsigned right shift (>>>) operation on this board.
|
|
103
|
-
* @param shiftAmount The amount to shift by.
|
|
103
|
+
* @param shiftAmount - The amount to shift by.
|
|
104
104
|
* @returns The result of the operation.
|
|
105
105
|
*/
|
|
106
106
|
rightShift(shiftAmount) {
|
|
@@ -108,7 +108,7 @@ export default class IntBitBoard extends BitBoard {
|
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* Carries out an in-place bitwise arithmetic right shift (>>) operation on this board.
|
|
111
|
-
* @param shiftAmount The amount to shift by.
|
|
111
|
+
* @param shiftAmount - The amount to shift by.
|
|
112
112
|
* @returns The result of the operation.
|
|
113
113
|
*/
|
|
114
114
|
arithmeticRightShift(shiftAmount) {
|
|
@@ -116,11 +116,11 @@ export default class IntBitBoard extends BitBoard {
|
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Checks if the current bitboard is equal to another.
|
|
119
|
-
* @param value The other bitboard.
|
|
119
|
+
* @param value - The other bitboard.
|
|
120
120
|
* @returns Whether or not the bitboards are equal.
|
|
121
121
|
*/
|
|
122
122
|
equals(value) {
|
|
123
123
|
return this._data === (value instanceof IntBitBoard ? value._data : value);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
126
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50Qml0Qm9hcmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYml0Qm9hcmQvaW50Qml0Qm9hcmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6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cmUgZXF1YWwuXG4gICAgICovXG4gICAgcHVibGljIGVxdWFscyh2YWx1ZTogSW50Qml0Qm9hcmQgfCBudW1iZXIpOiBib29sZWFuIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2RhdGEgPT09ICh2YWx1ZSBpbnN0YW5jZW9mIEludEJpdEJvYXJkID8gdmFsdWUuX2RhdGEgOiB2YWx1ZSk7XG4gICAgfVxufVxuIl19
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const enum StringType {
|
|
2
|
+
BINARY = 2,
|
|
3
|
+
DECIMAL = 10,
|
|
4
|
+
HEXADECIMAL = 16
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Represents a long integer using an array of 32-bit numbers.
|
|
4
8
|
* Provides static methods for bitwise operations which do not modify the original values.
|
|
@@ -9,112 +13,115 @@ export default class LongInt {
|
|
|
9
13
|
readonly data: Uint32Array;
|
|
10
14
|
/**
|
|
11
15
|
* Creates an instance of LongInt.
|
|
12
|
-
* @param values A little-endian array of 32-bit numbers to fill the `LongInt`.
|
|
16
|
+
* @param values - A little-endian array of 32-bit numbers to fill the `LongInt`.
|
|
13
17
|
*/
|
|
14
18
|
constructor(values: number[] | Uint32Array);
|
|
15
19
|
/**
|
|
16
20
|
* Creates an instance of LongInt.
|
|
17
|
-
* @param length The number of 32-bit numbers to construct the `LongInt` out of.
|
|
21
|
+
* @param length - The number of 32-bit numbers to construct the `LongInt` out of.
|
|
18
22
|
*/
|
|
19
23
|
constructor(length: number);
|
|
20
24
|
/**
|
|
21
25
|
* Creates an instance of LongInt.
|
|
22
|
-
* @param longInt A `LongInt` object to duplicate.
|
|
26
|
+
* @param longInt - A `LongInt` object to duplicate.
|
|
23
27
|
*/
|
|
24
28
|
constructor(longInt: LongInt);
|
|
25
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Gets the number of 32-bit words which make the LongInt.
|
|
31
|
+
* @returns The number of words.
|
|
32
|
+
*/
|
|
26
33
|
get wordCount(): number;
|
|
27
34
|
/**
|
|
28
35
|
* Carries out a bitwise and (&) operation on the two numbers.
|
|
29
|
-
* @param left The left number.
|
|
30
|
-
* @param right The right number.
|
|
36
|
+
* @param left - The left number.
|
|
37
|
+
* @param right - The right number.
|
|
31
38
|
* @returns The result of left & right.
|
|
32
39
|
*/
|
|
33
40
|
static and(left: LongInt, right: LongInt | number): LongInt;
|
|
34
41
|
/**
|
|
35
42
|
* Carries out a bitwise or (|) operation on the two numbers.
|
|
36
|
-
* @param left The left number.
|
|
37
|
-
* @param right The right number.
|
|
43
|
+
* @param left - The left number.
|
|
44
|
+
* @param right - The right number.
|
|
38
45
|
* @returns The result of left | right.
|
|
39
46
|
*/
|
|
40
47
|
static or(left: LongInt, right: LongInt | number): LongInt;
|
|
41
48
|
/**
|
|
42
49
|
* Carries out a bitwise xor (^) operation on the two numbers.
|
|
43
|
-
* @param left The left number.
|
|
44
|
-
* @param right The right number.
|
|
50
|
+
* @param left - The left number.
|
|
51
|
+
* @param right - The right number.
|
|
45
52
|
* @returns The result of left ^ right.
|
|
46
53
|
*/
|
|
47
54
|
static xor(left: LongInt, right: LongInt | number): LongInt;
|
|
48
55
|
/**
|
|
49
56
|
* Carries out a bitwise not (~) operation on the number.
|
|
50
|
-
* @param number The number to negate.
|
|
57
|
+
* @param number - The number to negate.
|
|
51
58
|
* @returns The result of ~number.
|
|
52
59
|
*/
|
|
53
60
|
static not(number: LongInt): LongInt;
|
|
54
61
|
/**
|
|
55
62
|
* Carries out a bitwise left shift (<<) operation on the number.
|
|
56
|
-
* @param number The number to shift.
|
|
57
|
-
* @param shiftAmount The number of places to shift.
|
|
63
|
+
* @param number - The number to shift.
|
|
64
|
+
* @param shiftAmount - The number of places to shift.
|
|
58
65
|
* @returns The result of number << shiftAmount.
|
|
59
66
|
*/
|
|
60
67
|
static leftShift(number: LongInt, shiftAmount: number): LongInt;
|
|
61
68
|
/**
|
|
62
69
|
* Carries out a bitwise unsigned right shift (>>>) operation on the number.
|
|
63
|
-
* @param number The number to shift.
|
|
64
|
-
* @param shiftAmount The number of places to shift.
|
|
70
|
+
* @param number - The number to shift.
|
|
71
|
+
* @param shiftAmount - The number of places to shift.
|
|
65
72
|
* @returns The result of number >>> shiftAmount.
|
|
66
73
|
*/
|
|
67
74
|
static rightShift(number: LongInt, shiftAmount: number): LongInt;
|
|
68
75
|
/**
|
|
69
76
|
* Carries out a bitwise arithmetic right shift (>>) operation on the number.
|
|
70
|
-
* @param number The number to shift.
|
|
71
|
-
* @param shiftAmount The number of places to shift.
|
|
77
|
+
* @param number - The number to shift.
|
|
78
|
+
* @param shiftAmount - The number of places to shift.
|
|
72
79
|
* @returns The result of number >> shiftAmount.
|
|
73
80
|
*/
|
|
74
81
|
static arithmeticRightShift(number: LongInt, shiftAmount: number): LongInt;
|
|
75
82
|
/**
|
|
76
83
|
* Determines whether or not 2 LongInts have equal values.
|
|
77
|
-
* @param longInt1 The first LongInt.
|
|
78
|
-
* @param longInt2 The second LongInt (can also be a number).
|
|
84
|
+
* @param longInt1 - The first LongInt.
|
|
85
|
+
* @param longInt2 - The second LongInt (can also be a number).
|
|
79
86
|
* @returns Whether or not they are equal.
|
|
80
87
|
*/
|
|
81
88
|
static equals(longInt1: LongInt, longInt2: LongInt | number): boolean;
|
|
82
89
|
/**
|
|
83
90
|
* Creates a new LongInt object with the given value, stretched or truncated to the same size as this.
|
|
84
|
-
* @param longInt The LongInt to match the dimensions of.
|
|
85
|
-
* @param value The LongInt object to use as the value.
|
|
91
|
+
* @param longInt - The LongInt to match the dimensions of.
|
|
92
|
+
* @param value - The LongInt object to use as the value.
|
|
86
93
|
* @returns The new LongInt.
|
|
87
94
|
*/
|
|
88
95
|
static getMatchingLongInt(longInt: LongInt, value: LongInt): LongInt;
|
|
89
96
|
/**
|
|
90
97
|
* Creates a new LongInt object using the given value, stretched or truncated to the same size as this.
|
|
91
|
-
* @param longInt The LongInt to match the dimensions of.
|
|
92
|
-
* @param values An array of 32-bit numbers to use as the value.
|
|
98
|
+
* @param longInt - The LongInt to match the dimensions of.
|
|
99
|
+
* @param values - An array of 32-bit numbers to use as the value.
|
|
93
100
|
* @returns The new LongInt.
|
|
94
101
|
*/
|
|
95
102
|
static getMatchingLongInt(longInt: LongInt, values: number[] | Uint32Array): LongInt;
|
|
96
103
|
/**
|
|
97
104
|
* Creates a new LongInt object using the given value, stretched or truncated to the same size as this.
|
|
98
|
-
* @param longInt The LongInt to match the dimensions of.
|
|
99
|
-
* @param value A 32-bit number to use as the value.
|
|
105
|
+
* @param longInt - The LongInt to match the dimensions of.
|
|
106
|
+
* @param value - A 32-bit number to use as the value.
|
|
100
107
|
* @returns The new LongInt.
|
|
101
108
|
*/
|
|
102
109
|
static getMatchingLongInt(longInt: LongInt, value?: number): LongInt;
|
|
103
110
|
/**
|
|
104
111
|
* Carries out an in-place bitwise and (&) operation on this number and the one provided.
|
|
105
|
-
* @param right The right number.
|
|
112
|
+
* @param right - The right number.
|
|
106
113
|
* @returns The new value of this & right.
|
|
107
114
|
*/
|
|
108
115
|
and(right: LongInt | number): this;
|
|
109
116
|
/**
|
|
110
117
|
* Carries out an in-place bitwise or (|) operation on this number and the one provided.
|
|
111
|
-
* @param right The right number.
|
|
118
|
+
* @param right - The right number.
|
|
112
119
|
* @returns The new value of this | right.
|
|
113
120
|
*/
|
|
114
121
|
or(right: LongInt | number): this;
|
|
115
122
|
/**
|
|
116
123
|
* Carries out an in-place bitwise xor (^) operation on this number and the one provided.
|
|
117
|
-
* @param right The right number.
|
|
124
|
+
* @param right - The right number.
|
|
118
125
|
* @returns The new value of this ^ right.
|
|
119
126
|
*/
|
|
120
127
|
xor(right: LongInt | number): this;
|
|
@@ -125,51 +132,51 @@ export default class LongInt {
|
|
|
125
132
|
not(): this;
|
|
126
133
|
/**
|
|
127
134
|
* Carries out an in-place bitwise left shift (<<) operation on this number.
|
|
128
|
-
* @param shiftAmount The number of places to shift.
|
|
135
|
+
* @param shiftAmount - The number of places to shift.
|
|
129
136
|
* @returns The result of this << shiftAmount.
|
|
130
137
|
*/
|
|
131
138
|
leftShift(shiftAmount: number): this;
|
|
132
139
|
/**
|
|
133
140
|
* Carries out an in-place bitwise unsigned right shift (>>>) operation on this number.
|
|
134
|
-
* @param shiftAmount The number of places to shift.
|
|
141
|
+
* @param shiftAmount - The number of places to shift.
|
|
135
142
|
* @returns The result of this >>> shiftAmount.
|
|
136
|
-
|
|
143
|
+
*/
|
|
137
144
|
rightShift(shiftAmount: number): this;
|
|
138
145
|
/**
|
|
139
146
|
* Carries out an in-place bitwise arithmetic right shift (>>) operation on this number.
|
|
140
|
-
* @param shiftAmount The number of places to shift.
|
|
147
|
+
* @param shiftAmount - The number of places to shift.
|
|
141
148
|
* @returns The result of this >> shiftAmount.
|
|
142
149
|
*/
|
|
143
150
|
arithmeticRightShift(shiftAmount: number): this;
|
|
144
151
|
/**
|
|
145
152
|
* Determines whether or not this LongInt has equal value to another.
|
|
146
|
-
* @param value The LongInt or number to compare to.
|
|
153
|
+
* @param value - The LongInt or number to compare to.
|
|
147
154
|
* @returns Whether or not they are equal.
|
|
148
155
|
*/
|
|
149
156
|
equals(value: LongInt | number): boolean;
|
|
150
157
|
/**
|
|
151
158
|
* Returns a string representation of the LongInt.
|
|
152
|
-
* @param type The base of the string to print.
|
|
159
|
+
* @param type - The base of the string to print.
|
|
153
160
|
* @returns The string representation.
|
|
154
161
|
*/
|
|
155
162
|
toString(type: StringType): string;
|
|
156
163
|
/**
|
|
157
164
|
* Creates a new LongInt object with the given value, stretched or truncated to the same size as this.
|
|
158
|
-
* @param longInt The LongInt object to use as the value.
|
|
165
|
+
* @param longInt - The LongInt object to use as the value.
|
|
159
166
|
* @returns The new LongInt.
|
|
160
167
|
*/
|
|
161
168
|
private getMatchingLongInt;
|
|
162
169
|
/**
|
|
163
170
|
* Shifts the 32-bit number array to the right.
|
|
164
|
-
* @param count How many places to shift the array.
|
|
165
|
-
* @param fillValue The value to fill empty spaces with.
|
|
171
|
+
* @param count - How many places to shift the array.
|
|
172
|
+
* @param fillValue - The value to fill empty spaces with.
|
|
166
173
|
* @returns The new value of this.
|
|
167
174
|
*/
|
|
168
175
|
private shiftArrayRight;
|
|
169
176
|
/**
|
|
170
177
|
* Shifts the 32-bit number array to the left.
|
|
171
|
-
* @param count How many places to shift the array.
|
|
172
|
-
* @param fillValue The value to fill empty spaces with.
|
|
178
|
+
* @param count - How many places to shift the array.
|
|
179
|
+
* @param fillValue - The value to fill empty spaces with.
|
|
173
180
|
* @returns The new value of this.
|
|
174
181
|
*/
|
|
175
182
|
private shiftArrayLeft;
|