isaacscript-common 31.2.1 → 31.2.4

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.
@@ -1035,6 +1035,10 @@ export declare function anyPlayerHoldingItem(): boolean;
1035
1035
  */
1036
1036
  export declare function anyPlayerIs(...matchingCharacters: PlayerType[]): boolean;
1037
1037
 
1038
+ declare type Arr<N extends number, T extends unknown[] = []> = T["length"] extends N ? T : Arr<N, [...T, unknown]>;
1039
+
1040
+ declare type Arr_2<N extends number, T extends unknown[] = []> = T["length"] extends N ? T : Arr_2<N, [...T, unknown]>;
1041
+
1038
1042
  /**
1039
1043
  * Helper function for determining if two arrays contain the exact same elements. Note that this
1040
1044
  * only performs a shallow comparison.
@@ -3196,7 +3200,7 @@ declare class DebugDisplay extends Feature {
3196
3200
  *
3197
3201
  * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
3198
3202
  */
3199
- export declare type Decrement<N extends number> = Tuple<N> extends [unknown, ...infer U] ? U["length"] : never;
3203
+ export declare type Decrement<N extends number> = Arr<N> extends [unknown, ...infer U] ? U["length"] : never;
3200
3204
 
3201
3205
  /**
3202
3206
  * `deepCopy` is a semi-generic deep cloner. It will recursively copy all of the values so that none
@@ -4221,7 +4225,7 @@ export declare function filter<T>(array: T[], func: (value: T, index: number, ar
4221
4225
  * This is named `filterMap` after the Rust function:
4222
4226
  * https://doc.rust-lang.org/std/iter/struct.FilterMap.html
4223
4227
  */
4224
- export declare function filterMap<OldT, NewT>(array: OldT[], func: (element: OldT) => NewT | undefined): NewT[];
4228
+ export declare function filterMap<OldT, NewT>(array: OldT[] | readonly OldT[], func: (element: OldT) => NewT | undefined): NewT[];
4225
4229
 
4226
4230
  /**
4227
4231
  * Helper function for non-TypeScript users to find an element in an array.
@@ -7548,7 +7552,7 @@ export declare function inCrawlSpace(): boolean;
7548
7552
  *
7549
7553
  * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
7550
7554
  */
7551
- export declare type Increment<N extends number> = [...Tuple<N>, unknown]["length"] & number;
7555
+ export declare type Increment<N extends number> = [...Arr_2<N>, unknown]["length"] & number;
7552
7556
 
7553
7557
  /**
7554
7558
  * Helper function to detect if the current room is one of the rooms in the Death Certificate area.
@@ -16965,11 +16969,12 @@ export declare interface TSTLClassMetatable {
16965
16969
  /**
16966
16970
  * Helper type to represent a tuple of length N.
16967
16971
  *
16968
- * This is used by the `Increment` and `Decrement` helper types.
16969
- *
16970
- * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
16972
+ * From:
16973
+ * https://stackoverflow.com/questions/52489261/typescript-can-i-define-an-n-length-tuple-type/52490977#52490977
16971
16974
  */
16972
- export declare type Tuple<N extends number, T extends unknown[] = []> = T["length"] extends N ? T : Tuple<N, [...T, unknown]>;
16975
+ export declare type Tuple<T, N extends number> = N extends N ? number extends N ? T[] : _TupleOf<T, N, []> : never;
16976
+
16977
+ declare type _TupleOf<T, N extends number, R extends unknown[]> = R["length"] extends N ? R : _TupleOf<T, N, [T, ...R]>;
16973
16978
 
