isaacscript-common 1.2.125 → 1.2.126

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,2 +1,8 @@
1
+ /// <reference types="isaac-typescript-definitions" />
1
2
  /** Helper function to copy a map. (You can also use a Map constructor to accomplish this task.) */
2
3
  export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
4
+ /**
5
+ * Helper function to make using map with `Seed` values easier. Use this instead of manually getting
6
+ * the current value, incrementing it, and then re-setting it.
7
+ */
8
+ export declare function mapGetNextSeed<K>(map: Map<K, Seed>, key: K): Seed | undefined;
@@ -4,6 +4,8 @@ local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__Iterator = ____lualib.__TS__Iterator
6
6
  local ____exports = {}
7
+ local ____random = require("functions.random")
8
+ local nextSeed = ____random.nextSeed
7
9
  function ____exports.copyMap(self, oldMap)
8
10
  local newMap = __TS__New(Map)
9
11
  for ____, ____value in __TS__Iterator(oldMap:entries()) do
@@ -13,4 +15,16 @@ function ____exports.copyMap(self, oldMap)
13
15
  end
14
16
  return newMap
15
17
  end
18
+ function ____exports.mapGetNextSeed(self, map, key)
19
+ local seed = map:get(key)
20
+ if seed == nil then
21
+ return nil
22
+ end
23
+ if seed == 0 then
24
+ error("The seed map had a value of 0 for the key of: " .. tostring(key))
25
+ end
26
+ local newSeed = nextSeed(nil, seed)
27
+ map:set(key, newSeed)
28
+ return newSeed
29
+ end
16
30
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.125",
3
+ "version": "1.2.126",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",