isaacscript-common 79.2.0 → 79.3.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.
- package/dist/functions/map.d.ts +16 -0
- package/dist/functions/map.d.ts.map +1 -1
- package/dist/functions/map.lua +16 -0
- package/dist/index.rollup.d.ts +17 -0
- package/dist/isaacscript-common.lua +17 -1
- package/package.json +1 -1
- package/src/functions/map.ts +21 -0
package/dist/functions/map.d.ts
CHANGED
|
@@ -54,8 +54,24 @@ export declare function mapSetHash<V>(map: Map<PtrHash, V>, entity: Entity, valu
|
|
|
54
54
|
*
|
|
55
55
|
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
56
56
|
* hood.
|
|
57
|
+
*
|
|
58
|
+
* Also see the `objectToReadonlyMap` function.
|
|
57
59
|
*/
|
|
58
60
|
export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): Map<K, V>;
|
|
61
|
+
/**
|
|
62
|
+
* Helper function to convert an object to a read-only map.
|
|
63
|
+
*
|
|
64
|
+
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
65
|
+
* then later on you need to query it in a way where you expect the return value to be T or
|
|
66
|
+
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
67
|
+
* assertions.
|
|
68
|
+
*
|
|
69
|
+
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
70
|
+
* hood.
|
|
71
|
+
*
|
|
72
|
+
* Also see the `objectToMap` function.
|
|
73
|
+
*/
|
|
74
|
+
export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
|
|
59
75
|
/** Helper function to sum every value in a map together. */
|
|
60
76
|
export declare function sumMap(map: Map<unknown, number> | ReadonlyMap<unknown, number>): number;
|
|
61
77
|
//# sourceMappingURL=map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names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E,CAAC,EAC/D,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAQX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACvE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAEnB;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CACpB,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,GACvD,MAAM,CAGR"}
|
package/dist/functions/map.lua
CHANGED
|
@@ -74,6 +74,8 @@ end
|
|
|
74
74
|
--
|
|
75
75
|
-- Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
76
76
|
-- hood.
|
|
77
|
+
--
|
|
78
|
+
-- Also see the `objectToReadonlyMap` function.
|
|
77
79
|
function ____exports.objectToMap(self, object)
|
|
78
80
|
local map = __TS__New(Map)
|
|
79
81
|
for ____, ____value in ipairs(__TS__ObjectEntries(object)) do
|
|
@@ -83,6 +85,20 @@ function ____exports.objectToMap(self, object)
|
|
|
83
85
|
end
|
|
84
86
|
return map
|
|
85
87
|
end
|
|
88
|
+
--- Helper function to convert an object to a read-only map.
|
|
89
|
+
--
|
|
90
|
+
-- This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
91
|
+
-- then later on you need to query it in a way where you expect the return value to be T or
|
|
92
|
+
-- undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
93
|
+
-- assertions.
|
|
94
|
+
--
|
|
95
|
+
-- Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
96
|
+
-- hood.
|
|
97
|
+
--
|
|
98
|
+
-- Also see the `objectToMap` function.
|
|
99
|
+
function ____exports.objectToReadonlyMap(self, object)
|
|
100
|
+
return ____exports.objectToMap(nil, object)
|
|
101
|
+
end
|
|
86
102
|
--- Helper function to sum every value in a map together.
|
|
87
103
|
function ____exports.sumMap(self, map)
|
|
88
104
|
local values = {__TS__Spread(map:values())}
|
package/dist/index.rollup.d.ts
CHANGED
|
@@ -14908,9 +14908,26 @@ export declare const NUM_VANILLA_TRINKET_TYPES: number;
|
|
|
14908
14908
|
*
|
|
14909
14909
|
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
14910
14910
|
* hood.
|
|
14911
|
+
*
|
|
14912
|
+
* Also see the `objectToReadonlyMap` function.
|
|
14911
14913
|
*/
|
|
14912
14914
|
export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): Map<K, V>;
|
|
14913
14915
|
|
|
14916
|
+
/**
|
|
14917
|
+
* Helper function to convert an object to a read-only map.
|
|
14918
|
+
*
|
|
14919
|
+
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
14920
|
+
* then later on you need to query it in a way where you expect the return value to be T or
|
|
14921
|
+
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
14922
|
+
* assertions.
|
|
14923
|
+
*
|
|
14924
|
+
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
14925
|
+
* hood.
|
|
14926
|
+
*
|
|
14927
|
+
* Also see the `objectToMap` function.
|
|
14928
|
+
*/
|
|
14929
|
+
export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
|
|
14930
|
+
|
|
14914
14931
|
/** Helper function to see if the player is playing any challenge. */
|
|
14915
14932
|
export declare function onAnyChallenge(): boolean;
|
|
14916
14933
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 79.
|
|
3
|
+
isaacscript-common 79.2.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -46941,6 +46941,8 @@ end
|
|
|
46941
46941
|
--
|
|
46942
46942
|
-- Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
46943
46943
|
-- hood.
|
|
46944
|
+
--
|
|
46945
|
+
-- Also see the `objectToReadonlyMap` function.
|
|
46944
46946
|
function ____exports.objectToMap(self, object)
|
|
46945
46947
|
local map = __TS__New(Map)
|
|
46946
46948
|
for ____, ____value in ipairs(__TS__ObjectEntries(object)) do
|
|
@@ -46950,6 +46952,20 @@ function ____exports.objectToMap(self, object)
|
|
|
46950
46952
|
end
|
|
46951
46953
|
return map
|
|
46952
46954
|
end
|
|
46955
|
+
--- Helper function to convert an object to a read-only map.
|
|
46956
|
+
--
|
|
46957
|
+
-- This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
46958
|
+
-- then later on you need to query it in a way where you expect the return value to be T or
|
|
46959
|
+
-- undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
46960
|
+
-- assertions.
|
|
46961
|
+
--
|
|
46962
|
+
-- Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
46963
|
+
-- hood.
|
|
46964
|
+
--
|
|
46965
|
+
-- Also see the `objectToMap` function.
|
|
46966
|
+
function ____exports.objectToReadonlyMap(self, object)
|
|
46967
|
+
return ____exports.objectToMap(nil, object)
|
|
46968
|
+
end
|
|
46953
46969
|
--- Helper function to sum every value in a map together.
|
|
46954
46970
|
function ____exports.sumMap(self, map)
|
|
46955
46971
|
local values = {__TS__Spread(map:values())}
|
package/package.json
CHANGED
package/src/functions/map.ts
CHANGED
|
@@ -99,6 +99,8 @@ export function mapSetHash<V>(
|
|
|
99
99
|
*
|
|
100
100
|
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
101
101
|
* hood.
|
|
102
|
+
*
|
|
103
|
+
* Also see the `objectToReadonlyMap` function.
|
|
102
104
|
*/
|
|
103
105
|
export function objectToMap<K extends string | number | symbol, V>(
|
|
104
106
|
object: Record<K, V>,
|
|
@@ -112,6 +114,25 @@ export function objectToMap<K extends string | number | symbol, V>(
|
|
|
112
114
|
return map;
|
|
113
115
|
}
|
|
114
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Helper function to convert an object to a read-only map.
|
|
119
|
+
*
|
|
120
|
+
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
121
|
+
* then later on you need to query it in a way where you expect the return value to be T or
|
|
122
|
+
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
123
|
+
* assertions.
|
|
124
|
+
*
|
|
125
|
+
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
126
|
+
* hood.
|
|
127
|
+
*
|
|
128
|
+
* Also see the `objectToMap` function.
|
|
129
|
+
*/
|
|
130
|
+
export function objectToReadonlyMap<K extends string | number | symbol, V>(
|
|
131
|
+
object: Record<K, V>,
|
|
132
|
+
): ReadonlyMap<K, V> {
|
|
133
|
+
return objectToMap(object);
|
|
134
|
+
}
|
|
135
|
+
|
|
115
136
|
/** Helper function to sum every value in a map together. */
|
|
116
137
|
export function sumMap(
|
|
117
138
|
map: Map<unknown, number> | ReadonlyMap<unknown, number>,
|