From 5b74400a1088132dc6400ffdfa6c2a6cc03b6ca1 Mon Sep 17 00:00:00 2001 From: rhpidfyre Date: Sat, 8 Mar 2025 15:59:23 -0500 Subject: [PATCH] wrap module, may branch this out to the entire codebase --- src/rt/rfwfs/wrap.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/rt/rfwfs/wrap.ts diff --git a/src/rt/rfwfs/wrap.ts b/src/rt/rfwfs/wrap.ts new file mode 100644 index 0000000..2bdaa99 --- /dev/null +++ b/src/rt/rfwfs/wrap.ts @@ -0,0 +1,38 @@ +import { Result } from "./enum" +import { ConstEnum, Entry } from "./types/entry" + +type WrapResultEntry = WrapResult +type WrapBSearch = WrapResult +type WrapResultNone = WrapResult + +interface WrapResult { + readonly result: T, + readonly some: U +} + +function wrap(result: T, some: U): WrapResult { + return { result: result, some: some } +} + +function wrap_bsearch(index: number, result: T): WrapBSearch { + return wrap(result, index) +} + +function wrap_entry(status: U, result?: T): WrapResultEntry { + return wrap(result, status) +} + +function wrap_none(status: T): WrapResultNone { + return wrap(Result.None, status) +} + +export default wrap +export { + wrap_bsearch, + wrap_entry, + wrap_none, + type WrapResultEntry, + type WrapBSearch, + type WrapResultNone, + type WrapResult, +} \ No newline at end of file