isaacscript-common 57.1.1 → 57.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.
package/dist/index.rollup.d.ts
CHANGED
|
@@ -1238,6 +1238,16 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
|
|
|
1238
1238
|
"The assertion is useless because the provided value does not contain undefined."
|
|
1239
1239
|
]): asserts value is Exclude<T, undefined>;
|
|
1240
1240
|
|
|
1241
|
+
/**
|
|
1242
|
+
* Helper function to throw an error (using the `error` Lua function) if the provided value is equal
|
|
1243
|
+
* to `null`.
|
|
1244
|
+
*
|
|
1245
|
+
* This is useful to have TypeScript narrow a `T | null` value to `T` in a concise way.
|
|
1246
|
+
*/
|
|
1247
|
+
export declare function assertNotNull<T>(value: T, ...[msg]: [null] extends [T] ? [string] : [
|
|
1248
|
+
"The assertion is useless because the provided value does not contain null."
|
|
1249
|
+
]): asserts value is Exclude<T, null>;
|
|
1250
|
+
|
|
1241
1251
|
/**
|
|
1242
1252
|
* Helper function to safely cast an enum to a `string`. (This is better than using the `as`
|
|
1243
1253
|
* TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 57.
|
|
3
|
+
isaacscript-common 57.2.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -16259,6 +16259,14 @@ function ____exports.assertDefined(self, value, ...)
|
|
|
16259
16259
|
error(msg)
|
|
16260
16260
|
end
|
|
16261
16261
|
end
|
|
16262
|
+
function ____exports.assertNotNull(self, value, ...)
|
|
16263
|
+
local ____bindingPattern0 = {...}
|
|
16264
|
+
local msg
|
|
16265
|
+
msg = ____bindingPattern0[1]
|
|
16266
|
+
if value == nil then
|
|
16267
|
+
error(msg)
|
|
16268
|
+
end
|
|
16269
|
+
end
|
|
16262
16270
|
function ____exports.eRange(self, start, ____end, increment)
|
|
16263
16271
|
if increment == nil then
|
|
16264
16272
|
increment = 1
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends [T] ? [string] : [
|
|
9
9
|
"The assertion is useless because the provided value does not contain undefined."
|
|
10
10
|
]): asserts value is Exclude<T, undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Helper function to throw an error (using the `error` Lua function) if the provided value is equal
|
|
13
|
+
* to `null`.
|
|
14
|
+
*
|
|
15
|
+
* This is useful to have TypeScript narrow a `T | null` value to `T` in a concise way.
|
|
16
|
+
*/
|
|
17
|
+
export declare function assertNotNull<T>(value: T, ...[msg]: [null] extends [T] ? [string] : [
|
|
18
|
+
"The assertion is useless because the provided value does not contain null."
|
|
19
|
+
]): asserts value is Exclude<T, null>;
|
|
11
20
|
/**
|
|
12
21
|
* Helper function to return an array of integers with the specified range, inclusive on the lower
|
|
13
22
|
* end and exclusive on the high end. (The "e" in the function name stands for exclusive.) Thus,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/functions/utils.ts"],"names":[],"mappings":";AAIA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAC7B,CAAC,MAAM,CAAC,GACR;IACE,iFAAiF;CAClF,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAIxC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,GAAG,EAAE,CAkBlE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE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R;IACE,4EAA4E;CAC7E,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAInC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,GAAG,EAAE,CAkBlE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CAQR;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,GAAG,EAAE,CAQlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAMvC;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAiBtC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAI3D;AAED;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAG"}
|
|
@@ -20,6 +20,18 @@ function ____exports.assertDefined(self, value, ...)
|
|
|
20
20
|
error(msg)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
|
+
--- Helper function to throw an error (using the `error` Lua function) if the provided value is equal
|
|
24
|
+
-- to `null`.
|
|
25
|
+
--
|
|
26
|
+
-- This is useful to have TypeScript narrow a `T | null` value to `T` in a concise way.
|
|
27
|
+
function ____exports.assertNotNull(self, value, ...)
|
|
28
|
+
local ____bindingPattern0 = {...}
|
|
29
|
+
local msg
|
|
30
|
+
msg = ____bindingPattern0[1]
|
|
31
|
+
if value == nil then
|
|
32
|
+
error(msg)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
23
35
|
--- Helper function to return an array of integers with the specified range, inclusive on the lower
|
|
24
36
|
-- end and exclusive on the high end. (The "e" in the function name stands for exclusive.) Thus,
|
|
25
37
|
-- this function works in a similar way as the built-in `range` function from Python.
|
package/package.json
CHANGED
package/src/functions/utils.ts
CHANGED
|
@@ -21,6 +21,25 @@ export function assertDefined<T>(
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to throw an error (using the `error` Lua function) if the provided value is equal
|
|
26
|
+
* to `null`.
|
|
27
|
+
*
|
|
28
|
+
* This is useful to have TypeScript narrow a `T | null` value to `T` in a concise way.
|
|
29
|
+
*/
|
|
30
|
+
export function assertNotNull<T>(
|
|
31
|
+
value: T,
|
|
32
|
+
...[msg]: [null] extends [T]
|
|
33
|
+
? [string]
|
|
34
|
+
: [
|
|
35
|
+
"The assertion is useless because the provided value does not contain null.",
|
|
36
|
+
]
|
|
37
|
+
): asserts value is Exclude<T, null> {
|
|
38
|
+
if (value === null) {
|
|
39
|
+
error(msg);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
24
43
|
/**
|
|
25
44
|
* Helper function to return an array of integers with the specified range, inclusive on the lower
|
|
26
45
|
* end and exclusive on the high end. (The "e" in the function name stands for exclusive.) Thus,
|