isaacscript-common 80.0.0 → 80.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.
@@ -58,10 +58,46 @@ export declare function getSetCombinations<T>(set: Set<T> | ReadonlySet<T>, incl
58
58
  /**
59
59
  * Helper function to get a sorted array based on the contents of a set.
60
60
  *
61
- * Normally, set values are returned in a random order, so use this function when the ordering of
61
+ * Normally, set values are returned in insertion order, so use this function when the ordering of
62
62
  * the contents is important.
63
63
  */
64
64
  export declare function getSortedSetValues<T>(set: Set<T> | ReadonlySet<T>): T[];
65
+ /**
66
+ * Helper function to convert the keys of an object to a read-only set.
67
+ *
68
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
69
+ * hood.
70
+ *
71
+ * Also see the `objectKeysToSet` function.
72
+ */
73
+ export declare function objectKeysToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
74
+ /**
75
+ * Helper function to convert the keys of an object to a set.
76
+ *
77
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
78
+ * hood.
79
+ *
80
+ * Also see the `objectKeysToReadonlySet` function.
81
+ */
82
+ export declare function objectKeysToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<K>;
83
+ /**
84
+ * Helper function to convert the values of an object to a read-only set.
85
+ *
86
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
87
+ * hood.
88
+ *
89
+ * Also see the `objectValuesToSet` function.
90
+ */
91
+ export declare function objectValuesToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
92
+ /**
93
+ * Helper function to convert the values of an object to a set.
94
+ *
95
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
96
+ * hood.
97
+ *
98
+ * Also see the `objectValuesToReadonlySet` function.
99
+ */
100
+ export declare function objectValuesToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<V>;
65
101
  /**
66
102
  * Helper function to add one or more elements to a set at once without having to repeatedly call
67
103
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,GAAG,CAAC,CAAC,CAAC,CAQR;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,CAAC,EACD,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEtC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACrE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,GAAG,CAAC,CAAC,CAAC,CAQR;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,EAAE,GAAG,IAAI,CAI7D;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAC5B,GAAG,QAAQ,EAAE,CAAC,EAAE,GACf,OAAO,CAET;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAGrE"}
@@ -5,6 +5,8 @@ local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
6
6
  local __TS__Spread = ____lualib.__TS__Spread
7
7
  local __TS__ArraySort = ____lualib.__TS__ArraySort
8
+ local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
9
+ local __TS__ObjectValues = ____lualib.__TS__ObjectValues
8
10
  local __TS__ArraySome = ____lualib.__TS__ArraySome
9
11
  local ____exports = {}
10
12
  local ____ReadonlySet = require("types.ReadonlySet")
@@ -17,20 +19,45 @@ local ____types = require("functions.types")
17
19
  local isPrimitive = ____types.isPrimitive
18
20
  --- Helper function to get a sorted array based on the contents of a set.
19
21
  --
20
- -- Normally, set values are returned in a random order, so use this function when the ordering of
22
+ -- Normally, set values are returned in insertion order, so use this function when the ordering of
21
23
  -- the contents is important.
22
24
  function ____exports.getSortedSetValues(self, set)
23
- local values = set:values()
24
- local array = {__TS__Spread(values)}
25
- local firstElement = array[1]
25
+ local values = {__TS__Spread(set)}
26
+ local firstElement = values[1]
26
27
  if firstElement ~= nil then
27
28
  local arrayType = type(firstElement)
28
29
  if not isPrimitive(nil, arrayType) then
29
30
  error(("Failed to get the sorted set values because the provided set was of type \"" .. tostring(arrayType)) .. "\". Having sets with non-primitive types doesn't make much sense in general, so you might need to rethink what you are doing.")
30
31
  end
31
32
  end
32
- __TS__ArraySort(array)
33
- return array
33
+ __TS__ArraySort(values)
34
+ return values
35
+ end
36
+ --- Helper function to convert the keys of an object to a set.
37
+ --
38
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
39
+ -- hood.
40
+ --
41
+ -- Also see the `objectKeysToReadonlySet` function.
42
+ function ____exports.objectKeysToSet(self, object)
43
+ local set = __TS__New(Set)
44
+ for ____, key in ipairs(__TS__ObjectKeys(object)) do
45
+ set:add(key)
46
+ end
47
+ return set
48
+ end
49
+ --- Helper function to convert the values of an object to a set.
50
+ --
51
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
52
+ -- hood.
53
+ --
54
+ -- Also see the `objectValuesToReadonlySet` function.
55
+ function ____exports.objectValuesToSet(self, object)
56
+ local set = __TS__New(Set)
57
+ for ____, key in ipairs(__TS__ObjectValues(object)) do
58
+ set:add(key)
59
+ end
60
+ return set
34
61
  end
35
62
  --- Helper function to add all of the values in one set to another set. The first set passed will be
36
63
  -- modified in place.
@@ -39,7 +66,7 @@ end
39
66
  function ____exports.addSetsToSet(self, mainSet, ...)
40
67
  local setsToAdd = {...}
41
68
  for ____, set in ipairs(setsToAdd) do
42
- for ____, value in __TS__Iterator(set:values()) do
69
+ for ____, value in __TS__Iterator(set) do
43
70
  mainSet:add(value)
44
71
  end
45
72
  end
@@ -51,7 +78,7 @@ function ____exports.combineSets(self, ...)
51
78
  local sets = {...}
52
79
  local newSet = __TS__New(Set)
53
80
  for ____, set in ipairs(sets) do
54
- for ____, value in __TS__Iterator(set:values()) do
81
+ for ____, value in __TS__Iterator(set) do
55
82
  newSet:add(value)
56
83
  end
57
84
  end
@@ -60,7 +87,7 @@ end
60
87
  --- Helper function to copy a set. (You can also use a Set constructor to accomplish this task.)
61
88
  function ____exports.copySet(self, oldSet)
62
89
  local newSet = __TS__New(Set)
63
- for ____, value in __TS__Iterator(oldSet:values()) do
90
+ for ____, value in __TS__Iterator(oldSet) do
64
91
  newSet:add(value)
65
92
  end
66
93
  return newSet
@@ -72,7 +99,7 @@ end
72
99
  function ____exports.deleteSetsFromSet(self, mainSet, ...)
73
100
  local setsToRemove = {...}
74
101
  for ____, set in ipairs(setsToRemove) do
75
- for ____, value in __TS__Iterator(set:values()) do
102
+ for ____, value in __TS__Iterator(set) do
76
103
  mainSet:delete(value)
77
104
  end
78
105
  end
@@ -119,6 +146,24 @@ function ____exports.getSetCombinations(self, set, includeEmptyArray)
119
146
  function(____, array) return __TS__New(ReadonlySet, array) end
120
147
  )
121
148
  end
149
+ --- Helper function to convert the keys of an object to a read-only set.
150
+ --
151
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
152
+ -- hood.
153
+ --
154
+ -- Also see the `objectKeysToSet` function.
155
+ function ____exports.objectKeysToReadonlySet(self, object)
156
+ return ____exports.objectKeysToSet(nil, object)
157
+ end
158
+ --- Helper function to convert the values of an object to a read-only set.
159
+ --
160
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
161
+ -- hood.
162
+ --
163
+ -- Also see the `objectValuesToSet` function.
164
+ function ____exports.objectValuesToReadonlySet(self, object)
165
+ return ____exports.objectValuesToSet(nil, object)
166
+ end
122
167
  --- Helper function to add one or more elements to a set at once without having to repeatedly call
123
168
  -- the `Set.add` method.
124
169
  --
@@ -143,7 +188,7 @@ function ____exports.setHas(self, set, ...)
143
188
  end
144
189
  --- Helper function to sum every value in a set together.
145
190
  function ____exports.sumSet(self, set)
146
- local values = {__TS__Spread(set:values())}
191
+ local values = {__TS__Spread(set)}
147
192
  return sumArray(nil, values)
148
193
  end
149
194
  return ____exports
@@ -98,4 +98,5 @@ export declare function removeSubstring(string: string, ...substrings: string[])
98
98
  export declare function trimPrefix(string: string, prefix: string): string;
99
99
  /** Helper function to trim a suffix from a string, if it exists. Returns the trimmed string. */
100
100
  export declare function trimSuffix(string: string, prefix: string): string;
101
+ export declare function uncapitalizeFirstLetter(string: string): string;
101
102
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":";AAEA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU5D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAezB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GACxB,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAezB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,GAAG,SAAS,CAYpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GACtD;IACE,YAAY,EAAE,GAAG,CAA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;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,GAAG,SAAS,CAYpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GACtD;IACE,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,EAAE,GAAG,CAAC;CACnB,GACD,SAAS,CAyBZ;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAGR;AAED,8FAA8F;AAC9F,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,GAAG,UAAU,EAAE,MAAM,EAAE,GACtB,MAAM,CAMR;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU9D"}
@@ -169,4 +169,13 @@ function ____exports.trimSuffix(self, ____string, prefix)
169
169
  local endCharacter = #____string - #prefix
170
170
  return __TS__StringSlice(____string, 0, endCharacter)
171
171
  end
172
+ function ____exports.uncapitalizeFirstLetter(self, ____string)
173
+ if ____string == "" then
174
+ return ____string
175
+ end
176
+ local firstCharacter = string.sub(____string, 1, 1)
177
+ local uncapitalizedFirstLetter = string.lower(firstCharacter)
178
+ local restOfString = string.sub(____string, 2)
179
+ return uncapitalizedFirstLetter .. restOfString
180
+ end
172
181
  return ____exports
@@ -7874,7 +7874,7 @@ export declare function getSlots(slotVariant?: SlotVariant | -1, subType?: numbe
7874
7874
  /**
7875
7875
  * Helper function to get a sorted array based on the contents of a set.
7876
7876
  *
7877
- * Normally, set values are returned in a random order, so use this function when the ordering of
7877
+ * Normally, set values are returned in insertion order, so use this function when the ordering of
7878
7878
  * the contents is important.
7879
7879
  */
7880
7880
  export declare function getSortedSetValues<T>(set: Set<T> | ReadonlySet<T>): T[];
@@ -14889,6 +14889,26 @@ export declare const NUM_VANILLA_PILL_EFFECTS: int;
14889
14889
  /** Calculated from the `TrinketType` enum. (`TrinketType.NULL` is not included.) */
14890
14890
  export declare const NUM_VANILLA_TRINKET_TYPES: number;
14891
14891
 
14892
+ /**
14893
+ * Helper function to convert the keys of an object to a read-only set.
14894
+ *
14895
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
14896
+ * hood.
14897
+ *
14898
+ * Also see the `objectKeysToSet` function.
14899
+ */
14900
+ export declare function objectKeysToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
14901
+
14902
+ /**
14903
+ * Helper function to convert the keys of an object to a set.
14904
+ *
14905
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
14906
+ * hood.
14907
+ *
14908
+ * Also see the `objectKeysToReadonlySet` function.
14909
+ */
14910
+ export declare function objectKeysToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<K>;
14911
+
14892
14912
  /**
14893
14913
  * Helper function to convert an object to a map.
14894
14914
  *
@@ -14919,6 +14939,26 @@ export declare function objectToMap<K extends string | number | symbol, V>(objec
14919
14939
  */
14920
14940
  export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
14921
14941
 
14942
+ /**
14943
+ * Helper function to convert the values of an object to a read-only set.
14944
+ *
14945
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
14946
+ * hood.
14947
+ *
14948
+ * Also see the `objectValuesToSet` function.
14949
+ */
14950
+ export declare function objectValuesToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
14951
+
14952
+ /**
14953
+ * Helper function to convert the values of an object to a set.
14954
+ *
14955
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
14956
+ * hood.
14957
+ *
14958
+ * Also see the `objectValuesToReadonlySet` function.
14959
+ */
14960
+ export declare function objectValuesToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<V>;
14961
+
14922
14962
  /** Helper function to see if the player is playing any challenge. */
14923
14963
  export declare function onAnyChallenge(): boolean;
14924
14964
 
@@ -18970,6 +19010,8 @@ export declare type TupleWithMaxLength<T, MaxLength extends number> = (T[] | rea
18970
19010
  */
18971
19011
  export declare const UI_HEART_WIDTH = 12;
18972
19012
 
19013
+ export declare function uncapitalizeFirstLetter(string: string): string;
19014
+
18973
19015
  /** Helper type to convert a union to an intersection. */
18974
19016
  export declare type UnionToIntersection<U> = (U extends U ? (u: U) => 0 : never) extends (i: infer I) => 0 ? Extract<I, U> : never;
18975
19017
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 79.3.0
3
+ isaacscript-common 80.1.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -18095,6 +18095,15 @@ function ____exports.trimSuffix(self, ____string, prefix)
18095
18095
  local endCharacter = #____string - #prefix
18096
18096
  return __TS__StringSlice(____string, 0, endCharacter)
18097
18097
  end
18098
+ function ____exports.uncapitalizeFirstLetter(self, ____string)
18099
+ if ____string == "" then
18100
+ return ____string
18101
+ end
18102
+ local firstCharacter = string.sub(____string, 1, 1)
18103
+ local uncapitalizedFirstLetter = string.lower(firstCharacter)
18104
+ local restOfString = string.sub(____string, 2)
18105
+ return uncapitalizedFirstLetter .. restOfString
18106
+ end
18098
18107
  return ____exports
18099
18108
  end,
18100
18109
  ["functions.isaacAPIClass"] = function(...)
@@ -44239,6 +44248,8 @@ local __TS__New = ____lualib.__TS__New
44239
44248
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
44240
44249
  local __TS__Spread = ____lualib.__TS__Spread
44241
44250
  local __TS__ArraySort = ____lualib.__TS__ArraySort
44251
+ local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
44252
+ local __TS__ObjectValues = ____lualib.__TS__ObjectValues
44242
44253
  local __TS__ArraySome = ____lualib.__TS__ArraySome
44243
44254
  local ____exports = {}
44244
44255
  local ____ReadonlySet = require("types.ReadonlySet")
@@ -44251,20 +44262,45 @@ local ____types = require("functions.types")
44251
44262
  local isPrimitive = ____types.isPrimitive
44252
44263
  --- Helper function to get a sorted array based on the contents of a set.
44253
44264
  --
44254
- -- Normally, set values are returned in a random order, so use this function when the ordering of
44265
+ -- Normally, set values are returned in insertion order, so use this function when the ordering of
44255
44266
  -- the contents is important.
44256
44267
  function ____exports.getSortedSetValues(self, set)
44257
- local values = set:values()
44258
- local array = {__TS__Spread(values)}
44259
- local firstElement = array[1]
44268
+ local values = {__TS__Spread(set)}
44269
+ local firstElement = values[1]
44260
44270
  if firstElement ~= nil then
44261
44271
  local arrayType = type(firstElement)
44262
44272
  if not isPrimitive(nil, arrayType) then
44263
44273
  error(("Failed to get the sorted set values because the provided set was of type \"" .. tostring(arrayType)) .. "\". Having sets with non-primitive types doesn't make much sense in general, so you might need to rethink what you are doing.")
44264
44274
  end
44265
44275
  end
44266
- __TS__ArraySort(array)
44267
- return array
44276
+ __TS__ArraySort(values)
44277
+ return values
44278
+ end
44279
+ --- Helper function to convert the keys of an object to a set.
44280
+ --
44281
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
44282
+ -- hood.
44283
+ --
44284
+ -- Also see the `objectKeysToReadonlySet` function.
44285
+ function ____exports.objectKeysToSet(self, object)
44286
+ local set = __TS__New(Set)
44287
+ for ____, key in ipairs(__TS__ObjectKeys(object)) do
44288
+ set:add(key)
44289
+ end
44290
+ return set
44291
+ end
44292
+ --- Helper function to convert the values of an object to a set.
44293
+ --
44294
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
44295
+ -- hood.
44296
+ --
44297
+ -- Also see the `objectValuesToReadonlySet` function.
44298
+ function ____exports.objectValuesToSet(self, object)
44299
+ local set = __TS__New(Set)
44300
+ for ____, key in ipairs(__TS__ObjectValues(object)) do
44301
+ set:add(key)
44302
+ end
44303
+ return set
44268
44304
  end
44269
44305
  --- Helper function to add all of the values in one set to another set. The first set passed will be
44270
44306
  -- modified in place.
@@ -44273,7 +44309,7 @@ end
44273
44309
  function ____exports.addSetsToSet(self, mainSet, ...)
44274
44310
  local setsToAdd = {...}
44275
44311
  for ____, set in ipairs(setsToAdd) do
44276
- for ____, value in __TS__Iterator(set:values()) do
44312
+ for ____, value in __TS__Iterator(set) do
44277
44313
  mainSet:add(value)
44278
44314
  end
44279
44315
  end
@@ -44285,7 +44321,7 @@ function ____exports.combineSets(self, ...)
44285
44321
  local sets = {...}
44286
44322
  local newSet = __TS__New(Set)
44287
44323
  for ____, set in ipairs(sets) do
44288
- for ____, value in __TS__Iterator(set:values()) do
44324
+ for ____, value in __TS__Iterator(set) do
44289
44325
  newSet:add(value)
44290
44326
  end
44291
44327
  end
@@ -44294,7 +44330,7 @@ end
44294
44330
  --- Helper function to copy a set. (You can also use a Set constructor to accomplish this task.)
44295
44331
  function ____exports.copySet(self, oldSet)
44296
44332
  local newSet = __TS__New(Set)
44297
- for ____, value in __TS__Iterator(oldSet:values()) do
44333
+ for ____, value in __TS__Iterator(oldSet) do
44298
44334
  newSet:add(value)
44299
44335
  end
44300
44336
  return newSet
@@ -44306,7 +44342,7 @@ end
44306
44342
  function ____exports.deleteSetsFromSet(self, mainSet, ...)
44307
44343
  local setsToRemove = {...}
44308
44344
  for ____, set in ipairs(setsToRemove) do
44309
- for ____, value in __TS__Iterator(set:values()) do
44345
+ for ____, value in __TS__Iterator(set) do
44310
44346
  mainSet:delete(value)
44311
44347
  end
44312
44348
  end
@@ -44353,6 +44389,24 @@ function ____exports.getSetCombinations(self, set, includeEmptyArray)
44353
44389
  function(____, array) return __TS__New(ReadonlySet, array) end
44354
44390
  )
44355
44391
  end
44392
+ --- Helper function to convert the keys of an object to a read-only set.
44393
+ --
44394
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
44395
+ -- hood.
44396
+ --
44397
+ -- Also see the `objectKeysToSet` function.
44398
+ function ____exports.objectKeysToReadonlySet(self, object)
44399
+ return ____exports.objectKeysToSet(nil, object)
44400
+ end
44401
+ --- Helper function to convert the values of an object to a read-only set.
44402
+ --
44403
+ -- Note that the set values will be inserted in a random order, due to how `pairs` works under the
44404
+ -- hood.
44405
+ --
44406
+ -- Also see the `objectValuesToSet` function.
44407
+ function ____exports.objectValuesToReadonlySet(self, object)
44408
+ return ____exports.objectValuesToSet(nil, object)
44409
+ end
44356
44410
  --- Helper function to add one or more elements to a set at once without having to repeatedly call
44357
44411
  -- the `Set.add` method.
44358
44412
  --
@@ -44377,7 +44431,7 @@ function ____exports.setHas(self, set, ...)
44377
44431
  end
44378
44432
  --- Helper function to sum every value in a set together.
44379
44433
  function ____exports.sumSet(self, set)
44380
- local values = {__TS__Spread(set:values())}
44434
+ local values = {__TS__Spread(set)}
44381
44435
  return sumArray(nil, values)
44382
44436
  end
44383
44437
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "80.0.0",
3
+ "version": "80.2.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -13,7 +13,7 @@ export function addSetsToSet<T>(
13
13
  ...setsToAdd: Array<Set<T> | ReadonlySet<T>>
14
14
  ): void {
15
15
  for (const set of setsToAdd) {
16
- for (const value of set.values()) {
16
+ for (const value of set) {
17
17
  mainSet.add(value);
18
18
  }
19
19
  }
@@ -29,7 +29,7 @@ export function combineSets<T>(
29
29
  ): Set<T> {
30
30
  const newSet = new Set<T>();
31
31
  for (const set of sets) {
32
- for (const value of set.values()) {
32
+ for (const value of set) {
33
33
  newSet.add(value);
34
34
  }
35
35
  }
@@ -40,7 +40,7 @@ export function combineSets<T>(
40
40
  /** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
41
41
  export function copySet<T>(oldSet: Set<T> | ReadonlySet<T>): Set<T> {
42
42
  const newSet = new Set<T>();
43
- for (const value of oldSet.values()) {
43
+ for (const value of oldSet) {
44
44
  newSet.add(value);
45
45
  }
46
46
 
@@ -58,7 +58,7 @@ export function deleteSetsFromSet<T>(
58
58
  ...setsToRemove: Array<Set<T> | ReadonlySet<T>>
59
59
  ): void {
60
60
  for (const set of setsToRemove) {
61
- for (const value of set.values()) {
61
+ for (const value of set) {
62
62
  mainSet.delete(value);
63
63
  }
64
64
  }
@@ -117,15 +117,14 @@ export function getSetCombinations<T>(
117
117
  /**
118
118
  * Helper function to get a sorted array based on the contents of a set.
119
119
  *
120
- * Normally, set values are returned in a random order, so use this function when the ordering of
120
+ * Normally, set values are returned in insertion order, so use this function when the ordering of
121
121
  * the contents is important.
122
122
  */
123
123
  export function getSortedSetValues<T>(set: Set<T> | ReadonlySet<T>): T[] {
124
- const values = set.values();
125
- const array = [...values];
124
+ const values = [...set];
126
125
 
127
126
  // Check for problematic types in order to throw a helpful error message.
128
- const firstElement = array[0];
127
+ const firstElement = values[0];
129
128
  if (firstElement !== undefined) {
130
129
  const arrayType = type(firstElement);
131
130
  if (!isPrimitive(arrayType)) {
@@ -135,9 +134,78 @@ export function getSortedSetValues<T>(set: Set<T> | ReadonlySet<T>): T[] {
135
134
  }
136
135
  }
137
136
 
138
- array.sort();
137
+ values.sort();
139
138
 
140
- return array;
139
+ return values;
140
+ }
141
+
142
+ /**
143
+ * Helper function to convert the keys of an object to a read-only set.
144
+ *
145
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
146
+ * hood.
147
+ *
148
+ * Also see the `objectKeysToSet` function.
149
+ */
150
+ export function objectKeysToReadonlySet<K extends string | number | symbol, V>(
151
+ object: Record<K, V>,
152
+ ): ReadonlySet<K> {
153
+ return objectKeysToSet(object);
154
+ }
155
+
156
+ /**
157
+ * Helper function to convert the keys of an object to a set.
158
+ *
159
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
160
+ * hood.
161
+ *
162
+ * Also see the `objectKeysToReadonlySet` function.
163
+ */
164
+ export function objectKeysToSet<K extends string | number | symbol, V>(
165
+ object: Record<K, V>,
166
+ ): Set<K> {
167
+ const set = new Set<K>();
168
+
169
+ for (const key of Object.keys(object)) {
170
+ set.add(key as K);
171
+ }
172
+
173
+ return set;
174
+ }
175
+
176
+ /**
177
+ * Helper function to convert the values of an object to a read-only set.
178
+ *
179
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
180
+ * hood.
181
+ *
182
+ * Also see the `objectValuesToSet` function.
183
+ */
184
+ export function objectValuesToReadonlySet<
185
+ K extends string | number | symbol,
186
+ V,
187
+ >(object: Record<K, V>): ReadonlySet<V> {
188
+ return objectValuesToSet(object);
189
+ }
190
+
191
+ /**
192
+ * Helper function to convert the values of an object to a set.
193
+ *
194
+ * Note that the set values will be inserted in a random order, due to how `pairs` works under the
195
+ * hood.
196
+ *
197
+ * Also see the `objectValuesToReadonlySet` function.
198
+ */
199
+ export function objectValuesToSet<K extends string | number | symbol, V>(
200
+ object: Record<K, V>,
201
+ ): Set<V> {
202
+ const set = new Set<V>();
203
+
204
+ for (const key of Object.values(object)) {
205
+ set.add(key as V);
206
+ }
207
+
208
+ return set;
141
209
  }
142
210
 
143
211
  /**
@@ -168,6 +236,6 @@ export function setHas<T>(
168
236
 
169
237
  /** Helper function to sum every value in a set together. */
170
238
  export function sumSet(set: Set<number> | ReadonlySet<number>): number {
171
- const values = [...set.values()];
239
+ const values = [...set];
172
240
  return sumArray(values);
173
241
  }
@@ -230,3 +230,15 @@ export function trimSuffix(string: string, prefix: string): string {
230
230
  const endCharacter = string.length - prefix.length;
231
231
  return string.slice(0, endCharacter);
232
232
  }
233
+
234
+ export function uncapitalizeFirstLetter(string: string): string {
235
+ if (string === "") {
236
+ return string;
237
+ }
238
+
239
+ const firstCharacter = string.charAt(0);
240
+ const uncapitalizedFirstLetter = firstCharacter.toLowerCase();
241
+ const restOfString = string.slice(1);
242
+
243
+ return `${uncapitalizedFirstLetter}${restOfString}`;
244
+ }