isaacscript-common 80.1.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
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 80.0.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
 
@@ -44248,6 +44248,8 @@ local __TS__New = ____lualib.__TS__New
44248
44248
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
44249
44249
  local __TS__Spread = ____lualib.__TS__Spread
44250
44250
  local __TS__ArraySort = ____lualib.__TS__ArraySort
44251
+ local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
44252
+ local __TS__ObjectValues = ____lualib.__TS__ObjectValues
44251
44253
  local __TS__ArraySome = ____lualib.__TS__ArraySome
44252
44254
  local ____exports = {}
44253
44255
  local ____ReadonlySet = require("types.ReadonlySet")
@@ -44260,20 +44262,45 @@ local ____types = require("functions.types")
44260
44262
  local isPrimitive = ____types.isPrimitive
44261
44263
  --- Helper function to get a sorted array based on the contents of a set.
44262
44264
  --
44263
- -- 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
44264
44266
  -- the contents is important.
44265
44267
  function ____exports.getSortedSetValues(self, set)
44266
- local values = set:values()
44267
- local array = {__TS__Spread(values)}
44268
- local firstElement = array[1]
44268
+ local values = {__TS__Spread(set)}
44269
+ local firstElement = values[1]
44269
44270
  if firstElement ~= nil then
44270
44271
  local arrayType = type(firstElement)
44271
44272
  if not isPrimitive(nil, arrayType) then
44272
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.")
44273
44274
  end
44274
44275
  end
44275
- __TS__ArraySort(array)
44276
- 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
44277
44304
  end
44278
44305
  --- Helper function to add all of the values in one set to another set. The first set passed will be
44279
44306
  -- modified in place.
@@ -44282,7 +44309,7 @@ end
44282
44309
  function ____exports.addSetsToSet(self, mainSet, ...)
44283
44310
  local setsToAdd = {...}
44284
44311
  for ____, set in ipairs(setsToAdd) do
44285
- for ____, value in __TS__Iterator(set:values()) do
44312
+ for ____, value in __TS__Iterator(set) do
44286
44313
  mainSet:add(value)
44287
44314
  end
44288
44315
  end
@@ -44294,7 +44321,7 @@ function ____exports.combineSets(self, ...)
44294
44321
  local sets = {...}
44295
44322
  local newSet = __TS__New(Set)
44296
44323
  for ____, set in ipairs(sets) do
44297
- for ____, value in __TS__Iterator(set:values()) do
44324
+ for ____, value in __TS__Iterator(set) do
44298
44325
  newSet:add(value)
44299
44326
  end
44300
44327
  end
@@ -44303,7 +44330,7 @@ end
44303
44330
  --- Helper function to copy a set. (You can also use a Set constructor to accomplish this task.)
44304
44331
  function ____exports.copySet(self, oldSet)
44305
44332
  local newSet = __TS__New(Set)
44306
- for ____, value in __TS__Iterator(oldSet:values()) do
44333
+ for ____, value in __TS__Iterator(oldSet) do
44307
44334
  newSet:add(value)
44308
44335
  end
44309
44336
  return newSet
@@ -44315,7 +44342,7 @@ end
44315
44342
  function ____exports.deleteSetsFromSet(self, mainSet, ...)
44316
44343
  local setsToRemove = {...}
44317
44344
  for ____, set in ipairs(setsToRemove) do
44318
- for ____, value in __TS__Iterator(set:values()) do
44345
+ for ____, value in __TS__Iterator(set) do
44319
44346
  mainSet:delete(value)
44320
44347
  end
44321
44348
  end
@@ -44362,6 +44389,24 @@ function ____exports.getSetCombinations(self, set, includeEmptyArray)
44362
44389
  function(____, array) return __TS__New(ReadonlySet, array) end
44363
44390
  )
44364
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
44365
44410
  --- Helper function to add one or more elements to a set at once without having to repeatedly call
44366
44411
  -- the `Set.add` method.
44367
44412
  --
@@ -44386,7 +44431,7 @@ function ____exports.setHas(self, set, ...)
44386
44431
  end
44387
44432
  --- Helper function to sum every value in a set together.
44388
44433
  function ____exports.sumSet(self, set)
44389
- local values = {__TS__Spread(set:values())}
44434
+ local values = {__TS__Spread(set)}
44390
44435
  return sumArray(nil, values)
44391
44436
  end
44392
44437
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "80.1.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
  }