From 344f3d520950f213884c12027b7109d7caf8d498 Mon Sep 17 00:00:00 2001 From: Braden Wong <13159333+braden-w@users.noreply.github.com> Date: Tue, 24 Dec 2024 13:42:59 -0800 Subject: [PATCH] refactor: update generics in trySync and tryAsync functions; remove services.ts --- .changeset/fluffy-turkeys-rest.md | 5 +++++ src/index.ts | 1 - src/services.ts | 26 -------------------------- 3 files changed, 5 insertions(+), 27 deletions(-) create mode 100644 .changeset/fluffy-turkeys-rest.md delete mode 100644 src/services.ts diff --git a/.changeset/fluffy-turkeys-rest.md b/.changeset/fluffy-turkeys-rest.md new file mode 100644 index 0000000..c80d055 --- /dev/null +++ b/.changeset/fluffy-turkeys-rest.md @@ -0,0 +1,5 @@ +--- +"@epicenterhq/result": minor +--- + +Update generics in trySync and tryAsync functions; remove services.ts diff --git a/src/index.ts b/src/index.ts index 326f3b8..b0c7d84 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,4 +8,3 @@ export { tryAsync, trySync, } from "./result"; -export { ServiceFn, createServiceErrorFns } from "./services"; diff --git a/src/services.ts b/src/services.ts deleted file mode 100644 index 90b3bb5..0000000 --- a/src/services.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Result } from "./result"; -import { Err, tryAsync, trySync } from "./result"; - -export type ServiceFn = ( - input: I, -) => Promise>; - -type ServiceErrorFns = { - Err: (props: ServiceErrorProperties) => Err; - trySync: (opts: { - try: () => T extends Promise ? never : T; - mapErr: (error: Err) => Err; - }) => Result; - tryAsync: (opts: { - try: () => Promise; - mapErr: (error: Err) => Err; - }) => Promise>; -}; - -export const createServiceErrorFns = < - ServiceErrorProperties extends Record, ->(): ServiceErrorFns => ({ - Err, - trySync, - tryAsync, -});