@sorrell/utilities 1.2.8 → 1.2.11
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/Distribution/PackageExports.Generated.json +30 -0
- package/Distribution/Types/FileSystem/FileSystem.d.cts +16 -0
- package/Distribution/Types/FileSystem/FileSystem.d.cts.map +1 -1
- package/Distribution/Types/FileSystem/FileSystem.d.mts +16 -0
- package/Distribution/Types/FileSystem/FileSystem.d.mts.map +1 -1
- package/Distribution/Types/FileSystem/FileSystem.d.ts +16 -0
- package/Distribution/Types/FileSystem/FileSystem.d.ts.map +1 -1
- package/Distribution/Types/Functional/Functional.d.cts +7 -1
- package/Distribution/Types/Functional/Functional.d.cts.map +1 -1
- package/Distribution/Types/Functional/Functional.d.mts +7 -1
- package/Distribution/Types/Functional/Functional.d.mts.map +1 -1
- package/Distribution/Types/Functional/Functional.d.ts +7 -1
- package/Distribution/Types/Functional/Functional.d.ts.map +1 -1
- package/Distribution/Types/HigherKind/HigherKind.Internal.Types.d.cts +30 -0
- package/Distribution/Types/HigherKind/HigherKind.Internal.Types.d.cts.map +10 -0
- package/Distribution/Types/HigherKind/HigherKind.Internal.Types.d.mts +30 -0
- package/Distribution/Types/HigherKind/HigherKind.Internal.Types.d.mts.map +10 -0
- package/Distribution/Types/HigherKind/HigherKind.Internal.Types.d.ts +30 -0
- package/Distribution/Types/HigherKind/HigherKind.Internal.Types.d.ts.map +1 -0
- package/Distribution/Types/HigherKind/HigherKind.Registrar.Types.d.cts +31 -0
- package/Distribution/Types/HigherKind/HigherKind.Registrar.Types.d.cts.map +10 -0
- package/Distribution/Types/HigherKind/HigherKind.Registrar.Types.d.mts +31 -0
- package/Distribution/Types/HigherKind/HigherKind.Registrar.Types.d.mts.map +10 -0
- package/Distribution/Types/HigherKind/HigherKind.Registrar.Types.d.ts +31 -0
- package/Distribution/Types/HigherKind/HigherKind.Registrar.Types.d.ts.map +1 -0
- package/Distribution/Types/HigherKind/HigherKind.Types.d.cts +85 -0
- package/Distribution/Types/HigherKind/HigherKind.Types.d.cts.map +10 -0
- package/Distribution/Types/HigherKind/HigherKind.Types.d.mts +85 -0
- package/Distribution/Types/HigherKind/HigherKind.Types.d.mts.map +10 -0
- package/Distribution/Types/HigherKind/HigherKind.Types.d.ts +85 -0
- package/Distribution/Types/HigherKind/HigherKind.Types.d.ts.map +1 -0
- package/Distribution/Types/HigherKind/index.d.cts +8 -0
- package/Distribution/Types/HigherKind/index.d.cts.map +10 -0
- package/Distribution/Types/HigherKind/index.d.mts +8 -0
- package/Distribution/Types/HigherKind/index.d.mts.map +10 -0
- package/Distribution/Types/HigherKind/index.d.ts +8 -0
- package/Distribution/Types/HigherKind/index.d.ts.map +1 -0
- package/Distribution/Types/Miscellaneous/Utility.Types.d.cts +12 -26
- package/Distribution/Types/Miscellaneous/Utility.Types.d.cts.map +1 -1
- package/Distribution/Types/Miscellaneous/Utility.Types.d.mts +12 -26
- package/Distribution/Types/Miscellaneous/Utility.Types.d.mts.map +1 -1
- package/Distribution/Types/Miscellaneous/Utility.Types.d.ts +12 -26
- package/Distribution/Types/Miscellaneous/Utility.Types.d.ts.map +1 -1
- package/Distribution/Types/String/String.d.cts +55 -10
- package/Distribution/Types/String/String.d.cts.map +1 -1
- package/Distribution/Types/String/String.d.mts +55 -10
- package/Distribution/Types/String/String.d.mts.map +1 -1
- package/Distribution/Types/String/String.d.ts +55 -10
- package/Distribution/Types/String/String.d.ts.map +1 -1
- package/Distribution/Types/TsConfig/TsConfig.Types.d.cts +32 -0
- package/Distribution/Types/TsConfig/TsConfig.Types.d.cts.map +10 -0
- package/Distribution/Types/TsConfig/TsConfig.Types.d.mts +32 -0
- package/Distribution/Types/TsConfig/TsConfig.Types.d.mts.map +10 -0
- package/Distribution/Types/TsConfig/TsConfig.Types.d.ts +32 -0
- package/Distribution/Types/TsConfig/TsConfig.Types.d.ts.map +1 -0
- package/Distribution/Types/TsConfig/index.d.cts +8 -0
- package/Distribution/Types/TsConfig/index.d.cts.map +10 -0
- package/Distribution/Types/TsConfig/index.d.mts +8 -0
- package/Distribution/Types/TsConfig/index.d.mts.map +10 -0
- package/Distribution/Types/TsConfig/index.d.ts +8 -0
- package/Distribution/Types/TsConfig/index.d.ts.map +1 -0
- package/Distribution/Types/index.d.cts +1 -0
- package/Distribution/Types/index.d.cts.map +1 -1
- package/Distribution/Types/index.d.mts +1 -0
- package/Distribution/Types/index.d.mts.map +1 -1
- package/Distribution/Types/index.d.ts +1 -0
- package/Distribution/Types/index.d.ts.map +1 -1
- package/Distribution/async.cjs.map +2 -2
- package/Distribution/async.js.map +2 -2
- package/Distribution/fs.cjs +94 -4
- package/Distribution/fs.cjs.map +3 -3
- package/Distribution/fs.js +94 -4
- package/Distribution/fs.js.map +3 -3
- package/Distribution/functional.cjs +2 -2
- package/Distribution/functional.cjs.map +2 -2
- package/Distribution/functional.js +2 -2
- package/Distribution/functional.js.map +2 -2
- package/Distribution/higher-kind.cjs +31 -0
- package/Distribution/higher-kind.cjs.map +7 -0
- package/Distribution/higher-kind.js +13 -0
- package/Distribution/higher-kind.js.map +7 -0
- package/Distribution/index.cjs +137 -18
- package/Distribution/index.cjs.map +4 -4
- package/Distribution/index.js +144 -25
- package/Distribution/index.js.map +4 -4
- package/Distribution/misc.cjs.map +2 -2
- package/Distribution/misc.js.map +2 -2
- package/Distribution/string.cjs +70 -0
- package/Distribution/string.cjs.map +7 -0
- package/Distribution/string.js +47 -0
- package/Distribution/string.js.map +7 -0
- package/Distribution/tsconfig.cjs +31 -0
- package/Distribution/tsconfig.cjs.map +7 -0
- package/Distribution/tsconfig.js +13 -0
- package/Distribution/tsconfig.js.map +7 -0
- package/package.json +45 -7
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../../Source/String/String.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAAA;;;;;GAKG;AAEH;;;GAGG;
|
|
9
|
+
"mappings": "AAAA;;;;;GAKG;AAEH;;;GAGG;AAKH;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CA4BrE"
|
|
10
10
|
}
|
|
@@ -9,20 +9,65 @@
|
|
|
9
9
|
* Functions for manipulating strings.
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Does the given {@link TestString} contain only letters?
|
|
13
|
+
* This is equivalent to Python's
|
|
14
|
+
* {@link https://docs.python.org/3/library/stdtypes.html#str.isalpha | isalpha} function.
|
|
15
|
+
*
|
|
16
|
+
* @remarks This is an alias for {@link IsAlpha}.
|
|
17
|
+
*
|
|
18
|
+
* @param TestString - The string that you wish to test.
|
|
19
|
+
*
|
|
20
|
+
* @returns {boolean} Whether the given string contains *only* (Latin alphabet) letters.
|
|
21
|
+
*/
|
|
22
|
+
export declare function IsLetters(TestString: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Does the given {@link TestString} contain only letters?
|
|
25
|
+
* This is equivalent to Python's
|
|
26
|
+
* {@link https://docs.python.org/3/library/stdtypes.html#str.isalpha | isalpha} function.
|
|
27
|
+
*
|
|
28
|
+
* @param TestString - The string that you wish to test.
|
|
29
|
+
*
|
|
30
|
+
* @returns {boolean} Whether the given string contains *only* (Latin alphabet) letters.
|
|
14
31
|
*/
|
|
15
|
-
export declare function
|
|
32
|
+
export declare function IsAlpha(TestString: string): boolean;
|
|
16
33
|
/**
|
|
17
|
-
*
|
|
34
|
+
* Does the given {@link TestString} contain only digits?
|
|
18
35
|
*
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
36
|
+
* This is equivalent to Python's
|
|
37
|
+
* {@link https://docs.python.org/3/library/stdtypes.html#str.isnumeric | isnumeric} function.
|
|
38
|
+
*
|
|
39
|
+
* @param TestString - The string that you wish to test.
|
|
40
|
+
*
|
|
41
|
+
* @returns {boolean} Whether the given string contains *only* numeric digits.
|
|
21
42
|
*/
|
|
22
|
-
export declare function
|
|
43
|
+
export declare function IsNumeric(TestString: string): boolean;
|
|
23
44
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
45
|
+
* This function provides a convenient way to define long strings across multiple lines.
|
|
46
|
+
* The linebreaks and leading indentation are removed from the final string.
|
|
47
|
+
* Please see the example below for how this is to be done.
|
|
48
|
+
*
|
|
49
|
+
* @param Content - The given string to dedent.
|
|
50
|
+
* @param IndentLength - The number of spaces for which this function will check. This
|
|
51
|
+
* is necessary only if the number of spaces used in the {@link Content} is not a multiple
|
|
52
|
+
* of two.
|
|
53
|
+
*
|
|
54
|
+
* @returns {string} The given {@link Content}, but with the spaces at the beginning
|
|
55
|
+
* of each line (excluding the first line if no spaces exist in the first line) removed.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { Dedent } from "@sorrell/utilities/string";
|
|
60
|
+
*
|
|
61
|
+
* const MyLongString: string = Dedent(`Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
|
62
|
+
* sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
|
|
63
|
+
* minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
|
64
|
+
* commodo consequat.`);
|
|
65
|
+
*
|
|
66
|
+
* // `MyLongString` <- `"Lorem ipsum dolor sit amet, consectetur adipiscing elit, \
|
|
67
|
+
* sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \
|
|
68
|
+
* minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea \
|
|
69
|
+
* commodo consequat."`
|
|
70
|
+
* ```
|
|
26
71
|
*/
|
|
27
|
-
export declare function
|
|
72
|
+
export declare function Dedent(Content: string, IndentLength?: number): string;
|
|
28
73
|
//# sourceMappingURL=String.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../../../Source/String/String.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;
|
|
1
|
+
{"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../../../Source/String/String.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AAKH;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAGrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CA4BrE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file TsConfig.Types.ts
|
|
3
|
+
* @author Gage Sorrell <gage@sorrell.sh>
|
|
4
|
+
* @copyright (c) 2026 Gage Sorrell
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
import type TypeScript from "typescript";
|
|
8
|
+
export type FOverriddenCompilerOptions = "jsx" | "lib" | "module" | "moduleResolution" | "target";
|
|
9
|
+
export type FCompilerOptions = Omit<TypeScript.server.protocol.CompilerOptions, FOverriddenCompilerOptions> & Partial<{
|
|
10
|
+
jsx: JsxEmit;
|
|
11
|
+
lib: Array<string>;
|
|
12
|
+
module: FModuleKind;
|
|
13
|
+
moduleResolution: FModuleResolutionKind;
|
|
14
|
+
target: FTarget;
|
|
15
|
+
}>;
|
|
16
|
+
export type JsxEmit = "none" | "preserve" | "react-native" | "react" | "react-jsx" | "react-jsxdev";
|
|
17
|
+
export type FModuleKind = "none" | "commonjs" | "amd" | "umd" | "system" | "es6" | "es2015" | "es2020" | "es2022" | "esnext" | "node16" | "node18" | "node20" | "nodenext" | "preserve";
|
|
18
|
+
export type FModuleResolutionKind = "classic" | "node" | "node" | "node10" | "node16" | "nodenext" | "bundler";
|
|
19
|
+
export type FTarget = "es3" | "es5" | "es6" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "es2025" | "esnext" | "json" | "esnext" | "es2025";
|
|
20
|
+
/** The type corresponding to the schema of `tsconfig.json`. */
|
|
21
|
+
export interface TsConfigSchema {
|
|
22
|
+
extends?: string | Array<string>;
|
|
23
|
+
files?: Array<string>;
|
|
24
|
+
include?: Array<string>;
|
|
25
|
+
exclude?: Array<string>;
|
|
26
|
+
references?: Array<TypeScript.ProjectReference>;
|
|
27
|
+
compilerOptions?: FCompilerOptions;
|
|
28
|
+
watchOptions?: TypeScript.WatchOptions;
|
|
29
|
+
typeAcquisition?: TypeScript.TypeAcquisition;
|
|
30
|
+
compileOnSave?: boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=TsConfig.Types.d.cts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "TsConfig.Types.d.cts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../Source/TsConfig/TsConfig.Types.ts"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAAA;;;;;GAKG;AAEH,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAIzC,MAAM,MAAM,0BAA0B,GAChC,KAAK,GACL,K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CAAC;IACxB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,UAAU,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAChD,eAAe,CAAC,EAAE,gBAAgB,CAAC;IACnC,YAAY,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC;IACvC,eAAe,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B"
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file TsConfig.Types.ts
|
|
3
|
+
* @author Gage Sorrell <gage@sorrell.sh>
|
|
4
|
+
* @copyright (c) 2026 Gage Sorrell
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
import type TypeScript from "typescript";
|
|
8
|
+
export type FOverriddenCompilerOptions = "jsx" | "lib" | "module" | "moduleResolution" | "target";
|
|
9
|
+
export type FCompilerOptions = Omit<TypeScript.server.protocol.CompilerOptions, FOverriddenCompilerOptions> & Partial<{
|
|
10
|
+
jsx: JsxEmit;
|
|
11
|
+
lib: Array<string>;
|
|
12
|
+
module: FModuleKind;
|
|
13
|
+
moduleResolution: FModuleResolutionKind;
|
|
14
|
+
target: FTarget;
|
|
15
|
+
}>;
|
|
16
|
+
export type JsxEmit = "none" | "preserve" | "react-native" | "react" | "react-jsx" | "react-jsxdev";
|
|
17
|
+
export type FModuleKind = "none" | "commonjs" | "amd" | "umd" | "system" | "es6" | "es2015" | "es2020" | "es2022" | "esnext" | "node16" | "node18" | "node20" | "nodenext" | "preserve";
|
|
18
|
+
export type FModuleResolutionKind = "classic" | "node" | "node" | "node10" | "node16" | "nodenext" | "bundler";
|
|
19
|
+
export type FTarget = "es3" | "es5" | "es6" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "es2025" | "esnext" | "json" | "esnext" | "es2025";
|
|
20
|
+
/** The type corresponding to the schema of `tsconfig.json`. */
|
|
21
|
+
export interface TsConfigSchema {
|
|
22
|
+
extends?: string | Array<string>;
|
|
23
|
+
files?: Array<string>;
|
|
24
|
+
include?: Array<string>;
|
|
25
|
+
exclude?: Array<string>;
|
|
26
|
+
references?: Array<TypeScript.ProjectReference>;
|
|
27
|
+
compilerOptions?: FCompilerOptions;
|
|
28
|
+
watchOptions?: TypeScript.WatchOptions;
|
|
29
|
+
typeAcquisition?: TypeScript.TypeAcquisition;
|
|
30
|
+
compileOnSave?: boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=TsConfig.Types.d.mts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "TsConfig.Types.d.mts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../Source/TsConfig/TsConfig.Types.ts"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAAA;;;;;GAKG;AAEH,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAIzC,MAAM,MAAM,0BAA0B,GAChC,KAAK,GACL,KAAK,GACL,QAAQ,GACR,kBAAkB,GAClB,QAAQ,CAAC;AAEf,MAAM,MAAM,gBAAgB,GACxB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,0BAA0B,CAAC,GAC5E,OAAO,CAAC;IACJ,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEP,MAAM,MAAM,OAAO,GACb,MAAM,GACN,UAAU,GACV,cAAc,GACd,OAAO,GACP,WAAW,GACX,cAAc,CAAC;AAErB,MAAM,MA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|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
import type TypeScript from "typescript";
|
|
8
|
+
export type FOverriddenCompilerOptions = "jsx" | "lib" | "module" | "moduleResolution" | "target";
|
|
9
|
+
export type FCompilerOptions = Omit<TypeScript.server.protocol.CompilerOptions, FOverriddenCompilerOptions> & Partial<{
|
|
10
|
+
jsx: JsxEmit;
|
|
11
|
+
lib: Array<string>;
|
|
12
|
+
module: FModuleKind;
|
|
13
|
+
moduleResolution: FModuleResolutionKind;
|
|
14
|
+
target: FTarget;
|
|
15
|
+
}>;
|
|
16
|
+
export type JsxEmit = "none" | "preserve" | "react-native" | "react" | "react-jsx" | "react-jsxdev";
|
|
17
|
+
export type FModuleKind = "none" | "commonjs" | "amd" | "umd" | "system" | "es6" | "es2015" | "es2020" | "es2022" | "esnext" | "node16" | "node18" | "node20" | "nodenext" | "preserve";
|
|
18
|
+
export type FModuleResolutionKind = "classic" | "node" | "node" | "node10" | "node16" | "nodenext" | "bundler";
|
|
19
|
+
export type FTarget = "es3" | "es5" | "es6" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "es2025" | "esnext" | "json" | "esnext" | "es2025";
|
|
20
|
+
/** The type corresponding to the schema of `tsconfig.json`. */
|
|
21
|
+
export interface TsConfigSchema {
|
|
22
|
+
extends?: string | Array<string>;
|
|
23
|
+
files?: Array<string>;
|
|
24
|
+
include?: Array<string>;
|
|
25
|
+
exclude?: Array<string>;
|
|
26
|
+
references?: Array<TypeScript.ProjectReference>;
|
|
27
|
+
compilerOptions?: FCompilerOptions;
|
|
28
|
+
watchOptions?: TypeScript.WatchOptions;
|
|
29
|
+
typeAcquisition?: TypeScript.TypeAcquisition;
|
|
30
|
+
compileOnSave?: boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=TsConfig.Types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TsConfig.Types.d.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3B,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,UAAU,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAChD,eAAe,CAAC,EAAE,gBAAgB,CAAC;IACnC,YAAY,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC;IACvC,eAAe,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Source/TsConfig/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,qBAAqB,CAAC"}
|
|
@@ -21,4 +21,5 @@ export * as Miscellaneous from "./Miscellaneous/index.cjs";
|
|
|
21
21
|
export * as Npm from "./Npm/index.cjs";
|
|
22
22
|
export * as Path from "./Path/index.cjs";
|
|
23
23
|
export * as String from "./String/index.cjs";
|
|
24
|
+
export * as TsConfig from "./TsConfig/index.cjs";
|
|
24
25
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../Source/index.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC"
|
|
9
|
+
"mappings": "AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"
|
|
10
10
|
}
|
|
@@ -21,4 +21,5 @@ export * as Miscellaneous from "./Miscellaneous/index.mjs";
|
|
|
21
21
|
export * as Npm from "./Npm/index.mjs";
|
|
22
22
|
export * as Path from "./Path/index.mjs";
|
|
23
23
|
export * as String from "./String/index.mjs";
|
|
24
|
+
export * as TsConfig from "./TsConfig/index.mjs";
|
|
24
25
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../Source/index.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC"
|
|
9
|
+
"mappings": "AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"
|
|
10
10
|
}
|
|
@@ -21,4 +21,5 @@ export * as Miscellaneous from "./Miscellaneous/index.ts";
|
|
|
21
21
|
export * as Npm from "./Npm/index.ts";
|
|
22
22
|
export * as Path from "./Path/index.ts";
|
|
23
23
|
export * as String from "./String/index.ts";
|
|
24
|
+
export * as TsConfig from "./TsConfig/index.ts";
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Source/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Source/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../Source/Async/index.ts", "../Source/Miscellaneous/Utility.Types.ts", "../Source/Async/Async.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @file index.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nexport * from \"./Async.ts\";\nexport * from \"./Async.Types.ts\";\n", "/**\n * @file Utility.Types.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport type { NoOptions } from \"./Utility.Internal.ts\";\nimport type TypeScript from \"typescript\";\n/**\n * @deprecated Use {@link TMutable} instead.\n *\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n */\nexport type TDeepWriteable<RecordLike> = {\n -readonly [Key in keyof RecordLike]: TDeepWriteable<RecordLike[Key]>;\n};\n/**\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n * @template ShallowOption - Whether the `readonly` modifier should be stripped recursively.\n * If `true` (the default), then only the properties of the given type will have the `readonly`\n * modifier stripped (that is, if any of these properties is a {@link Record} type with `readonly`\n * modifiers, then those will *not* be removed if {@link ShallowOption} is `true`).\n */\nexport type TMutable<RecordLike, ShallowOption extends boolean = true> = ShallowOption extends false ? {\n -readonly [Key in keyof RecordLike]: RecordLike[Key];\n} : ShallowOption extends true ? {\n -readonly [Key in keyof RecordLike]: TMutable<RecordLike[Key]>;\n} : never;\n/**\n * Given a {@link RecordLike | record-like type}, this type is the union\n * of the values of all properties in the {@link RecordLike | record-like type}.\n *\n * @template RecordLike - The record-like type from which this type extracts value types.\n */\nexport type TValues<RecordLike> = RecordLike[keyof RecordLike];\n/**\n * The element type of the return value of `Object.entries()`.\n *\n * @template RecordLike - The record-like type of the argument of `Object.entries()`.\n * @template KeyType - The subset of keys used by this type.\n */\nexport type TEntry<RecordLike, KeyType extends keyof RecordLike = keyof RecordLike> = [\n KeyType,\n RecordLike[KeyType]\n];\n/** The type used in `OptionsType`s when no options are specified. */\nexport type NoOptions = typeof NoOptions;\n/**\n * Define options for a given type as a union of `unique symbol` types.\n * All options must be *optional* by the type that uses these options.\n * The type that uses these options should have a type parameter `OptionsType`\n * defined with `OptionsType extends TOptions = NoOptions`. You will have to import\n * {@link NoOptions}, but this should be done anyway, since making all options types\n * optional should be optional. For this reason {@link NoOptions} is exported from the\n * same module as this type.\n *\n * @template OptionsType - The `unique symbol` types that act as options.\n *\n * @example * See the {@link Array.Options:type} type as an example.\n */\nexport type TOptions<OptionsType extends symbol = NoOptions> = OptionsType | NoOptions;\n/**\n * The opposite of {@link NonNullable}: the union of a given {@link Type}, `null`, and `undefined`.\n *\n * @template Type - The nontrivial type in this union.\n */\nexport type TNullable<Type> = Type | null | undefined;\n/** An error that is thrown in default implementations of `abstract` `class`es. */\nexport class AbstractMethodCallError extends Error {\n public constructor(ClassName?: string) {\n super(ClassName);\n }\n}\n/** The type corresponding to the schema of `tsconfig.json`. */\nexport interface FTsConfig {\n extends?: string | Array<string>;\n files?: Array<string>;\n include?: Array<string>;\n exclude?: Array<string>;\n references?: Array<TypeScript.ProjectReference>;\n compilerOptions?: FCompilerOptions;\n watchOptions?: TypeScript.WatchOptions;\n typeAcquisition?: TypeScript.TypeAcquisition;\n compileOnSave?: boolean;\n}\ntype FOverriddenCompilerOptions = \"jsx\" | \"lib\" | \"module\" | \"moduleResolution\" | \"target\";\ntype FCompilerOptions = Omit<TypeScript.server.protocol.CompilerOptions, FOverriddenCompilerOptions> & Partial<{\n jsx: JsxEmit;\n lib: Array<string>;\n module: FModuleKind;\n moduleResolution: FModuleResolutionKind;\n target: FTarget;\n}>;\ntype JsxEmit = \"none\" | \"preserve\" | \"react-native\" | \"react\" | \"react-jsx\" | \"react-jsxdev\";\ntype FModuleKind = \"none\" | \"commonjs\" | \"amd\" | \"umd\" | \"system\" | \"es6\" | \"es2015\" | \"es2020\" | \"es2022\" | \"esnext\" | \"node16\" | \"node18\" | \"node20\" | \"nodenext\" | \"preserve\";\ntype FModuleResolutionKind = \"classic\" | \"node\" | \"node\" | \"node10\" | \"node16\" | \"nodenext\" | \"bundler\";\ntype FTarget = \"es3\" | \"es5\" | \"es6\" | \"es2015\" | \"es2016\" | \"es2017\" | \"es2018\" | \"es2019\" | \"es2020\" | \"es2021\" | \"es2022\" | \"es2023\" | \"es2024\" | \"es2025\" | \"esnext\" | \"json\" | \"esnext\" | \"es2025\";\n/**\n * Maps a given {@link RecordLike} type to an identical {@link Record} type, but\n * the properties are wrapped with {@link NonNullable}.\n *\n * @template RecordLike - The `Record`-like type from which this type is defined.\n */\nexport type TRecordNonNullable<RecordLike> = {\n [Key in keyof RecordLike]: NonNullable<RecordLike[Key]>;\n};\n", "/**\n * @file Async.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport { AbstractMethodCallError, type TNullable } from \"../Miscellaneous/Utility.Types.ts\";\nimport type { TOnFulfilled, TOnRejected, TPromiseCtorArgument, TTryResult, TTrySource } from \"./Async.Types.ts\";\nimport type { TFunction } from \"../Functional/Functional.Types.ts\";\n/**\n * Implements \"Errors-as-values\" for `async` functions and `Promise<DataType>`s.\n *\n * If the `async` function or `Promise<DataType>` returns/resolves, then the `Error`\n * property of the returned object will be `undefined`, and the result of the\n * `async` function or `Promise<DataType>` will reside in the `Data` property of the\n * returned object.\n *\n * Similarly, if the `async` function or `Promise<DataType>` throws, then the `Data`\n * property of the returned object is `undefined`, and the `Error` property is what\n * was thrown to the `catch` block.\n *\n * @template DataType - The type of the data that the `async` function or `Promise<DataType>`.\n * @param Source - The `async` function or `Promise` to evaluate.\n *\n * @returns {TTryResult<DataType>} A {@link TTryResult} containing either the result\n * ({@link TTryResult.Data}) or error {@link TTryResult.Error}.\n *\n * @example\n * // With an `async` function,\n * async function GetName(): Promise<string> { ... }\n * // Or, with a `Promise`,\n * const GetName: Promise<string> = new Promise<string>(...);\n *\n * // For both of the above cases, `Try` behaves the same:\n * const { Data: Name, Error: NameError } = await Try(GetName);\n * // If `GetName` returned,\n * // `typeof Name` <- `\"string\"`\n * // `typeof NameError` <- `\"undefined\"`\n * // If `GetName` threw,\n * // `typeof Name` <- `\"undefined\"`\n * // `NameError !== undefined` <- `true` (Unless `GetName` threw `undefined`).\n */\nexport async function Try<DataType>(Source: TTrySource<DataType>): Promise<TTryResult<DataType>> {\n try {\n const Data: DataType = typeof Source === \"function\"\n ? await Source()\n : await Source;\n return {\n Data,\n Error: undefined\n };\n }\n catch (ErrorValue: unknown) {\n return {\n Data: undefined,\n Error: ErrorValue\n };\n }\n}\n/**\n * A cleaner way of using `Array.prototype.map` with an `async` function.\n *\n * @template ArgumentElementType - The type of the given {@link Elements}.\n * @template ReturnElementType - The type of the `Array` returned by this.\n *\n * @param Elements - The `Array` that will be transformed.\n * @param Mapper - The function that maps each {@link ArgumentElementType}\n * to a {@link ReturnElementType}.\n *\n * @returns {Array<ReturnElementType>} An `Array` of {@link ReturnElementType}.\n *\n * @example\n * In an `async` function,\n * ```typescript\n * const ArgumentElements: Array<ArgumentElementType> = [ ... ];\n * const ToReturnElement = async (Element: ArgumentElementType): Promise<ReturnElementType> => ...;\n * const ReturnElements: Array<ReturnElementType> = await Map(ArgumentElements, ToReturnElement);\n * ```\n */\nexport async function Map<ArgumentElementType, ReturnElementType>(Elements: Array<ArgumentElementType>, Mapper: ((Element: ArgumentElementType) => Promise<ReturnElementType>)): Promise<Array<ReturnElementType>> {\n const MapperWrapped = async (Element: ArgumentElementType): Promise<ReturnElementType> => {\n return Mapper(Element);\n };\n const Out: Array<Promise<ReturnElementType>> = Elements.map(MapperWrapped);\n return await Promise.all(Out);\n}\n/**\n * An abstract implementation of {@link PromiseLike}. This exists only to maintain the\n * project's naming convention.\n */\nexport abstract class TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public then<ResultType = ResolveType, RejectType = never>(_OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, _OnRejected?: TOnRejected<RejectType>): TPromiseLike<ResultType | RejectType> {\n throw new AbstractMethodCallError(\"TPromiseLike\");\n }\n}\n/**\n * The {@link TypeError} that is thrown by the constructor of {@link TPromise}\n * iff it receives an argument that is not a {@link TPromiseCtorArgument}.\n * It does not provide any additional information (in particular, it does not\n * add any properties, and it does not set any properties inherited from\n * {@link TypeError}).\n *\n * @note While the argument type of {@link TPromise}'s constructor is checked at runtime,\n * the type checker should prevent the error described by this from happening.\n */\nexport class FPromiseInstantiationError extends TypeError {\n public constructor() {\n super();\n }\n}\n/**\n * A `then`-able wrapper of {@link Promise}.\n *\n * @template ResolveType - The type to which this resolves, if it does resolve.\n */\nexport class TPromise<ResolveType> extends TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public constructor(Argument: TPromiseCtorArgument<ResolveType>) {\n super();\n if (typeof Argument === \"function\") {\n this.Underlying = new Promise<ResolveType>(Argument);\n }\n else {\n if (Argument instanceof TPromise) {\n this.Underlying = Argument.Raw();\n }\n else if (Argument instanceof Promise) {\n this.Underlying = Argument;\n }\n }\n throw new FPromiseInstantiationError();\n }\n private readonly Underlying: Promise<ResolveType>;\n /**\n * This class's extension of {@link Promise!then}.\n *\n * @template ResultType - The type to which the value underlying the {@link TPromise} returned by this\n * will resolve, if the {@link TPromise} resolves.\n *\n * @template RejectType - The type to which the value underlying the {@link TPromise} returned by this\n * will reject, if the {@link TPromise} rejects.\n *\n * @param OnFulfilled - The callback that is called when the underlying {@link Promise} resolves,\n * if it resolves.\n *\n * @param OnRejected - The callback that is called when the underlying {@link Promise} rejects,\n * if it rejects.\n *\n * @returns {TPromise<ResultType | RejectType>} A new {@link TPromise} of the result of the\n * given callbacks.\n *\n * @example\n * ```typescript\n * const Example: TPromise<string> = new TPromise<string>((Resolve, Reject) =>\n * {\n * if (Math.random() < 0.5)\n * {\n * Resolve(\"Success\");\n * }\n * else\n * {\n * Reject(\"Error\");\n * }\n * });\n *\n * Example.then(\n * (Value: string): void =>\n * {\n * // `Value` <- `\"Success\"`\n * },\n * (Reason: unknown): void =>\n * {\n * // `Reason` <- `\"Error\"`\n * }\n * );\n * ```\n */\n public Then<ResultType = ResolveType, RejectType = never>(OnFulfilled: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public override then<ResultType = ResolveType, RejectType = never>(OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public Catch<ResultType = never>(OnRejected?: TNullable<TOnRejected<ResolveType>>): TPromiseLike<ResolveType | ResultType> {\n return new TPromise<ResolveType | ResultType>(this.Underlying.catch(OnRejected));\n }\n public Finally(OnFinally?: TNullable<TFunction>): TPromise<ResolveType> {\n return new TPromise(this.Underlying.finally(OnFinally));\n }\n public static Resolve<ResolveType>(Value: ResolveType | PromiseLike<ResolveType>): TPromise<Awaited<ResolveType>> {\n return new TPromise(Promise.resolve(Value));\n }\n public static Reject<ResolveType = unknown>(Reason?: unknown): TPromise<ResolveType> {\n return new TPromise(Promise.reject<ResolveType>(Reason));\n }\n public Raw(): Promise<ResolveType> {\n return this.Underlying;\n }\n}\n;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
4
|
+
"sourcesContent": ["/**\n * @file index.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nexport * from \"./Async.ts\";\nexport * from \"./Async.Types.ts\";\n", "/**\n * @file Utility.Types.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport type { NoOptions } from \"./Utility.Internal.ts\";\n/**\n * @deprecated Use {@link TMutable} instead.\n *\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n */\nexport type TDeepWriteable<RecordLike> = {\n -readonly [Key in keyof RecordLike]: TDeepWriteable<RecordLike[Key]>;\n};\n/**\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n * @template ShallowOption - Whether the `readonly` modifier should be stripped recursively.\n * If `true` (the default), then only the properties of the given type will have the `readonly`\n * modifier stripped (that is, if any of these properties is a {@link Record} type with `readonly`\n * modifiers, then those will *not* be removed if {@link ShallowOption} is `true`).\n */\nexport type TMutable<RecordLike, ShallowOption extends boolean = true> = ShallowOption extends false ? {\n -readonly [Key in keyof RecordLike]: RecordLike[Key];\n} : ShallowOption extends true ? {\n -readonly [Key in keyof RecordLike]: TMutable<RecordLike[Key]>;\n} : never;\n/**\n * Given a {@link RecordLike | record-like type}, this type is the union\n * of the values of all properties in the {@link RecordLike | record-like type}.\n *\n * @template RecordLike - The record-like type from which this type extracts value types.\n */\nexport type TValues<RecordLike> = RecordLike[keyof RecordLike];\n/**\n * The element type of the return value of `Object.entries()`.\n *\n * @template RecordLike - The record-like type of the argument of `Object.entries()`.\n * @template KeyType - The subset of keys used by this type.\n */\nexport type TEntry<RecordLike, KeyType extends keyof RecordLike = keyof RecordLike> = [\n KeyType,\n RecordLike[KeyType]\n];\n/** The type used in `OptionsType`s when no options are specified. */\nexport type NoOptions = typeof NoOptions;\n/**\n * Define options for a given type as a union of `unique symbol` types.\n * All options must be *optional* by the type that uses these options.\n * The type that uses these options should have a type parameter `OptionsType`\n * defined with `OptionsType extends TOptions = NoOptions`. You will have to import\n * {@link NoOptions}, but this should be done anyway, since making all options types\n * optional should be optional. For this reason {@link NoOptions} is exported from the\n * same module as this type.\n *\n * @template OptionsType - The `unique symbol` types that act as options.\n *\n * @example * See the {@link Array.Options:type} type as an example.\n */\nexport type TOptions<OptionsType extends symbol = NoOptions> = OptionsType | NoOptions;\n/**\n * The opposite of {@link NonNullable}: the union of a given {@link Type}, `null`, and `undefined`.\n *\n * @template Type - The nontrivial type in this union.\n */\nexport type TNullable<Type> = Type | null | undefined;\n/** An error that is thrown in default implementations of `abstract` `class`es. */\nexport class AbstractMethodCallError extends Error {\n public constructor(ClassName?: string) {\n super(ClassName);\n }\n}\n/**\n * Maps a given {@link RecordLike} type to an identical {@link Record} type, but\n * the properties are wrapped with {@link NonNullable}.\n *\n * @template RecordLike - The `Record`-like type from which this type is defined.\n */\nexport type TRecordNonNullable<RecordLike> = {\n [Key in keyof RecordLike]: NonNullable<RecordLike[Key]>;\n};\n/**\n * A \"safe\" intersection of two types, such that if exactly one\n * of the two types is `never`, then this evaluates to the other type.\n * This evaluates to the intersection of the two types iff *both*\n * type parameters.\n *\n * @template LeftType - The first type parameter.\n * @template RightType - The second type parameter.\n */\nexport type TSafeIntersection<LeftType, RightType> = [\n LeftType\n] extends [\n never\n] ? [\n RightType\n] extends [\n never\n] ? never : RightType : [\n RightType\n] extends [\n never\n] ? LeftType : (LeftType & RightType);\n", "/**\n * @file Async.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport { AbstractMethodCallError, type TNullable } from \"../Miscellaneous/Utility.Types.ts\";\nimport type { TOnFulfilled, TOnRejected, TPromiseCtorArgument, TTryResult, TTrySource } from \"./Async.Types.ts\";\nimport type { TFunction } from \"../Functional/Functional.Types.ts\";\n/**\n * Implements \"Errors-as-values\" for `async` functions and `Promise<DataType>`s.\n *\n * If the `async` function or `Promise<DataType>` returns/resolves, then the `Error`\n * property of the returned object will be `undefined`, and the result of the\n * `async` function or `Promise<DataType>` will reside in the `Data` property of the\n * returned object.\n *\n * Similarly, if the `async` function or `Promise<DataType>` throws, then the `Data`\n * property of the returned object is `undefined`, and the `Error` property is what\n * was thrown to the `catch` block.\n *\n * @template DataType - The type of the data that the `async` function or `Promise<DataType>`.\n * @param Source - The `async` function or `Promise` to evaluate.\n *\n * @returns {TTryResult<DataType>} A {@link TTryResult} containing either the result\n * ({@link TTryResult.Data}) or error {@link TTryResult.Error}.\n *\n * @example\n * // With an `async` function,\n * async function GetName(): Promise<string> { ... }\n * // Or, with a `Promise`,\n * const GetName: Promise<string> = new Promise<string>(...);\n *\n * // For both of the above cases, `Try` behaves the same:\n * const { Data: Name, Error: NameError } = await Try(GetName);\n * // If `GetName` returned,\n * // `typeof Name` <- `\"string\"`\n * // `typeof NameError` <- `\"undefined\"`\n * // If `GetName` threw,\n * // `typeof Name` <- `\"undefined\"`\n * // `NameError !== undefined` <- `true` (Unless `GetName` threw `undefined`).\n */\nexport async function Try<DataType>(Source: TTrySource<DataType>): Promise<TTryResult<DataType>> {\n try {\n const Data: DataType = typeof Source === \"function\"\n ? await Source()\n : await Source;\n return {\n Data,\n Error: undefined\n };\n }\n catch (ErrorValue: unknown) {\n return {\n Data: undefined,\n Error: ErrorValue\n };\n }\n}\n/**\n * A cleaner way of using `Array.prototype.map` with an `async` function.\n *\n * @template ArgumentElementType - The type of the given {@link Elements}.\n * @template ReturnElementType - The type of the `Array` returned by this.\n *\n * @param Elements - The `Array` that will be transformed.\n * @param Mapper - The function that maps each {@link ArgumentElementType}\n * to a {@link ReturnElementType}.\n *\n * @returns {Array<ReturnElementType>} An `Array` of {@link ReturnElementType}.\n *\n * @example\n * In an `async` function,\n * ```typescript\n * const ArgumentElements: Array<ArgumentElementType> = [ ... ];\n * const ToReturnElement = async (Element: ArgumentElementType): Promise<ReturnElementType> => ...;\n * const ReturnElements: Array<ReturnElementType> = await Map(ArgumentElements, ToReturnElement);\n * ```\n */\nexport async function Map<ArgumentElementType, ReturnElementType>(Elements: Array<ArgumentElementType>, Mapper: ((Element: ArgumentElementType) => Promise<ReturnElementType>)): Promise<Array<ReturnElementType>> {\n const MapperWrapped = async (Element: ArgumentElementType): Promise<ReturnElementType> => {\n return Mapper(Element);\n };\n const Out: Array<Promise<ReturnElementType>> = Elements.map(MapperWrapped);\n return await Promise.all(Out);\n}\n/**\n * An abstract implementation of {@link PromiseLike}. This exists only to maintain the\n * project's naming convention.\n */\nexport abstract class TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public then<ResultType = ResolveType, RejectType = never>(_OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, _OnRejected?: TOnRejected<RejectType>): TPromiseLike<ResultType | RejectType> {\n throw new AbstractMethodCallError(\"TPromiseLike\");\n }\n}\n/**\n * The {@link TypeError} that is thrown by the constructor of {@link TPromise}\n * iff it receives an argument that is not a {@link TPromiseCtorArgument}.\n * It does not provide any additional information (in particular, it does not\n * add any properties, and it does not set any properties inherited from\n * {@link TypeError}).\n *\n * @note While the argument type of {@link TPromise}'s constructor is checked at runtime,\n * the type checker should prevent the error described by this from happening.\n */\nexport class FPromiseInstantiationError extends TypeError {\n public constructor() {\n super();\n }\n}\n/**\n * A `then`-able wrapper of {@link Promise}.\n *\n * @template ResolveType - The type to which this resolves, if it does resolve.\n */\nexport class TPromise<ResolveType> extends TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public constructor(Argument: TPromiseCtorArgument<ResolveType>) {\n super();\n if (typeof Argument === \"function\") {\n this.Underlying = new Promise<ResolveType>(Argument);\n }\n else {\n if (Argument instanceof TPromise) {\n this.Underlying = Argument.Raw();\n }\n else if (Argument instanceof Promise) {\n this.Underlying = Argument;\n }\n }\n throw new FPromiseInstantiationError();\n }\n private readonly Underlying: Promise<ResolveType>;\n /**\n * This class's extension of {@link Promise!then}.\n *\n * @template ResultType - The type to which the value underlying the {@link TPromise} returned by this\n * will resolve, if the {@link TPromise} resolves.\n *\n * @template RejectType - The type to which the value underlying the {@link TPromise} returned by this\n * will reject, if the {@link TPromise} rejects.\n *\n * @param OnFulfilled - The callback that is called when the underlying {@link Promise} resolves,\n * if it resolves.\n *\n * @param OnRejected - The callback that is called when the underlying {@link Promise} rejects,\n * if it rejects.\n *\n * @returns {TPromise<ResultType | RejectType>} A new {@link TPromise} of the result of the\n * given callbacks.\n *\n * @example\n * ```typescript\n * const Example: TPromise<string> = new TPromise<string>((Resolve, Reject) =>\n * {\n * if (Math.random() < 0.5)\n * {\n * Resolve(\"Success\");\n * }\n * else\n * {\n * Reject(\"Error\");\n * }\n * });\n *\n * Example.then(\n * (Value: string): void =>\n * {\n * // `Value` <- `\"Success\"`\n * },\n * (Reason: unknown): void =>\n * {\n * // `Reason` <- `\"Error\"`\n * }\n * );\n * ```\n */\n public Then<ResultType = ResolveType, RejectType = never>(OnFulfilled: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public override then<ResultType = ResolveType, RejectType = never>(OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public Catch<ResultType = never>(OnRejected?: TNullable<TOnRejected<ResolveType>>): TPromiseLike<ResolveType | ResultType> {\n return new TPromise<ResolveType | ResultType>(this.Underlying.catch(OnRejected));\n }\n public Finally(OnFinally?: TNullable<TFunction>): TPromise<ResolveType> {\n return new TPromise(this.Underlying.finally(OnFinally));\n }\n public static Resolve<ResolveType>(Value: ResolveType | PromiseLike<ResolveType>): TPromise<Awaited<ResolveType>> {\n return new TPromise(Promise.resolve(Value));\n }\n public static Reject<ResolveType = unknown>(Reason?: unknown): TPromise<ResolveType> {\n return new TPromise(Promise.reject<ResolveType>(Reason));\n }\n public Raw(): Promise<ResolveType> {\n return this.Underlying;\n }\n}\n;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyEO,IAAM,0BA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8CO,KAAmD,aAAoD,YAAyE;AACnL,WAAO,IAAI,UAAkC,KAAK,WAAW,KAAK,aAAa,UAAU,CAAC;AAAA,EAC9F;AAAA,EACgB,KAAmD,aAAqD,YAAyE;AAC7L,WAAO,IAAI,UAAkC,KAAK,WAAW,KAAK,aAAa,UAAU,CAAC;AAAA,EAC9F;AAAA,EACO,MAA0B,YAA0F;AACvH,WAAO,IAAI,UAAmC,KAAK,WAAW,MAAM,UAAU,CAAC;AAAA,EACnF;AAAA,EACO,QAAQ,WAAyD;AACpE,WAAO,IAAI,UAAS,KAAK,WAAW,QAAQ,SAAS,CAAC;AAAA,EAC1D;AAAA,EACA,OAAc,QAAqB,OAA+E;AAC9G,WAAO,IAAI,UAAS,QAAQ,QAAQ,KAAK,CAAC;AAAA,EAC9C;AAAA,EACA,OAAc,OAA8B,QAAyC;AACjF,WAAO,IAAI,UAAS,QAAQ,OAAoB,MAAM,CAAC;AAAA,EAC3D;AAAA,EACO,MAA4B;AAC/B,WAAO,KAAK;AAAA,EAChB;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../Source/Miscellaneous/Utility.Types.ts", "../Source/Async/Async.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @file Utility.Types.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport type { NoOptions } from \"./Utility.Internal.ts\";\nimport type TypeScript from \"typescript\";\n/**\n * @deprecated Use {@link TMutable} instead.\n *\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n */\nexport type TDeepWriteable<RecordLike> = {\n -readonly [Key in keyof RecordLike]: TDeepWriteable<RecordLike[Key]>;\n};\n/**\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n * @template ShallowOption - Whether the `readonly` modifier should be stripped recursively.\n * If `true` (the default), then only the properties of the given type will have the `readonly`\n * modifier stripped (that is, if any of these properties is a {@link Record} type with `readonly`\n * modifiers, then those will *not* be removed if {@link ShallowOption} is `true`).\n */\nexport type TMutable<RecordLike, ShallowOption extends boolean = true> = ShallowOption extends false ? {\n -readonly [Key in keyof RecordLike]: RecordLike[Key];\n} : ShallowOption extends true ? {\n -readonly [Key in keyof RecordLike]: TMutable<RecordLike[Key]>;\n} : never;\n/**\n * Given a {@link RecordLike | record-like type}, this type is the union\n * of the values of all properties in the {@link RecordLike | record-like type}.\n *\n * @template RecordLike - The record-like type from which this type extracts value types.\n */\nexport type TValues<RecordLike> = RecordLike[keyof RecordLike];\n/**\n * The element type of the return value of `Object.entries()`.\n *\n * @template RecordLike - The record-like type of the argument of `Object.entries()`.\n * @template KeyType - The subset of keys used by this type.\n */\nexport type TEntry<RecordLike, KeyType extends keyof RecordLike = keyof RecordLike> = [\n KeyType,\n RecordLike[KeyType]\n];\n/** The type used in `OptionsType`s when no options are specified. */\nexport type NoOptions = typeof NoOptions;\n/**\n * Define options for a given type as a union of `unique symbol` types.\n * All options must be *optional* by the type that uses these options.\n * The type that uses these options should have a type parameter `OptionsType`\n * defined with `OptionsType extends TOptions = NoOptions`. You will have to import\n * {@link NoOptions}, but this should be done anyway, since making all options types\n * optional should be optional. For this reason {@link NoOptions} is exported from the\n * same module as this type.\n *\n * @template OptionsType - The `unique symbol` types that act as options.\n *\n * @example * See the {@link Array.Options:type} type as an example.\n */\nexport type TOptions<OptionsType extends symbol = NoOptions> = OptionsType | NoOptions;\n/**\n * The opposite of {@link NonNullable}: the union of a given {@link Type}, `null`, and `undefined`.\n *\n * @template Type - The nontrivial type in this union.\n */\nexport type TNullable<Type> = Type | null | undefined;\n/** An error that is thrown in default implementations of `abstract` `class`es. */\nexport class AbstractMethodCallError extends Error {\n public constructor(ClassName?: string) {\n super(ClassName);\n }\n}\n/** The type corresponding to the schema of `tsconfig.json`. */\nexport interface FTsConfig {\n extends?: string | Array<string>;\n files?: Array<string>;\n include?: Array<string>;\n exclude?: Array<string>;\n references?: Array<TypeScript.ProjectReference>;\n compilerOptions?: FCompilerOptions;\n watchOptions?: TypeScript.WatchOptions;\n typeAcquisition?: TypeScript.TypeAcquisition;\n compileOnSave?: boolean;\n}\ntype FOverriddenCompilerOptions = \"jsx\" | \"lib\" | \"module\" | \"moduleResolution\" | \"target\";\ntype FCompilerOptions = Omit<TypeScript.server.protocol.CompilerOptions, FOverriddenCompilerOptions> & Partial<{\n jsx: JsxEmit;\n lib: Array<string>;\n module: FModuleKind;\n moduleResolution: FModuleResolutionKind;\n target: FTarget;\n}>;\ntype JsxEmit = \"none\" | \"preserve\" | \"react-native\" | \"react\" | \"react-jsx\" | \"react-jsxdev\";\ntype FModuleKind = \"none\" | \"commonjs\" | \"amd\" | \"umd\" | \"system\" | \"es6\" | \"es2015\" | \"es2020\" | \"es2022\" | \"esnext\" | \"node16\" | \"node18\" | \"node20\" | \"nodenext\" | \"preserve\";\ntype FModuleResolutionKind = \"classic\" | \"node\" | \"node\" | \"node10\" | \"node16\" | \"nodenext\" | \"bundler\";\ntype FTarget = \"es3\" | \"es5\" | \"es6\" | \"es2015\" | \"es2016\" | \"es2017\" | \"es2018\" | \"es2019\" | \"es2020\" | \"es2021\" | \"es2022\" | \"es2023\" | \"es2024\" | \"es2025\" | \"esnext\" | \"json\" | \"esnext\" | \"es2025\";\n/**\n * Maps a given {@link RecordLike} type to an identical {@link Record} type, but\n * the properties are wrapped with {@link NonNullable}.\n *\n * @template RecordLike - The `Record`-like type from which this type is defined.\n */\nexport type TRecordNonNullable<RecordLike> = {\n [Key in keyof RecordLike]: NonNullable<RecordLike[Key]>;\n};\n", "/**\n * @file Async.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport { AbstractMethodCallError, type TNullable } from \"../Miscellaneous/Utility.Types.ts\";\nimport type { TOnFulfilled, TOnRejected, TPromiseCtorArgument, TTryResult, TTrySource } from \"./Async.Types.ts\";\nimport type { TFunction } from \"../Functional/Functional.Types.ts\";\n/**\n * Implements \"Errors-as-values\" for `async` functions and `Promise<DataType>`s.\n *\n * If the `async` function or `Promise<DataType>` returns/resolves, then the `Error`\n * property of the returned object will be `undefined`, and the result of the\n * `async` function or `Promise<DataType>` will reside in the `Data` property of the\n * returned object.\n *\n * Similarly, if the `async` function or `Promise<DataType>` throws, then the `Data`\n * property of the returned object is `undefined`, and the `Error` property is what\n * was thrown to the `catch` block.\n *\n * @template DataType - The type of the data that the `async` function or `Promise<DataType>`.\n * @param Source - The `async` function or `Promise` to evaluate.\n *\n * @returns {TTryResult<DataType>} A {@link TTryResult} containing either the result\n * ({@link TTryResult.Data}) or error {@link TTryResult.Error}.\n *\n * @example\n * // With an `async` function,\n * async function GetName(): Promise<string> { ... }\n * // Or, with a `Promise`,\n * const GetName: Promise<string> = new Promise<string>(...);\n *\n * // For both of the above cases, `Try` behaves the same:\n * const { Data: Name, Error: NameError } = await Try(GetName);\n * // If `GetName` returned,\n * // `typeof Name` <- `\"string\"`\n * // `typeof NameError` <- `\"undefined\"`\n * // If `GetName` threw,\n * // `typeof Name` <- `\"undefined\"`\n * // `NameError !== undefined` <- `true` (Unless `GetName` threw `undefined`).\n */\nexport async function Try<DataType>(Source: TTrySource<DataType>): Promise<TTryResult<DataType>> {\n try {\n const Data: DataType = typeof Source === \"function\"\n ? await Source()\n : await Source;\n return {\n Data,\n Error: undefined\n };\n }\n catch (ErrorValue: unknown) {\n return {\n Data: undefined,\n Error: ErrorValue\n };\n }\n}\n/**\n * A cleaner way of using `Array.prototype.map` with an `async` function.\n *\n * @template ArgumentElementType - The type of the given {@link Elements}.\n * @template ReturnElementType - The type of the `Array` returned by this.\n *\n * @param Elements - The `Array` that will be transformed.\n * @param Mapper - The function that maps each {@link ArgumentElementType}\n * to a {@link ReturnElementType}.\n *\n * @returns {Array<ReturnElementType>} An `Array` of {@link ReturnElementType}.\n *\n * @example\n * In an `async` function,\n * ```typescript\n * const ArgumentElements: Array<ArgumentElementType> = [ ... ];\n * const ToReturnElement = async (Element: ArgumentElementType): Promise<ReturnElementType> => ...;\n * const ReturnElements: Array<ReturnElementType> = await Map(ArgumentElements, ToReturnElement);\n * ```\n */\nexport async function Map<ArgumentElementType, ReturnElementType>(Elements: Array<ArgumentElementType>, Mapper: ((Element: ArgumentElementType) => Promise<ReturnElementType>)): Promise<Array<ReturnElementType>> {\n const MapperWrapped = async (Element: ArgumentElementType): Promise<ReturnElementType> => {\n return Mapper(Element);\n };\n const Out: Array<Promise<ReturnElementType>> = Elements.map(MapperWrapped);\n return await Promise.all(Out);\n}\n/**\n * An abstract implementation of {@link PromiseLike}. This exists only to maintain the\n * project's naming convention.\n */\nexport abstract class TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public then<ResultType = ResolveType, RejectType = never>(_OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, _OnRejected?: TOnRejected<RejectType>): TPromiseLike<ResultType | RejectType> {\n throw new AbstractMethodCallError(\"TPromiseLike\");\n }\n}\n/**\n * The {@link TypeError} that is thrown by the constructor of {@link TPromise}\n * iff it receives an argument that is not a {@link TPromiseCtorArgument}.\n * It does not provide any additional information (in particular, it does not\n * add any properties, and it does not set any properties inherited from\n * {@link TypeError}).\n *\n * @note While the argument type of {@link TPromise}'s constructor is checked at runtime,\n * the type checker should prevent the error described by this from happening.\n */\nexport class FPromiseInstantiationError extends TypeError {\n public constructor() {\n super();\n }\n}\n/**\n * A `then`-able wrapper of {@link Promise}.\n *\n * @template ResolveType - The type to which this resolves, if it does resolve.\n */\nexport class TPromise<ResolveType> extends TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public constructor(Argument: TPromiseCtorArgument<ResolveType>) {\n super();\n if (typeof Argument === \"function\") {\n this.Underlying = new Promise<ResolveType>(Argument);\n }\n else {\n if (Argument instanceof TPromise) {\n this.Underlying = Argument.Raw();\n }\n else if (Argument instanceof Promise) {\n this.Underlying = Argument;\n }\n }\n throw new FPromiseInstantiationError();\n }\n private readonly Underlying: Promise<ResolveType>;\n /**\n * This class's extension of {@link Promise!then}.\n *\n * @template ResultType - The type to which the value underlying the {@link TPromise} returned by this\n * will resolve, if the {@link TPromise} resolves.\n *\n * @template RejectType - The type to which the value underlying the {@link TPromise} returned by this\n * will reject, if the {@link TPromise} rejects.\n *\n * @param OnFulfilled - The callback that is called when the underlying {@link Promise} resolves,\n * if it resolves.\n *\n * @param OnRejected - The callback that is called when the underlying {@link Promise} rejects,\n * if it rejects.\n *\n * @returns {TPromise<ResultType | RejectType>} A new {@link TPromise} of the result of the\n * given callbacks.\n *\n * @example\n * ```typescript\n * const Example: TPromise<string> = new TPromise<string>((Resolve, Reject) =>\n * {\n * if (Math.random() < 0.5)\n * {\n * Resolve(\"Success\");\n * }\n * else\n * {\n * Reject(\"Error\");\n * }\n * });\n *\n * Example.then(\n * (Value: string): void =>\n * {\n * // `Value` <- `\"Success\"`\n * },\n * (Reason: unknown): void =>\n * {\n * // `Reason` <- `\"Error\"`\n * }\n * );\n * ```\n */\n public Then<ResultType = ResolveType, RejectType = never>(OnFulfilled: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public override then<ResultType = ResolveType, RejectType = never>(OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public Catch<ResultType = never>(OnRejected?: TNullable<TOnRejected<ResolveType>>): TPromiseLike<ResolveType | ResultType> {\n return new TPromise<ResolveType | ResultType>(this.Underlying.catch(OnRejected));\n }\n public Finally(OnFinally?: TNullable<TFunction>): TPromise<ResolveType> {\n return new TPromise(this.Underlying.finally(OnFinally));\n }\n public static Resolve<ResolveType>(Value: ResolveType | PromiseLike<ResolveType>): TPromise<Awaited<ResolveType>> {\n return new TPromise(Promise.resolve(Value));\n }\n public static Reject<ResolveType = unknown>(Reason?: unknown): TPromise<ResolveType> {\n return new TPromise(Promise.reject<ResolveType>(Reason));\n }\n public Raw(): Promise<ResolveType> {\n return this.Underlying;\n }\n}\n;\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * @file Utility.Types.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport type { NoOptions } from \"./Utility.Internal.ts\";\n/**\n * @deprecated Use {@link TMutable} instead.\n *\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n */\nexport type TDeepWriteable<RecordLike> = {\n -readonly [Key in keyof RecordLike]: TDeepWriteable<RecordLike[Key]>;\n};\n/**\n * Defines a type that corresponds to {@link RecordLike}, such that every\n * `readonly` modifier is removed, recursively.\n *\n * @template RecordLike - The type to make writeable.\n * @template ShallowOption - Whether the `readonly` modifier should be stripped recursively.\n * If `true` (the default), then only the properties of the given type will have the `readonly`\n * modifier stripped (that is, if any of these properties is a {@link Record} type with `readonly`\n * modifiers, then those will *not* be removed if {@link ShallowOption} is `true`).\n */\nexport type TMutable<RecordLike, ShallowOption extends boolean = true> = ShallowOption extends false ? {\n -readonly [Key in keyof RecordLike]: RecordLike[Key];\n} : ShallowOption extends true ? {\n -readonly [Key in keyof RecordLike]: TMutable<RecordLike[Key]>;\n} : never;\n/**\n * Given a {@link RecordLike | record-like type}, this type is the union\n * of the values of all properties in the {@link RecordLike | record-like type}.\n *\n * @template RecordLike - The record-like type from which this type extracts value types.\n */\nexport type TValues<RecordLike> = RecordLike[keyof RecordLike];\n/**\n * The element type of the return value of `Object.entries()`.\n *\n * @template RecordLike - The record-like type of the argument of `Object.entries()`.\n * @template KeyType - The subset of keys used by this type.\n */\nexport type TEntry<RecordLike, KeyType extends keyof RecordLike = keyof RecordLike> = [\n KeyType,\n RecordLike[KeyType]\n];\n/** The type used in `OptionsType`s when no options are specified. */\nexport type NoOptions = typeof NoOptions;\n/**\n * Define options for a given type as a union of `unique symbol` types.\n * All options must be *optional* by the type that uses these options.\n * The type that uses these options should have a type parameter `OptionsType`\n * defined with `OptionsType extends TOptions = NoOptions`. You will have to import\n * {@link NoOptions}, but this should be done anyway, since making all options types\n * optional should be optional. For this reason {@link NoOptions} is exported from the\n * same module as this type.\n *\n * @template OptionsType - The `unique symbol` types that act as options.\n *\n * @example * See the {@link Array.Options:type} type as an example.\n */\nexport type TOptions<OptionsType extends symbol = NoOptions> = OptionsType | NoOptions;\n/**\n * The opposite of {@link NonNullable}: the union of a given {@link Type}, `null`, and `undefined`.\n *\n * @template Type - The nontrivial type in this union.\n */\nexport type TNullable<Type> = Type | null | undefined;\n/** An error that is thrown in default implementations of `abstract` `class`es. */\nexport class AbstractMethodCallError extends Error {\n public constructor(ClassName?: string) {\n super(ClassName);\n }\n}\n/**\n * Maps a given {@link RecordLike} type to an identical {@link Record} type, but\n * the properties are wrapped with {@link NonNullable}.\n *\n * @template RecordLike - The `Record`-like type from which this type is defined.\n */\nexport type TRecordNonNullable<RecordLike> = {\n [Key in keyof RecordLike]: NonNullable<RecordLike[Key]>;\n};\n/**\n * A \"safe\" intersection of two types, such that if exactly one\n * of the two types is `never`, then this evaluates to the other type.\n * This evaluates to the intersection of the two types iff *both*\n * type parameters.\n *\n * @template LeftType - The first type parameter.\n * @template RightType - The second type parameter.\n */\nexport type TSafeIntersection<LeftType, RightType> = [\n LeftType\n] extends [\n never\n] ? [\n RightType\n] extends [\n never\n] ? never : RightType : [\n RightType\n] extends [\n never\n] ? LeftType : (LeftType & RightType);\n", "/**\n * @file Async.ts\n * @author Gage Sorrell <gage@sorrell.sh>\n * @copyright (c) 2026 Gage Sorrell\n * @license MIT\n */\nimport { AbstractMethodCallError, type TNullable } from \"../Miscellaneous/Utility.Types.ts\";\nimport type { TOnFulfilled, TOnRejected, TPromiseCtorArgument, TTryResult, TTrySource } from \"./Async.Types.ts\";\nimport type { TFunction } from \"../Functional/Functional.Types.ts\";\n/**\n * Implements \"Errors-as-values\" for `async` functions and `Promise<DataType>`s.\n *\n * If the `async` function or `Promise<DataType>` returns/resolves, then the `Error`\n * property of the returned object will be `undefined`, and the result of the\n * `async` function or `Promise<DataType>` will reside in the `Data` property of the\n * returned object.\n *\n * Similarly, if the `async` function or `Promise<DataType>` throws, then the `Data`\n * property of the returned object is `undefined`, and the `Error` property is what\n * was thrown to the `catch` block.\n *\n * @template DataType - The type of the data that the `async` function or `Promise<DataType>`.\n * @param Source - The `async` function or `Promise` to evaluate.\n *\n * @returns {TTryResult<DataType>} A {@link TTryResult} containing either the result\n * ({@link TTryResult.Data}) or error {@link TTryResult.Error}.\n *\n * @example\n * // With an `async` function,\n * async function GetName(): Promise<string> { ... }\n * // Or, with a `Promise`,\n * const GetName: Promise<string> = new Promise<string>(...);\n *\n * // For both of the above cases, `Try` behaves the same:\n * const { Data: Name, Error: NameError } = await Try(GetName);\n * // If `GetName` returned,\n * // `typeof Name` <- `\"string\"`\n * // `typeof NameError` <- `\"undefined\"`\n * // If `GetName` threw,\n * // `typeof Name` <- `\"undefined\"`\n * // `NameError !== undefined` <- `true` (Unless `GetName` threw `undefined`).\n */\nexport async function Try<DataType>(Source: TTrySource<DataType>): Promise<TTryResult<DataType>> {\n try {\n const Data: DataType = typeof Source === \"function\"\n ? await Source()\n : await Source;\n return {\n Data,\n Error: undefined\n };\n }\n catch (ErrorValue: unknown) {\n return {\n Data: undefined,\n Error: ErrorValue\n };\n }\n}\n/**\n * A cleaner way of using `Array.prototype.map` with an `async` function.\n *\n * @template ArgumentElementType - The type of the given {@link Elements}.\n * @template ReturnElementType - The type of the `Array` returned by this.\n *\n * @param Elements - The `Array` that will be transformed.\n * @param Mapper - The function that maps each {@link ArgumentElementType}\n * to a {@link ReturnElementType}.\n *\n * @returns {Array<ReturnElementType>} An `Array` of {@link ReturnElementType}.\n *\n * @example\n * In an `async` function,\n * ```typescript\n * const ArgumentElements: Array<ArgumentElementType> = [ ... ];\n * const ToReturnElement = async (Element: ArgumentElementType): Promise<ReturnElementType> => ...;\n * const ReturnElements: Array<ReturnElementType> = await Map(ArgumentElements, ToReturnElement);\n * ```\n */\nexport async function Map<ArgumentElementType, ReturnElementType>(Elements: Array<ArgumentElementType>, Mapper: ((Element: ArgumentElementType) => Promise<ReturnElementType>)): Promise<Array<ReturnElementType>> {\n const MapperWrapped = async (Element: ArgumentElementType): Promise<ReturnElementType> => {\n return Mapper(Element);\n };\n const Out: Array<Promise<ReturnElementType>> = Elements.map(MapperWrapped);\n return await Promise.all(Out);\n}\n/**\n * An abstract implementation of {@link PromiseLike}. This exists only to maintain the\n * project's naming convention.\n */\nexport abstract class TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public then<ResultType = ResolveType, RejectType = never>(_OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, _OnRejected?: TOnRejected<RejectType>): TPromiseLike<ResultType | RejectType> {\n throw new AbstractMethodCallError(\"TPromiseLike\");\n }\n}\n/**\n * The {@link TypeError} that is thrown by the constructor of {@link TPromise}\n * iff it receives an argument that is not a {@link TPromiseCtorArgument}.\n * It does not provide any additional information (in particular, it does not\n * add any properties, and it does not set any properties inherited from\n * {@link TypeError}).\n *\n * @note While the argument type of {@link TPromise}'s constructor is checked at runtime,\n * the type checker should prevent the error described by this from happening.\n */\nexport class FPromiseInstantiationError extends TypeError {\n public constructor() {\n super();\n }\n}\n/**\n * A `then`-able wrapper of {@link Promise}.\n *\n * @template ResolveType - The type to which this resolves, if it does resolve.\n */\nexport class TPromise<ResolveType> extends TPromiseLike<ResolveType> implements PromiseLike<ResolveType> {\n public constructor(Argument: TPromiseCtorArgument<ResolveType>) {\n super();\n if (typeof Argument === \"function\") {\n this.Underlying = new Promise<ResolveType>(Argument);\n }\n else {\n if (Argument instanceof TPromise) {\n this.Underlying = Argument.Raw();\n }\n else if (Argument instanceof Promise) {\n this.Underlying = Argument;\n }\n }\n throw new FPromiseInstantiationError();\n }\n private readonly Underlying: Promise<ResolveType>;\n /**\n * This class's extension of {@link Promise!then}.\n *\n * @template ResultType - The type to which the value underlying the {@link TPromise} returned by this\n * will resolve, if the {@link TPromise} resolves.\n *\n * @template RejectType - The type to which the value underlying the {@link TPromise} returned by this\n * will reject, if the {@link TPromise} rejects.\n *\n * @param OnFulfilled - The callback that is called when the underlying {@link Promise} resolves,\n * if it resolves.\n *\n * @param OnRejected - The callback that is called when the underlying {@link Promise} rejects,\n * if it rejects.\n *\n * @returns {TPromise<ResultType | RejectType>} A new {@link TPromise} of the result of the\n * given callbacks.\n *\n * @example\n * ```typescript\n * const Example: TPromise<string> = new TPromise<string>((Resolve, Reject) =>\n * {\n * if (Math.random() < 0.5)\n * {\n * Resolve(\"Success\");\n * }\n * else\n * {\n * Reject(\"Error\");\n * }\n * });\n *\n * Example.then(\n * (Value: string): void =>\n * {\n * // `Value` <- `\"Success\"`\n * },\n * (Reason: unknown): void =>\n * {\n * // `Reason` <- `\"Error\"`\n * }\n * );\n * ```\n */\n public Then<ResultType = ResolveType, RejectType = never>(OnFulfilled: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public override then<ResultType = ResolveType, RejectType = never>(OnFulfilled?: TOnFulfilled<ResolveType, ResultType>, OnRejected?: TOnRejected<RejectType>): TPromise<ResultType | RejectType> {\n return new TPromise<ResultType | RejectType>(this.Underlying.then(OnFulfilled, OnRejected));\n }\n public Catch<ResultType = never>(OnRejected?: TNullable<TOnRejected<ResolveType>>): TPromiseLike<ResolveType | ResultType> {\n return new TPromise<ResolveType | ResultType>(this.Underlying.catch(OnRejected));\n }\n public Finally(OnFinally?: TNullable<TFunction>): TPromise<ResolveType> {\n return new TPromise(this.Underlying.finally(OnFinally));\n }\n public static Resolve<ResolveType>(Value: ResolveType | PromiseLike<ResolveType>): TPromise<Awaited<ResolveType>> {\n return new TPromise(Promise.resolve(Value));\n }\n public static Reject<ResolveType = unknown>(Reason?: unknown): TPromise<ResolveType> {\n return new TPromise(Promise.reject<ResolveType>(Reason));\n }\n public Raw(): Promise<ResolveType> {\n return this.Underlying;\n }\n}\n;\n"],
|
|
5
|
+
"mappings": ";AAyEO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EACxC,YAAY,WAAoB;AACnC,UAAM,SAAS;AAAA,EACnB;AACJ;;;ACnCA,eAAsB,IAAc,QAA6D;AAC7F,MAAI;AACA,UAAM,OAAiB,OAAO,WAAW,aACnC,MAAM,OAAO,IACb,MAAM;AACZ,WAAO;AAAA,MACH;AAAA,MACA,OAAO;AAAA,IACX;AAAA,EACJ,SACO,YAAqB;AACxB,WAAO;AAAA,MACH,MAAM;AAAA,MACN,OAAO;AAAA,IACX;AAAA,EACJ;AACJ;AAqBA,eAAsB,IAA4C,UAAsC,QAA2G;AAC/M,QAAM,gBAAgB,OAAO,YAA6D;AACtF,WAAO,OAAO,OAAO;AAAA,EACzB;AACA,QAAM,MAAyC,SAAS,IAAI,aAAa;AACzE,SAAO,MAAM,QAAQ,IAAI,GAAG;AAChC;AAKO,IAAe,eAAf,MAA6E;AAAA,EACzE,KAAmD,cAAsD,aAA8E;AAC1L,UAAM,IAAI,wBAAwB,cAAc;AAAA,EACpD;AACJ;AAWO,IAAM,6BAAN,cAAyC,UAAU;AAAA,EAC/C,cAAc;AACjB,UAAM;AAAA,EACV;AACJ;AAMO,IAAM,WAAN,MAAM,kBAA8B,aAA8D;AAAA,EAC9F,YAAY,UAA6C;AAC5D,UAAM;AACN,QAAI,OAAO,aAAa,YAAY;AAChC,WAAK,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ps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// Source/FileSystem/index.ts
|
|
31
31
|
var FileSystem_exports = {};
|
|
32
32
|
__export(FileSystem_exports, {
|
|
33
|
+
DeleteWithProgress: () => DeleteWithProgress,
|
|
33
34
|
GetSafeNewPath: () => GetSafeNewPath,
|
|
34
35
|
IsSupportedFileExtension: () => IsSupportedFileExtension,
|
|
35
36
|
IsValidFileName: () => IsValidFileName,
|
|
@@ -42,9 +43,11 @@ var import_path = require("path");
|
|
|
42
43
|
var import_fs = require("fs");
|
|
43
44
|
var import_fs2 = require("fs");
|
|
44
45
|
var import_os = __toESM(require("os"), 1);
|
|
45
|
-
|
|
46
|
+
var FileSystem = __toESM(require("node:fs/promises"), 1);
|
|
47
|
+
var Path = __toESM(require("node:path"), 1);
|
|
48
|
+
async function PathExists(Path2) {
|
|
46
49
|
try {
|
|
47
|
-
await import_fs.promises.access(
|
|
50
|
+
await import_fs.promises.access(Path2, import_fs2.constants.F_OK);
|
|
48
51
|
return true;
|
|
49
52
|
} catch {
|
|
50
53
|
return false;
|
|
@@ -104,8 +107,95 @@ async function IsValidFileName(DirectoryPath, FileName, PersistNewFile = false,
|
|
|
104
107
|
return false;
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
|
-
async function WriteTextFile(
|
|
108
|
-
await import_fs.promises.writeFile(
|
|
110
|
+
async function WriteTextFile(Path2, Contents) {
|
|
111
|
+
await import_fs.promises.writeFile(Path2, Contents, { encoding: "utf-8" });
|
|
112
|
+
}
|
|
113
|
+
function IsMissingFileError(ErrorValue) {
|
|
114
|
+
return typeof ErrorValue === "object" && ErrorValue !== null && "code" in ErrorValue && ErrorValue.code === "ENOENT";
|
|
115
|
+
}
|
|
116
|
+
function CloneProgress(Progress) {
|
|
117
|
+
return { ...Progress };
|
|
118
|
+
}
|
|
119
|
+
async function BuildDeletionPlan(RootPath, Progress, Options) {
|
|
120
|
+
const Entries = [];
|
|
121
|
+
async function Visit(CurrentPath) {
|
|
122
|
+
Options.Signal?.throwIfAborted();
|
|
123
|
+
Progress.Phase = "Scanning";
|
|
124
|
+
Progress.CurrentPath = CurrentPath;
|
|
125
|
+
Options.OnProgress?.(CloneProgress(Progress));
|
|
126
|
+
let Stats;
|
|
127
|
+
try {
|
|
128
|
+
Stats = await FileSystem.lstat(CurrentPath);
|
|
129
|
+
} catch (ErrorValue) {
|
|
130
|
+
if (IsMissingFileError(ErrorValue)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
throw ErrorValue;
|
|
134
|
+
}
|
|
135
|
+
if (Stats.isDirectory()) {
|
|
136
|
+
const Children = await FileSystem.readdir(CurrentPath, {
|
|
137
|
+
withFileTypes: true
|
|
138
|
+
});
|
|
139
|
+
for (const Child of Children) {
|
|
140
|
+
await Visit(Path.join(CurrentPath, Child.name));
|
|
141
|
+
}
|
|
142
|
+
Entries.push({
|
|
143
|
+
EntryPath: CurrentPath,
|
|
144
|
+
Kind: "Directory",
|
|
145
|
+
Size: 0
|
|
146
|
+
});
|
|
147
|
+
} else {
|
|
148
|
+
const Size = Stats.isFile() ? Stats.size : 0;
|
|
149
|
+
Entries.push({
|
|
150
|
+
EntryPath: CurrentPath,
|
|
151
|
+
Kind: Stats.isFile() ? "File" : "Other",
|
|
152
|
+
Size
|
|
153
|
+
});
|
|
154
|
+
Progress.TotalBytes += Size;
|
|
155
|
+
}
|
|
156
|
+
Progress.DiscoveredEntries = Entries.length;
|
|
157
|
+
Options.OnProgress?.(CloneProgress(Progress));
|
|
158
|
+
}
|
|
159
|
+
await Visit(RootPath);
|
|
160
|
+
return Entries;
|
|
161
|
+
}
|
|
162
|
+
async function DeleteWithProgress(RootPath, Options = {}) {
|
|
163
|
+
const Progress = {
|
|
164
|
+
Phase: "Scanning",
|
|
165
|
+
CurrentPath: null,
|
|
166
|
+
DiscoveredEntries: 0,
|
|
167
|
+
TotalEntries: 0,
|
|
168
|
+
DeletedEntries: 0,
|
|
169
|
+
TotalBytes: 0,
|
|
170
|
+
DeletedBytes: 0
|
|
171
|
+
};
|
|
172
|
+
const Entries = await BuildDeletionPlan(RootPath, Progress, Options);
|
|
173
|
+
Progress.Phase = "Deleting";
|
|
174
|
+
Progress.TotalEntries = Entries.length;
|
|
175
|
+
Progress.CurrentPath = null;
|
|
176
|
+
Options.OnProgress?.(CloneProgress(Progress));
|
|
177
|
+
for (const Entry of Entries) {
|
|
178
|
+
Options.Signal?.throwIfAborted();
|
|
179
|
+
Progress.CurrentPath = Entry.EntryPath;
|
|
180
|
+
Options.OnProgress?.(CloneProgress(Progress));
|
|
181
|
+
try {
|
|
182
|
+
if (Entry.Kind === "Directory") {
|
|
183
|
+
await FileSystem.rmdir(Entry.EntryPath);
|
|
184
|
+
} else {
|
|
185
|
+
await FileSystem.unlink(Entry.EntryPath);
|
|
186
|
+
}
|
|
187
|
+
} catch (ErrorValue) {
|
|
188
|
+
if (!IsMissingFileError(ErrorValue)) {
|
|
189
|
+
throw ErrorValue;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
Progress.DeletedEntries += 1;
|
|
193
|
+
Progress.DeletedBytes += Entry.Size;
|
|
194
|
+
Options.OnProgress?.(CloneProgress(Progress));
|
|
195
|
+
}
|
|
196
|
+
Progress.Phase = "Done";
|
|
197
|
+
Progress.CurrentPath = null;
|
|
198
|
+
Options.OnProgress?.(CloneProgress(Progress));
|
|
109
199
|
}
|
|
110
200
|
/**
|
|
111
201
|
* @file FileSystem.ts
|