allow mounting files directly (#2931)

* allow mounting files directly

* fixes from testing

* more fixes
This commit is contained in:
Aiden McClelland
2025-05-07 12:47:45 -06:00
committed by GitHub
parent 9bc945f76f
commit a3252f9671
12 changed files with 208 additions and 114 deletions

View File

@@ -329,6 +329,36 @@ export class FileHelper<A> {
)
}
/**
* Create a File Helper for a text file
*/
static string(path: string): FileHelper<string>
static string<A extends string>(
path: string,
shape: Validator<string, A>,
): FileHelper<A>
static string<A extends Transformed, Transformed = string>(
path: string,
shape: Validator<Transformed, A>,
transformers: Transformers<string, Transformed>,
): FileHelper<A>
static string<A extends Transformed, Transformed = string>(
path: string,
shape?: Validator<Transformed, A>,
transformers?: Transformers<string, Transformed>,
) {
return FileHelper.rawTransformed<A, string, Transformed>(
path,
(inData) => inData,
(inString) => inString,
(data) =>
(shape || (matches.string as Validator<Transformed, A>)).unsafeCast(
data,
),
transformers,
)
}
/**
* Create a File Helper for a .json file.
*/