Skip to content

Commit 7cf59f1

Browse files
committed
remove catchError() and assert() from lib.ts as they are unused (also removed the unsued imports from hsm.ts)
1 parent 51d5757 commit 7cf59f1

2 files changed

Lines changed: 2 additions & 16 deletions

File tree

src/bin/hsm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import chalk from "chalk"
55
import fs from "fs"
66

77
import { generateTypings, Info, processScript, pull, push, supportedExtensions, syncMacros, test, watch } from ".."
8-
import { assert, catchError, DynamicMap, hackmudLength, writeFilePersist } from "../lib"
8+
import { DynamicMap, hackmudLength, writeFilePersist } from "../lib"
99

1010
const { readFile: readFile, rmdir: removeDirectory, writeFile: writeFile, mkdir: makeDirectory } = fs.promises
1111

src/lib.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function writeFilePersist(
88
data: any,
99
options?: { encoding?: string | null | undefined, mode?: string | number | undefined, flag?: string | number | undefined } | string | null
1010
) {
11-
return writeFile(path, data, options).catch(async (error: NodeJS.ErrnoException) => {
11+
return writeFile(path, data, options).catch(async (error: NodeJS.ErrnoException) => {
1212
if (error.code != "ENOENT")
1313
throw error
1414

@@ -48,20 +48,6 @@ export function stringSplice(original: string, replacement: string, start: numbe
4848
return original.slice(0, start) + replacement + original.slice(end)
4949
}
5050

51-
export async function catchError<T>(promise: Promise<T>) {
52-
try {
53-
return await promise
54-
} catch (error) {
55-
assert(error instanceof Error, "error was not an instanceof Error")
56-
return error
57-
}
58-
}
59-
60-
export function assert(value: any, message = "assertion failed"): asserts value {
61-
if (!value)
62-
throw new Error(message)
63-
}
64-
6551
export class DynamicMap<K, V> extends Map<K, V> {
6652
constructor(private fallbackHandler: (key: K) => V) { super() }
6753

0 commit comments

Comments
 (0)