isaacscript-common 1.2.126 → 1.2.127
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.
package/dist/functions/map.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { DefaultMap } from "../types/DefaultMap";
|
|
2
3
|
/** Helper function to copy a map. (You can also use a Map constructor to accomplish this task.) */
|
|
3
4
|
export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
|
|
4
5
|
/**
|
|
5
|
-
* Helper function to make using
|
|
6
|
-
* the current value, incrementing it, and then
|
|
6
|
+
* Helper function to make using default maps with `Seed` values easier. Use this instead of
|
|
7
|
+
* manually getting the current value, incrementing it, and then setting it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function defaultMapGetNextSeed<K, A extends unknown[]>(map: DefaultMap<K, Seed, A>, key: K, ...extraArgs: A): Seed;
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to make using maps with `Seed` values easier. Use this instead of manually
|
|
12
|
+
* getting the current value, incrementing it, and then setting it.
|
|
7
13
|
*/
|
|
8
14
|
export declare function mapGetNextSeed<K>(map: Map<K, Seed>, key: K): Seed | undefined;
|
package/dist/functions/map.lua
CHANGED
|
@@ -15,6 +15,15 @@ function ____exports.copyMap(self, oldMap)
|
|
|
15
15
|
end
|
|
16
16
|
return newMap
|
|
17
17
|
end
|
|
18
|
+
function ____exports.defaultMapGetNextSeed(self, map, key, ...)
|
|
19
|
+
local seed = map:getAndSetDefault(key, ...)
|
|
20
|
+
if seed == 0 then
|
|
21
|
+
error("The seed map had a value of 0 for the key of: " .. tostring(key))
|
|
22
|
+
end
|
|
23
|
+
local newSeed = nextSeed(nil, seed)
|
|
24
|
+
map:set(key, newSeed)
|
|
25
|
+
return newSeed
|
|
26
|
+
end
|
|
18
27
|
function ____exports.mapGetNextSeed(self, map, key)
|
|
19
28
|
local seed = map:get(key)
|
|
20
29
|
if seed == nil then
|