isaacscript-common 67.0.0 → 67.1.1
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/dist/index.rollup.d.ts +18 -2
- package/dist/isaacscript-common.lua +48 -6
- package/dist/src/functions/bitwise.d.ts +1 -1
- package/dist/src/functions/bitwise.d.ts.map +1 -1
- package/dist/src/functions/bitwise.lua +3 -3
- package/dist/src/functions/math.d.ts +15 -0
- package/dist/src/functions/math.d.ts.map +1 -1
- package/dist/src/functions/math.lua +28 -0
- package/dist/src/functions/utils.d.ts +1 -1
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +2 -2
- package/package.json +2 -2
- package/src/functions/bitwise.ts +3 -3
- package/src/functions/math.ts +39 -0
- package/src/functions/utils.ts +2 -2
package/dist/index.rollup.d.ts
CHANGED
|
@@ -1862,7 +1862,7 @@ export declare function countEntities(entityType?: EntityType | -1, variant?: nu
|
|
|
1862
1862
|
* Helper function to count the number of bits that are set to 1 in a binary representation of a
|
|
1863
1863
|
* number.
|
|
1864
1864
|
*/
|
|
1865
|
-
export declare function countSetBits(
|
|
1865
|
+
export declare function countSetBits(num: int): int;
|
|
1866
1866
|
|
|
1867
1867
|
/**
|
|
1868
1868
|
* The base class for a custom callback. Individual custom callbacks (and validation callbacks) will
|
|
@@ -16091,7 +16091,7 @@ export declare function renderTextOnEntity(entity: Entity | GridEntity, text: st
|
|
|
16091
16091
|
* });
|
|
16092
16092
|
* ```
|
|
16093
16093
|
*/
|
|
16094
|
-
export declare function repeat(
|
|
16094
|
+
export declare function repeat(num: int, func: (i: int) => void): void;
|
|
16095
16095
|
|
|
16096
16096
|
/**
|
|
16097
16097
|
* Helper function to reroll an enemy. Use this instead of the vanilla "Game.RerollEnemy" function
|
|
@@ -17947,6 +17947,22 @@ export declare function spawnVoidPortal(gridIndex: int): GridEntity | undefined;
|
|
|
17947
17947
|
*/
|
|
17948
17948
|
export declare function spawnWithSeed(entityType: EntityType, variant: int, subType: int, positionOrGridIndex: Vector | int, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): Entity;
|
|
17949
17949
|
|
|
17950
|
+
/**
|
|
17951
|
+
* Breaks a number into chunks of a given size. This is similar to the `String.split` method, but
|
|
17952
|
+
* for a number instead of a string.
|
|
17953
|
+
*
|
|
17954
|
+
* For example, `splitNumber(90, 25)` would return an array with four elements:
|
|
17955
|
+
*
|
|
17956
|
+
* - [1, 25]
|
|
17957
|
+
* - [26, 50]
|
|
17958
|
+
* - [51, 75]
|
|
17959
|
+
* - [76, 90]
|
|
17960
|
+
*
|
|
17961
|
+
* @param num The number to split into chunks. This must be a positive integer.
|
|
17962
|
+
* @param size The size of each chunk. This must be a positive integer.
|
|
17963
|
+
*/
|
|
17964
|
+
export declare function splitNumber(num: int, size: int): Array<[min: int, max: int]>;
|
|
17965
|
+
|
|
17950
17966
|
/**
|
|
17951
17967
|
* Helper function to check if two sprite layers have the same sprite sheet by using the
|
|
17952
17968
|
* `Sprite.GetTexel` method.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 67.
|
|
3
|
+
isaacscript-common 67.1.1
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -7147,6 +7147,22 @@ ____exports.BatterySubType[____exports.BatterySubType.GOLDEN] = "GOLDEN"
|
|
|
7147
7147
|
--- For `EntityType.PICKUP` (5), `PickupVariant.COLLECTIBLE` (100).
|
|
7148
7148
|
--
|
|
7149
7149
|
-- This is the sub-type of a collectible.
|
|
7150
|
+
--
|
|
7151
|
+
-- This enum is not contiguous. In other words, the enum ranges from `CollectibleType.NULL` (0) to
|
|
7152
|
+
-- `CollectibleType.MOMS_RING` (732), but there is no corresponding `CollectibleType` with the
|
|
7153
|
+
-- following values:
|
|
7154
|
+
--
|
|
7155
|
+
-- 1. 43 (Pills here)
|
|
7156
|
+
-- 2. 61 (Tarot Card)
|
|
7157
|
+
-- 3. 235
|
|
7158
|
+
-- 4. 587 (Menorah)
|
|
7159
|
+
-- 5. 613 (Salt Shaker)
|
|
7160
|
+
-- 6. 620 (Voodoo Pin)
|
|
7161
|
+
-- 7. 630 (Lucky Seven)
|
|
7162
|
+
-- 8. 648 (Pill Crusher)
|
|
7163
|
+
-- 9. 662
|
|
7164
|
+
-- 10. 666
|
|
7165
|
+
-- 11. 718
|
|
7150
7166
|
____exports.CollectibleType = {}
|
|
7151
7167
|
____exports.CollectibleType.NULL = 0
|
|
7152
7168
|
____exports.CollectibleType[____exports.CollectibleType.NULL] = "NULL"
|
|
@@ -8598,6 +8614,8 @@ ____exports.CollectibleType[____exports.CollectibleType.MOMS_RING] = "MOMS_RING"
|
|
|
8598
8614
|
--
|
|
8599
8615
|
-- This enum was renamed from "Card" to be consistent with the `CollectibleType` and `TrinketType`
|
|
8600
8616
|
-- enums.
|
|
8617
|
+
--
|
|
8618
|
+
-- This enum is contiguous. (Every value is satisfied between 0 and 97, inclusive.)
|
|
8601
8619
|
____exports.CardType = {}
|
|
8602
8620
|
____exports.CardType.NULL = 0
|
|
8603
8621
|
____exports.CardType[____exports.CardType.NULL] = "NULL"
|
|
@@ -8798,6 +8816,10 @@ ____exports.CardType[____exports.CardType.SOUL_OF_JACOB_AND_ESAU] = "SOUL_OF_JAC
|
|
|
8798
8816
|
--- For `EntityType.PICKUP` (5), `PickupVariant.TRINKET` (350).
|
|
8799
8817
|
--
|
|
8800
8818
|
-- This is the sub-type of a trinket.
|
|
8819
|
+
--
|
|
8820
|
+
-- This enum is not contiguous. In other words, the enum ranges from `TrinketType.NULL` (0) to
|
|
8821
|
+
-- `TrinketType.SIGIL_OF_BAPHOMET` (189), but there is no corresponding `TrinketType` with a value
|
|
8822
|
+
-- of 47.
|
|
8801
8823
|
____exports.TrinketType = {}
|
|
8802
8824
|
____exports.TrinketType.NULL = 0
|
|
8803
8825
|
____exports.TrinketType[____exports.TrinketType.NULL] = "NULL"
|
|
@@ -9615,6 +9637,8 @@ ____exports.TreasureRoomSubType[____exports.TreasureRoomSubType.KNIFE_PIECE] = "
|
|
|
9615
9637
|
-- The enum is named `BossID` instead of `BossRoomSubType` in order to match the `Entity.GetBossID`,
|
|
9616
9638
|
-- `Room.GetBossID` and `Room.GetSecondBossID` methods.
|
|
9617
9639
|
--
|
|
9640
|
+
-- This enum is contiguous. (Every value is satisfied between 1 and 102, inclusive.)
|
|
9641
|
+
--
|
|
9618
9642
|
-- Also see the `MinibossID` enum.
|
|
9619
9643
|
____exports.BossID = {}
|
|
9620
9644
|
____exports.BossID.MONSTRO = 1
|
|
@@ -12529,6 +12553,7 @@ return ____exports
|
|
|
12529
12553
|
end,
|
|
12530
12554
|
["lua_modules.isaac-typescript-definitions.dist.src.enums.PillEffect"] = function(...)
|
|
12531
12555
|
local ____exports = {}
|
|
12556
|
+
--- This enum is contiguous. (Every value is satisfied between 0 and 49, inclusive.)
|
|
12532
12557
|
____exports.PillEffect = {}
|
|
12533
12558
|
____exports.PillEffect.BAD_GAS = 0
|
|
12534
12559
|
____exports.PillEffect[____exports.PillEffect.BAD_GAS] = "BAD_GAS"
|
|
@@ -15286,6 +15311,7 @@ return ____exports
|
|
|
15286
15311
|
end,
|
|
15287
15312
|
["lua_modules.isaac-typescript-definitions.dist.src.enums.Challenge"] = function(...)
|
|
15288
15313
|
local ____exports = {}
|
|
15314
|
+
--- This enum is contiguous. (Every value is satisfied between 0 and 45, inclusive.)
|
|
15289
15315
|
____exports.Challenge = {}
|
|
15290
15316
|
____exports.Challenge.NULL = 0
|
|
15291
15317
|
____exports.Challenge[____exports.Challenge.NULL] = "NULL"
|
|
@@ -16336,10 +16362,10 @@ function ____exports.isRepentance(self)
|
|
|
16336
16362
|
local getAnimation = classTable.GetAnimation
|
|
16337
16363
|
return isFunction(nil, getAnimation)
|
|
16338
16364
|
end
|
|
16339
|
-
____exports["repeat"] = function(self,
|
|
16365
|
+
____exports["repeat"] = function(self, num, func)
|
|
16340
16366
|
do
|
|
16341
16367
|
local i = 0
|
|
16342
|
-
while i <
|
|
16368
|
+
while i < num do
|
|
16343
16369
|
func(nil, i)
|
|
16344
16370
|
i = i + 1
|
|
16345
16371
|
end
|
|
@@ -20285,6 +20311,22 @@ function ____exports.sign(self, n)
|
|
|
20285
20311
|
end
|
|
20286
20312
|
return 0
|
|
20287
20313
|
end
|
|
20314
|
+
function ____exports.splitNumber(self, num, size)
|
|
20315
|
+
if num <= 0 then
|
|
20316
|
+
error("The number to split needs to be a positive number and is instead: " .. tostring(num))
|
|
20317
|
+
end
|
|
20318
|
+
if size <= 0 then
|
|
20319
|
+
error("The size to split needs to be a positive number and is instead: " .. tostring(num))
|
|
20320
|
+
end
|
|
20321
|
+
local chunks = {}
|
|
20322
|
+
local min = 1
|
|
20323
|
+
while min <= num do
|
|
20324
|
+
local max = math.min(min + size - 1, num)
|
|
20325
|
+
chunks[#chunks + 1] = {min, max}
|
|
20326
|
+
min = max + 1
|
|
20327
|
+
end
|
|
20328
|
+
return chunks
|
|
20329
|
+
end
|
|
20288
20330
|
function ____exports.tanh(self, x)
|
|
20289
20331
|
return (math.exp(x) - math.exp(-x)) / (math.exp(x) + math.exp(-x))
|
|
20290
20332
|
end
|
|
@@ -20642,10 +20684,10 @@ function ____exports.convertDecimalToBinary(self, num, minLength)
|
|
|
20642
20684
|
end
|
|
20643
20685
|
return bits
|
|
20644
20686
|
end
|
|
20645
|
-
function ____exports.countSetBits(self,
|
|
20687
|
+
function ____exports.countSetBits(self, num)
|
|
20646
20688
|
local count = 0
|
|
20647
|
-
while
|
|
20648
|
-
|
|
20689
|
+
while num > 0 do
|
|
20690
|
+
num = num & num - 1
|
|
20649
20691
|
count = count + 1
|
|
20650
20692
|
end
|
|
20651
20693
|
return count
|
|
@@ -20,7 +20,7 @@ export declare function convertDecimalToBinary(num: number, minLength?: int): in
|
|
|
20
20
|
* Helper function to count the number of bits that are set to 1 in a binary representation of a
|
|
21
21
|
* number.
|
|
22
22
|
*/
|
|
23
|
-
export declare function countSetBits(
|
|
23
|
+
export declare function countSetBits(num: int): int;
|
|
24
24
|
/** Helper function to get the value of a specific but in a binary representation of a number. */
|
|
25
25
|
export declare function getKBitOfN(k: int, n: int): int;
|
|
26
26
|
/** Helper function to get the number of bits in a binary representation of a number. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitwise.d.ts","sourceRoot":"","sources":["../../../src/functions/bitwise.ts"],"names":[],"mappings":";;;;AAGA,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,UAAU,EAC5D,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GACxB,QAAQ,CAAC,CAAC,CAAC,CAOb;AAED,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAG1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAqB1E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"bitwise.d.ts","sourceRoot":"","sources":["../../../src/functions/bitwise.ts"],"names":[],"mappings":";;;;AAGA,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,UAAU,EAC5D,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GACxB,QAAQ,CAAC,CAAC,CAAC,CAOb;AAED,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAG1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAqB1E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAS1C;AAED,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,GAAG,CAE9C;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAQzC;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,GAAG,UAAU,EAC1D,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAC3B,QAAQ,CAAC,CAAC,CAAC,CAOb"}
|
|
@@ -49,10 +49,10 @@ function ____exports.convertDecimalToBinary(self, num, minLength)
|
|
|
49
49
|
end
|
|
50
50
|
--- Helper function to count the number of bits that are set to 1 in a binary representation of a
|
|
51
51
|
-- number.
|
|
52
|
-
function ____exports.countSetBits(self,
|
|
52
|
+
function ____exports.countSetBits(self, num)
|
|
53
53
|
local count = 0
|
|
54
|
-
while
|
|
55
|
-
|
|
54
|
+
while num > 0 do
|
|
55
|
+
num = num & num - 1
|
|
56
56
|
count = count + 1
|
|
57
57
|
end
|
|
58
58
|
return count
|
|
@@ -46,5 +46,20 @@ export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent:
|
|
|
46
46
|
export declare function round(num: float, numDecimalPlaces?: number): float;
|
|
47
47
|
/** @returns 1 if n is positive, -1 if n is negative, or 0 if n is 0. */
|
|
48
48
|
export declare function sign(n: number): int;
|
|
49
|
+
/**
|
|
50
|
+
* Breaks a number into chunks of a given size. This is similar to the `String.split` method, but
|
|
51
|
+
* for a number instead of a string.
|
|
52
|
+
*
|
|
53
|
+
* For example, `splitNumber(90, 25)` would return an array with four elements:
|
|
54
|
+
*
|
|
55
|
+
* - [1, 25]
|
|
56
|
+
* - [26, 50]
|
|
57
|
+
* - [51, 75]
|
|
58
|
+
* - [76, 90]
|
|
59
|
+
*
|
|
60
|
+
* @param num The number to split into chunks. This must be a positive integer.
|
|
61
|
+
* @param size The size of each chunk. This must be a positive integer.
|
|
62
|
+
*/
|
|
63
|
+
export declare function splitNumber(num: int, size: int): Array<[min: int, max: int]>;
|
|
49
64
|
export declare function tanh(x: number): number;
|
|
50
65
|
//# sourceMappingURL=math.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/functions/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAEvD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,KAAK,CAGtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,GAAG,EACd,WAAW,SAAI,EACf,WAAW,SAAI,EACf,gBAAgB,YAAe,GAC9B,MAAM,EAAE,CAaV;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAOT;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,KAAK,EACnB,gBAAgB,EAAE,MAAM,EACxB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAgBT;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAGxC;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAGvC;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,KAA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,GAAG,GAAG,OAAO,CAGxC;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAGvC;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM,CAE7D;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,KAAK,GACb,MAAM,CAER;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,gBAAgB,SAAI,GAAG,KAAK,CAG7D;AAED,wEAAwE;AACxE,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAUnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAuB5E;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC"}
|
|
@@ -113,6 +113,34 @@ function ____exports.sign(self, n)
|
|
|
113
113
|
end
|
|
114
114
|
return 0
|
|
115
115
|
end
|
|
116
|
+
--- Breaks a number into chunks of a given size. This is similar to the `String.split` method, but
|
|
117
|
+
-- for a number instead of a string.
|
|
118
|
+
--
|
|
119
|
+
-- For example, `splitNumber(90, 25)` would return an array with four elements:
|
|
120
|
+
--
|
|
121
|
+
-- - [1, 25]
|
|
122
|
+
-- - [26, 50]
|
|
123
|
+
-- - [51, 75]
|
|
124
|
+
-- - [76, 90]
|
|
125
|
+
--
|
|
126
|
+
-- @param num The number to split into chunks. This must be a positive integer.
|
|
127
|
+
-- @param size The size of each chunk. This must be a positive integer.
|
|
128
|
+
function ____exports.splitNumber(self, num, size)
|
|
129
|
+
if num <= 0 then
|
|
130
|
+
error("The number to split needs to be a positive number and is instead: " .. tostring(num))
|
|
131
|
+
end
|
|
132
|
+
if size <= 0 then
|
|
133
|
+
error("The size to split needs to be a positive number and is instead: " .. tostring(num))
|
|
134
|
+
end
|
|
135
|
+
local chunks = {}
|
|
136
|
+
local min = 1
|
|
137
|
+
while min <= num do
|
|
138
|
+
local max = math.min(min + size - 1, num)
|
|
139
|
+
chunks[#chunks + 1] = {min, max}
|
|
140
|
+
min = max + 1
|
|
141
|
+
end
|
|
142
|
+
return chunks
|
|
143
|
+
end
|
|
116
144
|
function ____exports.tanh(self, x)
|
|
117
145
|
return (math.exp(x) - math.exp(-x)) / (math.exp(x) + math.exp(-x))
|
|
118
146
|
end
|
|
@@ -115,7 +115,7 @@ export declare function isRepentance(): boolean;
|
|
|
115
115
|
* });
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
export declare function repeat(
|
|
118
|
+
export declare function repeat(num: int, func: (i: int) => void): void;
|
|
119
119
|
/**
|
|
120
120
|
* Helper function to signify that the enclosing code block is not yet complete. Using this function
|
|
121
121
|
* is similar to writing a "TODO" comment, but it has the benefit of preventing ESLint errors due to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/functions/utils.ts"],"names":[],"mappings":";AAIA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAC7B,CAAC,MAAM,CAAC,GACR;IACE,iFAAiF;CAClF,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAIxC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC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```
|
|
178
|
-
____exports["repeat"] = function(self,
|
|
178
|
+
____exports["repeat"] = function(self, num, func)
|
|
179
179
|
do
|
|
180
180
|
local i = 0
|
|
181
|
-
while i <
|
|
181
|
+
while i < num do
|
|
182
182
|
func(nil, i)
|
|
183
183
|
i = i + 1
|
|
184
184
|
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "67.
|
|
3
|
+
"version": "67.1.1",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"main": "dist/src/index",
|
|
26
26
|
"types": "dist/index.rollup.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^33.0.
|
|
28
|
+
"isaac-typescript-definitions": "^33.0.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/functions/bitwise.ts
CHANGED
|
@@ -55,11 +55,11 @@ export function convertDecimalToBinary(num: number, minLength?: int): int[] {
|
|
|
55
55
|
* Helper function to count the number of bits that are set to 1 in a binary representation of a
|
|
56
56
|
* number.
|
|
57
57
|
*/
|
|
58
|
-
export function countSetBits(
|
|
58
|
+
export function countSetBits(num: int): int {
|
|
59
59
|
let count = 0;
|
|
60
60
|
|
|
61
|
-
while (
|
|
62
|
-
|
|
61
|
+
while (num > 0) {
|
|
62
|
+
num &= num - 1;
|
|
63
63
|
count++;
|
|
64
64
|
}
|
|
65
65
|
|
package/src/functions/math.ts
CHANGED
|
@@ -143,6 +143,45 @@ export function sign(n: number): int {
|
|
|
143
143
|
return 0;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Breaks a number into chunks of a given size. This is similar to the `String.split` method, but
|
|
148
|
+
* for a number instead of a string.
|
|
149
|
+
*
|
|
150
|
+
* For example, `splitNumber(90, 25)` would return an array with four elements:
|
|
151
|
+
*
|
|
152
|
+
* - [1, 25]
|
|
153
|
+
* - [26, 50]
|
|
154
|
+
* - [51, 75]
|
|
155
|
+
* - [76, 90]
|
|
156
|
+
*
|
|
157
|
+
* @param num The number to split into chunks. This must be a positive integer.
|
|
158
|
+
* @param size The size of each chunk. This must be a positive integer.
|
|
159
|
+
*/
|
|
160
|
+
export function splitNumber(num: int, size: int): Array<[min: int, max: int]> {
|
|
161
|
+
if (num <= 0) {
|
|
162
|
+
error(
|
|
163
|
+
`The number to split needs to be a positive number and is instead: ${num}`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (size <= 0) {
|
|
168
|
+
error(
|
|
169
|
+
`The size to split needs to be a positive number and is instead: ${num}`,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const chunks: Array<[number, number]> = [];
|
|
174
|
+
let min = 1;
|
|
175
|
+
|
|
176
|
+
while (min <= num) {
|
|
177
|
+
const max = Math.min(min + size - 1, num);
|
|
178
|
+
chunks.push([min, max]);
|
|
179
|
+
min = max + 1;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return chunks;
|
|
183
|
+
}
|
|
184
|
+
|
|
146
185
|
export function tanh(x: number): number {
|
|
147
186
|
return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x));
|
|
148
187
|
}
|
package/src/functions/utils.ts
CHANGED
|
@@ -206,8 +206,8 @@ export function isRepentance(): boolean {
|
|
|
206
206
|
* });
|
|
207
207
|
* ```
|
|
208
208
|
*/
|
|
209
|
-
export function repeat(
|
|
210
|
-
for (let i = 0; i <
|
|
209
|
+
export function repeat(num: int, func: (i: int) => void): void {
|
|
210
|
+
for (let i = 0; i < num; i++) {
|
|
211
211
|
func(i);
|
|
212
212
|
}
|
|
213
213
|
}
|