isaacscript-common 67.1.1 → 67.2.0

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.
@@ -17960,8 +17960,10 @@ export declare function spawnWithSeed(entityType: EntityType, variant: int, subT
17960
17960
  *
17961
17961
  * @param num The number to split into chunks. This must be a positive integer.
17962
17962
  * @param size The size of each chunk. This must be a positive integer.
17963
+ * @param startAtZero Whether to start at 0. Defaults to false. If true, the chunks will start at 0
17964
+ * instead of 1.
17963
17965
  */
17964
- export declare function splitNumber(num: int, size: int): Array<[min: int, max: int]>;
17966
+ export declare function splitNumber(num: int, size: int, startAtZero?: boolean): Array<[min: int, max: int]>;
17965
17967
 
17966
17968
  /**
17967
17969
  * Helper function to check if two sprite layers have the same sprite sheet by using the
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 67.1.1
3
+ isaacscript-common 67.2.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -20311,7 +20311,10 @@ function ____exports.sign(self, n)
20311
20311
  end
20312
20312
  return 0
20313
20313
  end
20314
- function ____exports.splitNumber(self, num, size)
20314
+ function ____exports.splitNumber(self, num, size, startAtZero)
20315
+ if startAtZero == nil then
20316
+ startAtZero = false
20317
+ end
20315
20318
  if num <= 0 then
20316
20319
  error("The number to split needs to be a positive number and is instead: " .. tostring(num))
20317
20320
  end
@@ -20319,11 +20322,11 @@ function ____exports.splitNumber(self, num, size)
20319
20322
  error("The size to split needs to be a positive number and is instead: " .. tostring(num))
20320
20323
  end
20321
20324
  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
20325
+ local start = startAtZero and 0 or 1
20326
+ while start <= num do
20327
+ local ____end = math.min(start + size - 1, num)
20328
+ chunks[#chunks + 1] = {start, ____end}
20329
+ start = start + size
20327
20330
  end
20328
20331
  return chunks
20329
20332
  end
@@ -59,7 +59,9 @@ export declare function sign(n: number): int;
59
59
  *
60
60
  * @param num The number to split into chunks. This must be a positive integer.
61
61
  * @param size The size of each chunk. This must be a positive integer.
62
+ * @param startAtZero Whether to start at 0. Defaults to false. If true, the chunks will start at 0
63
+ * instead of 1.
62
64
  */
63
- export declare function splitNumber(num: int, size: int): Array<[min: int, max: int]>;
65
+ export declare function splitNumber(num: int, size: int, startAtZero?: boolean): Array<[min: int, max: int]>;
64
66
  export declare function tanh(x: number): number;
65
67
  //# 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,CAGx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E,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,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;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,GAAG,EACT,WAAW,UAAQ,GAClB,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAuB7B;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC"}
@@ -125,7 +125,12 @@ end
125
125
  --
126
126
  -- @param num The number to split into chunks. This must be a positive integer.
127
127
  -- @param size The size of each chunk. This must be a positive integer.
128
- function ____exports.splitNumber(self, num, size)
128
+ -- @param startAtZero Whether to start at 0. Defaults to false. If true, the chunks will start at 0
129
+ -- instead of 1.
130
+ function ____exports.splitNumber(self, num, size, startAtZero)
131
+ if startAtZero == nil then
132
+ startAtZero = false
133
+ end
129
134
  if num <= 0 then
130
135
  error("The number to split needs to be a positive number and is instead: " .. tostring(num))
131
136
  end
@@ -133,11 +138,11 @@ function ____exports.splitNumber(self, num, size)
133
138
  error("The size to split needs to be a positive number and is instead: " .. tostring(num))
134
139
  end
135
140
  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
+ local start = startAtZero and 0 or 1
142
+ while start <= num do
143
+ local ____end = math.min(start + size - 1, num)
144
+ chunks[#chunks + 1] = {start, ____end}
145
+ start = start + size
141
146
  end
142
147
  return chunks
143
148
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "67.1.1",
3
+ "version": "67.2.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -156,8 +156,14 @@ export function sign(n: number): int {
156
156
  *
157
157
  * @param num The number to split into chunks. This must be a positive integer.
158
158
  * @param size The size of each chunk. This must be a positive integer.
159
+ * @param startAtZero Whether to start at 0. Defaults to false. If true, the chunks will start at 0
160
+ * instead of 1.
159
161
  */
160
- export function splitNumber(num: int, size: int): Array<[min: int, max: int]> {
162
+ export function splitNumber(
163
+ num: int,
164
+ size: int,
165
+ startAtZero = false,
166
+ ): Array<[min: int, max: int]> {
161
167
  if (num <= 0) {
162
168
  error(
163
169
  `The number to split needs to be a positive number and is instead: ${num}`,
@@ -171,12 +177,12 @@ export function splitNumber(num: int, size: int): Array<[min: int, max: int]> {
171
177
  }
172
178
 
173
179
  const chunks: Array<[number, number]> = [];
174
- let min = 1;
180
+ let start = startAtZero ? 0 : 1;
175
181
 
176
- while (min <= num) {
177
- const max = Math.min(min + size - 1, num);
178
- chunks.push([min, max]);
179
- min = max + 1;
182
+ while (start <= num) {
183
+ const end = Math.min(start + size - 1, num);
184
+ chunks.push([start, end]);
185
+ start += size;
180
186
  }
181
187
 
182
188
  return chunks;