feat: Add Matcher/ Parser for spec in getConfig

This commit is contained in:
BluJ
2022-12-09 16:13:04 -07:00
parent 386d654f6d
commit 5e60e754ed
5 changed files with 1091 additions and 5 deletions

11
util.ts
View File

@@ -1,5 +1,7 @@
import * as T from "./types.ts";
export { guardAll, typeFromProps } from "./utils/propertiesMatcher.ts";
export function unwrapResultType<T>(res: T.ResultType<T>): T {
if ("error-code" in res) {
throw new Error(res["error-code"][1]);
@@ -11,10 +13,11 @@ export function unwrapResultType<T>(res: T.ResultType<T>): T {
}
/** Used to check if the file exists before hand */
export const exists = (
effects: T.Effects,
props: { path: string; volumeId: string },
) => effects.metadata(props).then((_) => true, (_) => false);
export const exists = (effects: T.Effects, props: { path: string; volumeId: string }) =>
effects.metadata(props).then(
(_) => true,
(_) => false
);
export const errorCode = (code: number, error: string) => ({
"error-code": [code, error] as const,