isaacscript-common 39.4.3 → 39.4.6

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.
@@ -1,3 +1,5 @@
1
+ import { assertDefined } from "./utils";
2
+
1
3
  export function capitalizeFirstLetter(string: string): string {
2
4
  if (string === "") {
3
5
  return string;
@@ -10,10 +12,99 @@ export function capitalizeFirstLetter(string: string): string {
10
12
  return `${capitalizedFirstLetter}${restOfString}`;
11
13
  }
12
14
 
15
+ /**
16
+ * Helper function to get the closest key from a map based on partial search text. (It only searches
17
+ * through the keys, not the values.)
18
+ *
19
+ * Note that:
20
+ * - Spaces are automatically removed from the search text.
21
+ * - Both the search text and the strings to search through are converted to lowercase before
22
+ * attempting to find a match.
23
+ *
24
+ * For example:
25
+ *
26
+ * ```ts
27
+ * const map = new <string, number>Map([
28
+ * ["foo", 123],
29
+ * ["bar", 456],
30
+ * ]);
31
+ * const searchText = "f";
32
+ * const match = getMapPartialMatch(map, searchText); // match is now equal to ["foo", 123]
33
+ * ```
34
+ *
35
+ * @returns If a match was found, returns a tuple of the map key and value. If a match was not
36
+ * found, returns undefined.
37
+ */
38
+ export function getMapPartialMatch<T>(
39
+ searchText: string,
40
+ map: ReadonlyMap<string, T>,
41
+ ): [string, T] | undefined {
42
+ const keys = [...map.keys()];
43
+
44
+ const matchingKey = getPartialMatch(searchText, keys);
45
+ if (matchingKey === undefined) {
46
+ return undefined;
47
+ }
48
+
49
+ const value = map.get(matchingKey);
50
+ assertDefined(
51
+ value,
52
+ `Failed to get the map value corresponding to the partial match of: ${matchingKey}`,
53
+ );
54
+
55
+ return [matchingKey, value];
56
+ }
57
+
58
+ /**
59
+ * Helper function to get the closest key from an object based on partial search text. (It only
60
+ * searches through the keys, not the values.)
61
+ *
62
+ * Note that:
63
+ * - Spaces are automatically removed from the search text.
64
+ * - Both the search text and the strings to search through are converted to lowercase before
65
+ * attempting to find a match.
66
+ *
67
+ * For example:
68
+ *
69
+ * ```ts
70
+ * const object = {
71
+ * foo: 123,
72
+ * bar: 456,
73
+ * };
74
+ * const searchText = "f";
75
+ * const match = getObjectPartialMatch(object, searchText); // match is now equal to ["foo", 123]
76
+ * ```
77
+ *
78
+ * @returns If a match was found, returns a tuple of the map key and value. If a match was not
79
+ * found, returns undefined.
80
+ */
81
+ export function getObjectPartialMatch<T>(
82
+ searchText: string,
83
+ object: Record<string, T>,
84
+ ): [string, T] | undefined {
85
+ const keys = Object.keys(object);
86
+
87
+ const matchingKey = getPartialMatch(searchText, keys);
88
+ if (matchingKey === undefined) {
89
+ return undefined;
90
+ }
91
+
92
+ const value = object[matchingKey];
93
+ assertDefined(
94
+ value,
95
+ `Failed to get the object value corresponding to the partial match of: ${matchingKey}`,
96
+ );
97
+
98
+ return [matchingKey, value];
99
+ }
100
+
13
101
  /**
14
102
  * Helper function to get the closest value from an array of strings based on partial search text.
15
- * For the purposes of this function, both search text and the array are converted to lowercase
16
- * before attempting to find a match.
103
+ *
104
+ * Note that:
105
+ * - Spaces are automatically removed from the search text.
106
+ * - Both the search text and the strings to search through are converted to lowercase before
107
+ * attempting to find a match.
17
108
  *
18
109
  * For example:
19
110
  *
@@ -1,193 +0,0 @@
1
- export * from "./classes/DefaultMap";
2
- export * from "./classes/ModFeature";
3
- export * from "./classes/ModUpgraded";
4
- export * from "./core/cachedClasses";
5
- export * from "./core/constants";
6
- export * from "./core/constantsFirstLast";
7
- export * from "./core/upgradeMod";
8
- export * from "./enums/AmbushType";
9
- export * from "./enums/CornerType";
10
- export * from "./enums/HealthType";
11
- export * from "./enums/ISCFeature";
12
- export * from "./enums/LadderSubTypeCustom";
13
- export * from "./enums/ModCallbackCustom";
14
- export * from "./enums/MysteriousPaperEffect";
15
- export * from "./enums/PlayerStat";
16
- export * from "./enums/PocketItemType";
17
- export * from "./enums/RockAltType";
18
- export * from "./enums/SaveDataKey";
19
- export * from "./enums/SerializationType";
20
- export * from "./enums/SlotDestructionType";
21
- export * from "./functions/ambush";
22
- export * from "./functions/array";
23
- export * from "./functions/arrayLua";
24
- export * from "./functions/benchmark";
25
- export * from "./functions/bitSet128";
26
- export * from "./functions/bitwise";
27
- export * from "./functions/bombs";
28
- export * from "./functions/bosses";
29
- export * from "./functions/cards";
30
- export * from "./functions/challenges";
31
- export * from "./functions/characters";
32
- export * from "./functions/charge";
33
- export * from "./functions/chargeBar";
34
- export * from "./functions/collectibleTag";
35
- export * from "./functions/collectibles";
36
- export * from "./functions/color";
37
- export * from "./functions/console";
38
- export * from "./functions/curses";
39
- export * from "./functions/debugFunctions";
40
- export * from "./functions/decorators";
41
- export * from "./functions/deepCopy";
42
- export * from "./functions/deepCopyTests";
43
- export * from "./functions/dimensions";
44
- export * from "./functions/direction";
45
- export * from "./functions/doors";
46
- export * from "./functions/easing";
47
- export * from "./functions/effects";
48
- export * from "./functions/emptyRoom";
49
- export * from "./functions/entities";
50
- export * from "./functions/entitiesSpecific";
51
- export * from "./functions/entityTypes";
52
- export * from "./functions/enums";
53
- export * from "./functions/external";
54
- export * from "./functions/familiars";
55
- export * from "./functions/flag";
56
- export * from "./functions/globals";
57
- export * from "./functions/gridEntities";
58
- export * from "./functions/gridEntitiesSpecific";
59
- export * from "./functions/gridIndex";
60
- export * from "./functions/hex";
61
- export * from "./functions/input";
62
- export * from "./functions/isaacAPIClass";
63
- export * from "./functions/itemPool";
64
- export * from "./functions/jsonHelpers";
65
- export * from "./functions/jsonRoom";
66
- export * from "./functions/kColor";
67
- export * from "./functions/language";
68
- export * from "./functions/level";
69
- export * from "./functions/levelGrid";
70
- export * from "./functions/log";
71
- export * from "./functions/logEntities";
72
- export * from "./functions/logMisc";
73
- export * from "./functions/map";
74
- export * from "./functions/math";
75
- export * from "./functions/merge";
76
- export * from "./functions/mergeTests";
77
- export * from "./functions/minimap";
78
- export * from "./functions/modFeatures";
79
- export * from "./functions/newArray";
80
- export * from "./functions/nextStage";
81
- export * from "./functions/npcDataStructures";
82
- export * from "./functions/npcs";
83
- export * from "./functions/pickupVariants";
84
- export * from "./functions/pickups";
85
- export * from "./functions/pickupsSpecific";
86
- export * from "./functions/pills";
87
- export * from "./functions/playerCenter";
88
- export * from "./functions/playerDataStructures";
89
- export * from "./functions/playerHealth";
90
- export * from "./functions/playerIndex";
91
- export * from "./functions/players";
92
- export * from "./functions/pocketItems";
93
- export * from "./functions/positionVelocity";
94
- export * from "./functions/pressurePlate";
95
- export * from "./functions/projectiles";
96
- export * from "./functions/random";
97
- export * from "./functions/readOnly";
98
- export * from "./functions/render";
99
- export * from "./functions/revive";
100
- export * from "./functions/rng";
101
- export * from "./functions/rockAlt";
102
- export * from "./functions/roomData";
103
- export * from "./functions/roomGrid";
104
- export * from "./functions/roomShape";
105
- export * from "./functions/roomShapeWalls";
106
- export * from "./functions/roomTransition";
107
- export * from "./functions/rooms";
108
- export * from "./functions/run";
109
- export * from "./functions/seeds";
110
- export * from "./functions/serialization";
111
- export * from "./functions/set";
112
- export * from "./functions/slots";
113
- export * from "./functions/sort";
114
- export * from "./functions/sound";
115
- export * from "./functions/spawnCollectible";
116
- export * from "./functions/sprites";
117
- export * from "./functions/stage";
118
- export * from "./functions/stats";
119
- export * from "./functions/string";
120
- export * from "./functions/table";
121
- export * from "./functions/tears";
122
- export * from "./functions/transformations";
123
- export * from "./functions/trinketGive";
124
- export * from "./functions/trinkets";
125
- export * from "./functions/tstlClass";
126
- export * from "./functions/types";
127
- export * from "./functions/ui";
128
- export * from "./functions/utils";
129
- export * from "./functions/vector";
130
- export * from "./functions/weighted";
131
- export * from "./interfaces/ChargeBarSprites";
132
- export * from "./interfaces/Corner";
133
- export * from "./interfaces/CustomStageTSConfig";
134
- export * from "./interfaces/GridEntityCustomData";
135
- export * from "./interfaces/JSONRoomsFile";
136
- export * from "./interfaces/PlayerHealth";
137
- export * from "./interfaces/PlayerStats";
138
- export * from "./interfaces/PocketItemDescription";
139
- export * from "./interfaces/RoomDescription";
140
- export * from "./interfaces/SaveData";
141
- export * from "./interfaces/StageHistoryEntry";
142
- export * from "./interfaces/TSTLClassMetatable";
143
- export * from "./interfaces/TrinketSituation";
144
- export * from "./maps/cardNameToTypeMap";
145
- export * from "./maps/characterNameToTypeMap";
146
- export * from "./maps/pillNameToEffectMap";
147
- export * from "./maps/roomNameToTypeMap";
148
- export * from "./maps/transformationNameToPlayerFormMap";
149
- export * from "./objects/colors";
150
- export * from "./objects/kColors";
151
- export * from "./types/AddSubtract";
152
- export * from "./types/AllButFirst";
153
- export * from "./types/AllButLast";
154
- export * from "./types/AnyClass";
155
- export * from "./types/AnyEntity";
156
- export * from "./types/AnyFunction";
157
- export * from "./types/AnyGridEntity";
158
- export * from "./types/ConversionHeartSubType";
159
- export * from "./types/Decrement";
160
- export * from "./types/ERange";
161
- export * from "./types/EntityID";
162
- export * from "./types/Expand";
163
- export * from "./types/FunctionTuple";
164
- export * from "./types/GridEntityID";
165
- export * from "./types/HasFunction";
166
- export * from "./types/IRange";
167
- export * from "./types/Immutable";
168
- export * from "./types/Increment";
169
- export * from "./types/LowercaseKeys";
170
- export * from "./types/NaturalNumbersLessThan";
171
- export * from "./types/NaturalNumbersLessThanOrEqualTo";
172
- export * from "./types/PickingUpItem";
173
- export * from "./types/PickupIndex";
174
- export * from "./types/PlayerIndex";
175
- export * from "./types/PossibleStatType";
176
- export * from "./types/PublicInterface";
177
- export * from "./types/ReadonlyMap";
178
- export * from "./types/ReadonlySet";
179
- export * from "./types/StartsWithLowercase";
180
- export * from "./types/StartsWithUppercase";
181
- export * from "./types/TSTLClass";
182
- export * from "./types/Tuple";
183
- export * from "./types/TupleKeys";
184
- export * from "./types/TupleToIntersection";
185
- export * from "./types/TupleToUnion";
186
- export * from "./types/TupleWithLengthBetween";
187
- export * from "./types/TupleWithMaxLength";
188
- export * from "./types/UnionToIntersection";
189
- export * from "./types/UppercaseKeys";
190
- export * from "./types/WeightedArray";
191
- export * from "./types/Writable";
192
- export * from "isaac-typescript-definitions";
193
- //# sourceMappingURL=indexLua.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"indexLua.d.ts","sourceRoot":"","sources":["../../../../../packages/isaacscript-common/src/indexLua.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC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