16974
16979
  export declare type TupleToIntersection<T extends unknown[]> = T extends [
16975
16980
  infer F,
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 31.2.1
3
+ isaacscript-common 31.2.4
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -53818,10 +53818,6 @@ return ____exports
53818
53818
  end,
53819
53819
  ["src.types.AllButLast"] = function(...)
53820
53820
  local ____exports = {}
53821
- return ____exports
53822
- end,
53823
- ["src.types.Tuple"] = function(...)
53824
- local ____exports = {}
53825
53821
  return ____exports
53826
53822
  end,
53827
53823
  ["src.types.Decrement"] = function(...)
@@ -53858,6 +53854,10 @@ return ____exports
53858
53854
  end,
53859
53855
  ["src.types.StartsWithUppercase"] = function(...)
53860
53856
  local ____exports = {}
53857
+ return ____exports
53858
+ end,
53859
+ ["src.types.Tuple"] = function(...)
53860
+ local ____exports = {}
53861
53861
  return ____exports
53862
53862
  end,
53863
53863
  ["src.types.TupleToUnion"] = function(...)
@@ -53866,10 +53866,23 @@ return ____exports
53866
53866
  end,
53867
53867
  ["src.types.TupleWithLengthBetween"] = function(...)
53868
53868
  local ____exports = {}
53869
+ local zeroOneTwo = {}
53870
+ local oneOneTwo = {"1"}
53871
+ local twoOneTwo = {"1", "2"}
53872
+ local threeOneTwo = {"1", "2", "3"}
53869
53873
  return ____exports
53870
53874
  end,
53871
53875
  ["src.types.TupleWithMaxLength"] = function(...)
53872
53876
  local ____exports = {}
53877
+ local zeroZero = {}
53878
+ local oneZero = {"1"}
53879
+ local zeroOne = {}
53880
+ local oneOne = {"1"}
53881
+ local twoOne = {"1", "2"}
53882
+ local zeroTwo = {}
53883
+ local oneTwo = {"1"}
53884
+ local twoTwo = {"1", "2"}
53885
+ local threeTwo = {"1", "2", "3"}
53873
53886
  return ____exports
53874
53887
  end,
53875
53888
  ["src.types.UnionToIntersection"] = function(...)
@@ -104,7 +104,7 @@ export declare function emptyArray<T>(array: T[]): void;
104
104
  * This is named `filterMap` after the Rust function:
105
105
  * https://doc.rust-lang.org/std/iter/struct.FilterMap.html
106
106
  */
107
- export declare function filterMap<OldT, NewT>(array: OldT[], func: (element: OldT) => NewT | undefined): NewT[];
107
+ export declare function filterMap<OldT, NewT>(array: OldT[] | readonly OldT[], func: (element: OldT) => NewT | undefined): NewT[];
108
108
  /**
109
109
  * Helper function to get all possible combinations of the given array. This includes the
110
110
  * combination of an empty array.
@@ -1 +1 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/functions/array.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAC1B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GACzB,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B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,CAKL;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
@@ -1,8 +1,9 @@
1
- import type { Tuple } from "./Tuple";
2
1
  /**
3
2
  * Helper type to subtract one from a number type.
4
3
  *
5
4
  * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
6
5
  */
7
- export type Decrement<N extends number> = Tuple<N> extends [unknown, ...infer U] ? U["length"] : never;
6
+ export type Decrement<N extends number> = Arr<N> extends [unknown, ...infer U] ? U["length"] : never;
7
+ type Arr<N extends number, T extends unknown[] = []> = T["length"] extends N ? T : Arr<N, [...T, unknown]>;
8
+ export {};
8
9
  //# sourceMappingURL=Decrement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Decrement.d.ts","sourceRoot":"","sources":["../../../src/types/Decrement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,GAC5E,CAAC,CAAC,QAAQ,CAAC,GACX,KAAK,CAAC"}
1
+ {"version":3,"file":"Decrement.d.ts","sourceRoot":"","sources":["../../../src/types/Decrement.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,GAC1E,CAAC,CAAC,QAAQ,CAAC,GACX,KAAK,CAAC;AAEV,KAAK,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACxE,CAAC,GACD,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC"}
@@ -1,8 +1,9 @@
1
- import type { Tuple } from "./Tuple";
2
1
  /**
3
2
  * Helper type to add one to a number type.
4
3
  *
5
4
  * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
6
5
  */
7
- export type Increment<N extends number> = [...Tuple<N>, unknown]["length"] & number;
6
+ export type Increment<N extends number> = [...Arr<N>, unknown]["length"] & number;
7
+ type Arr<N extends number, T extends unknown[] = []> = T["length"] extends N ? T : Arr<N, [...T, unknown]>;
8
+ export {};
8
9
  //# sourceMappingURL=Increment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Increment.d.ts","sourceRoot":"","sources":["../../../src/types/Increment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GACxE,MAAM,CAAC"}
1
+ {"version":3,"file":"Increment.d.ts","sourceRoot":"","sources":["../../../src/types/Increment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GACtE,MAAM,CAAC;AAET,KAAK,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACxE,CAAC,GACD,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC"}
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Helper type to represent a tuple of length N.
3
3
  *
4
- * This is used by the `Increment` and `Decrement` helper types.
5
- *
6
- * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
4
+ * From:
5
+ * https://stackoverflow.com/questions/52489261/typescript-can-i-define-an-n-length-tuple-type/52490977#52490977
7
6
  */
8
- export type Tuple<N extends number, T extends unknown[] = []> = T["length"] extends N ? T : Tuple<N, [...T, unknown]>;
7
+ export type Tuple<T, N extends number> = N extends N ? number extends N ? T[] : _TupleOf<T, N, []> : never;
8
+ type _TupleOf<T, N extends number, R extends unknown[]> = R["length"] extends N ? R : _TupleOf<T, N, [T, ...R]>;
9
+ export {};
9
10
  //# sourceMappingURL=Tuple.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tuple.d.ts","sourceRoot":"","sources":["../../../src/types/Tuple.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,CACf,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,IACtB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"Tuple.d.ts","sourceRoot":"","sources":["../../../src/types/Tuple.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,GAChD,MAAM,SAAS,CAAC,GACd,CAAC,EAAE,GACH,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GACpB,KAAK,CAAC;AACV,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAC3E,CAAC,GACD,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC"}
@@ -1,2 +1,6 @@
1
1
  local ____exports = {}
2
+ local zeroOneTwo = {}
3
+ local oneOneTwo = {"1"}
4
+ local twoOneTwo = {"1", "2"}
5
+ local threeOneTwo = {"1", "2", "3"}
2
6
  return ____exports
@@ -1,2 +1,11 @@
1
1
  local ____exports = {}
2
+ local zeroZero = {}
3
+ local oneZero = {"1"}
4
+ local zeroOne = {}
5
+ local oneOne = {"1"}
6
+ local twoOne = {"1", "2"}
7
+ local zeroTwo = {}
8
+ local oneTwo = {"1"}
9
+ local twoTwo = {"1", "2"}
10
+ local threeTwo = {"1", "2", "3"}
2
11
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "31.2.1",
3
+ "version": "31.2.4",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -244,7 +244,7 @@ export function emptyArray<T>(array: T[]): void {
244
244
  * https://doc.rust-lang.org/std/iter/struct.FilterMap.html
245
245
  */
246
246
  export function filterMap<OldT, NewT>(
247
- array: OldT[],
247
+ array: OldT[] | readonly OldT[],
248
248
  func: (element: OldT) => NewT | undefined,
249
249
  ): NewT[] {
250
250
  const newArray: NewT[] = [];
@@ -1,10 +1,12 @@
1
- import type { Tuple } from "./Tuple";
2
-
3
1
  /**
4
2
  * Helper type to subtract one from a number type.
5
3
  *
6
4
  * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
7
5
  */
8
- export type Decrement<N extends number> = Tuple<N> extends [unknown, ...infer U]
6
+ export type Decrement<N extends number> = Arr<N> extends [unknown, ...infer U]
9
7
  ? U["length"]
10
8
  : never;
9
+
10
+ type Arr<N extends number, T extends unknown[] = []> = T["length"] extends N
11
+ ? T
12
+ : Arr<N, [...T, unknown]>;
@@ -1,9 +1,11 @@
1
- import type { Tuple } from "./Tuple";
2
-
3
1
  /**
4
2
  * Helper type to add one to a number type.
5
3
  *
6
4
  * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
7
5
  */
8
- export type Increment<N extends number> = [...Tuple<N>, unknown]["length"] &
6
+ export type Increment<N extends number> = [...Arr<N>, unknown]["length"] &
9
7
  number;
8
+
9
+ type Arr<N extends number, T extends unknown[] = []> = T["length"] extends N
10
+ ? T
11
+ : Arr<N, [...T, unknown]>;
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * Helper type to represent a tuple of length N.
3
3
  *
4
- * This is used by the `Increment` and `Decrement` helper types.
5
- *
6
- * From: https://stackoverflow.com/questions/54243431/typescript-increment-number-type
4
+ * From:
5
+ * https://stackoverflow.com/questions/52489261/typescript-can-i-define-an-n-length-tuple-type/52490977#52490977
7
6
  */
8
- export type Tuple<
9
- N extends number,
10
- T extends unknown[] = [],
11
- > = T["length"] extends N ? T : Tuple<N, [...T, unknown]>;
7
+ export type Tuple<T, N extends number> = N extends N
8
+ ? number extends N
9
+ ? T[]
10
+ : _TupleOf<T, N, []>
11
+ : never;
12
+ type _TupleOf<T, N extends number, R extends unknown[]> = R["length"] extends N
13
+ ? R
14
+ : _TupleOf<T, N, [T, ...R]>;
@@ -13,3 +13,31 @@ export type TupleWithLengthBetween<
13
13
  > = (T[] | readonly T[]) & {
14
14
  length: Range<MinLength, MaxLength>;
15
15
  };
16
+
17
+ // -----
18
+ // Tests
19
+ // -----
20
+
21
+ /* eslint-disable @typescript-eslint/no-unused-vars */
22
+ /* eslint-disable isaacscript/require-unannotated-const-assertions */
23
+
24
+ // @ts-expect-error Tuple of length 0 with min length 1 and max length 2.
25
+ const zeroOneTwo: TupleWithLengthBetween<string, 1, 2> = [] as const;
26
+
27
+ // Tuple of length 1 with min length 1 and max length 2.
28
+ const oneOneTwo: TupleWithLengthBetween<string, 1, 2> = ["1"] as const;
29
+
30
+ // Tuple of length 2 with min length 1 and max length 2.
31
+ const twoOneTwo: TupleWithLengthBetween<string, 1, 2> = ["1", "2"] as const;
32
+
33
+ // @ts-expect-error Tuple of length 3 with min length 1 and max length 2.
34
+ const threeOneTwo: TupleWithLengthBetween<string, 1, 2> = [
35
+ "1",
36
+ "2",
37
+ "3",
38
+ ] as const;
39
+
40
+ /* eslint-enable @typescript-eslint/no-unused-vars */
41
+ /* eslint-enable isaacscript/require-unannotated-const-assertions */
42
+
43
+ // See "TupleWithMaxLength.ts" for more tests.
@@ -11,3 +11,40 @@ export type TupleWithMaxLength<T, MaxLength extends number> = (
11
11
  ) & {
12
12
  length: Range<0, MaxLength>;
13
13
  };
14
+
15
+ // -----
16
+ // Tests
17
+ // -----
18
+
19
+ /* eslint-disable @typescript-eslint/no-unused-vars */
20
+ /* eslint-disable isaacscript/require-unannotated-const-assertions */
21
+
22
+ // Tuple of length 0 with max length 0.
23
+ const zeroZero: TupleWithMaxLength<string, 0> = [] as const;
24
+
25
+ // @ts-expect-error Tuple of length 1 with max length 0.
26
+ const oneZero: TupleWithMaxLength<string, 0> = ["1"] as const;
27
+
28
+ // Tuple of length 0 with max length 1.
29
+ const zeroOne: TupleWithMaxLength<string, 1> = [] as const;
30
+
31
+ // Tuple of length 1 with max length 1.
32
+ const oneOne: TupleWithMaxLength<string, 1> = ["1"] as const;
33
+
34
+ // @ts-expect-error Tuple of length 2 with max length 1.
35
+ const twoOne: TupleWithMaxLength<string, 1> = ["1", "2"] as const;
36
+
37
+ // Tuple of length 0 with max length 2.
38
+ const zeroTwo: TupleWithMaxLength<string, 2> = [] as const;
39
+
40
+ // Tuple of length 1 with max length 2.
41
+ const oneTwo: TupleWithMaxLength<string, 2> = ["1"] as const;
42
+
43
+ // Tuple of length 2 with max length 2.
44
+ const twoTwo: TupleWithMaxLength<string, 2> = ["1", "2"] as const;
45
+
46
+ // @ts-expect-error Tuple of length 3 with max length 2.
47
+ const threeTwo: TupleWithMaxLength<string, 2> = ["1", "2", "3"] as const;
48
+
49
+ /* eslint-enable @typescript-eslint/no-unused-vars */
50
+ /* eslint-enable isaacscript/require-unannotated-const-assertions */