resultar 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,196 @@
1
+ declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
2
+ static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
3
+ static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
4
+ private readonly innerPromise;
5
+ constructor(res: Promise<Result<T, E>>);
6
+ then<A, B>(// eslint-disable-line unicorn/no-thenable
7
+ successCallback?: (res: Result<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
8
+ mapErr<U>(f: (t: E) => U | Promise<U>): ResultAsync<T, U>;
9
+ map<X>(f: (t: T) => X | Promise<X>): ResultAsync<X, E>;
10
+ andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): ResultAsync<R, R | E>;
11
+ andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<R, R | E>;
12
+ andThen<X, Y>(f: (t: T) => ResultAsync<X, Y>): ResultAsync<X, E | Y>;
13
+ match<X>(ok: (t: T) => X, _err: (e: E) => X): Promise<X>;
14
+ /**
15
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
16
+ */
17
+ safeUnwrap(): AsyncGenerator<Result<never, E>, T>;
18
+ }
19
+ declare function fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
20
+ declare function fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
21
+ declare function okAsync<T, E = never>(value: T): ResultAsync<T, E>;
22
+ declare function errAsync<T = never, E = unknown>(error: E): ResultAsync<T, E>;
23
+ declare function safeTryAsync<T, E>(body: () => AsyncGenerator<Result<never, E>, Result<T, E>>): ResultAsync<T, E>;
24
+
25
+ declare class Result<T, E> {
26
+ private readonly state;
27
+ /**
28
+ * Wraps a function with a try catch, creating a new function with the same
29
+ * arguments but returning `Ok` if successful, `Err` if the function throws
30
+ *
31
+ * @param fn function to wrap with ok on success or err on failure
32
+ * @param errorFn when an error is thrown, this will wrap the error result if provided
33
+ */
34
+ static fromThrowable<Fn extends (...args: readonly any[]) => unknown, E>(fn: Fn, errorFn?: (e: any) => E): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E>;
35
+ static ok<T, E = never>(value: T): Result<T, E>;
36
+ static err<T = never, E = unknown>(error: E): Result<T, E>;
37
+ readonly value: T;
38
+ readonly error: E;
39
+ private constructor();
40
+ /**
41
+ * Used to check if a `Result` is an `OK`
42
+ *
43
+ * @returns `true` if the result is an `OK` variant of Result
44
+ */
45
+ isOk(): boolean;
46
+ /**
47
+ * Used to check if a `Result` is an `Err`
48
+ *
49
+ * @returns `true` if the result is an `Err` variant of Result
50
+ */
51
+ isErr(): boolean;
52
+ /**
53
+ * Maps a `Result<T, E>` to `Result<U, E>`
54
+ * by applying a function to a contained `Ok` value, leaving an `Err` value
55
+ * untouched.
56
+ *
57
+ * @param f The function to apply an `OK` value
58
+ * @returns the result of applying `f` or an `Err` untouched
59
+ */
60
+ map<X, Y>(f: (t: T) => Exclude<X, Promise<any>>): Result<X, E | Y>;
61
+ /**
62
+ * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
63
+ * contained `Err` value, leaving an `Ok` value untouched.
64
+ *
65
+ * This function can be used to pass through a successful result while
66
+ * handling an error.
67
+ *
68
+ * @param f a function to apply to the error `Err` value
69
+ */
70
+ mapErr<X>(fn: (t: Exclude<E, Promise<any>>) => Exclude<X, Promise<any>>): Result<T, X>;
71
+ /**
72
+ * Similar to `map` Except you must return a new `Result`.
73
+ *
74
+ * This is useful for when you need to do a subsequent computation using the
75
+ * inner `T` value, but that computation might fail.
76
+ * Additionally, `andThen` is really useful as a tool to flatten a
77
+ * `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
78
+ *
79
+ * @param f The function to apply to the current value
80
+ */
81
+ andThen<X, Y>(f: (t: T) => Exclude<Result<X, Y>, Promise<any>>): Result<X, E | Y>;
82
+ /**
83
+ * Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
84
+ *
85
+ * This is useful for error recovery.
86
+ *
87
+ *
88
+ * @param f A function to apply to an `Err` value, leaving `Ok` values
89
+ * untouched.
90
+ */
91
+ orElse<Y>(f: (t: E) => Result<T, Y>): Result<T, Y>;
92
+ /**
93
+ * Similar to `map` Except you must return a new `Result`.
94
+ *
95
+ * This is useful for when you need to do a subsequent async computation using
96
+ * the inner `T` value, but that computation might fail. Must return a ResultAsync
97
+ *
98
+ * @param f The function that returns a `ResultAsync` to apply to the current
99
+ * value
100
+ */
101
+ asyncAndThen<X, Y>(f: (t: T) => ResultAsync<X, Y>): ResultAsync<X, E | Y>;
102
+ /**
103
+ * Maps a `Result<T, E>` to `ResultAsync<U, E>`
104
+ * by applying an async function to a contained `Ok` value, leaving an `Err`
105
+ * value untouched.
106
+ *
107
+ * @param f An async function to apply an `OK` value
108
+ */
109
+ asyncMap<X>(f: (t: T) => Promise<X>): ResultAsync<X, E>;
110
+ /**
111
+ * Unwrap the `Ok` value, or return the default if there is an `Err`
112
+ *
113
+ * @param v the default value to return if there is an `Err`
114
+ */
115
+ unwrapOr<A>(defaultValue: A): T | A;
116
+ /**
117
+ *
118
+ * Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
119
+ * execute the function that matches the `Result` variant.
120
+ *
121
+ * Match callbacks do not necessitate to return a `Result`, however you can
122
+ * return a `Result` if you want to.
123
+ *
124
+ * `match` is like chaining `map` and `mapErr`, with the distinction that
125
+ * with `match` both functions must have the same return type.
126
+ *
127
+ * @param ok
128
+ * @param err
129
+ */
130
+ match<X>(fnOk: (t: T) => X, fnErr: (e: E) => X): X;
131
+ /**
132
+ * **This method is unsafe, and should only be used in a test environments**
133
+ *
134
+ * Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
135
+ *
136
+ * @param config
137
+ */
138
+ _unsafeUnwrap(config?: ErrorConfig): T;
139
+ /**
140
+ * **This method is unsafe, and should only be used in a test environments**
141
+ *
142
+ * takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
143
+ * otherwise it throws a custom object.
144
+ *
145
+ * @param config
146
+ */
147
+ _unsafeUnwrapErr(config?: ErrorConfig): E;
148
+ safeUnwrap(): Generator<Result<never, E>, T>;
149
+ }
150
+ declare const ok: <T, E = never>(value: T) => Result<T, E>;
151
+ declare const err: <T = never, E = unknown>(error: E) => Result<T, E>;
152
+ declare const fromThrowable: <Fn extends (...args: readonly any[]) => unknown, E>(fn: Fn, errorFn?: ((e: any) => E) | undefined) => (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E>;
153
+ /**
154
+ * Evaluates the given generator to a Result returned or an Err yielded from it,
155
+ * whichever comes first.
156
+ *
157
+ * This function, in combination with `Result.safeUnwrap()`, is intended to emulate
158
+ * Rust's ? operator.
159
+ * See `/tests/safeTry.test.ts` for examples.
160
+ *
161
+ * @param body - What is evaluated. In body, `yield* result.safeUnwrap()` works as
162
+ * Rust's `result?` expression.
163
+ * @returns The first occurence of either an yielded Err or a returned Result.
164
+ */
165
+ declare function safeTry<T, E>(body: () => Generator<Result<never, E>, Result<T, E>>): Result<T, E>;
166
+ /**
167
+ * Evaluates the given generator to a Result returned or an Err yielded from it,
168
+ * whichever comes first.
169
+ *
170
+ * This function, in combination with `Result.safeUnwrap()`, is intended to emulate
171
+ * Rust's ? operator.
172
+ * See `/tests/safeTry.test.ts` for examples.
173
+ *
174
+ * @param body - What is evaluated. In body, `yield* result.safeUnwrap()` and
175
+ * `yield* resultAsync.safeUnwrap()` work as Rust's `result?` expression.
176
+ * @returns The first occurence of either an yielded Err or a returned Result.
177
+ */
178
+ declare function safeTry<T, E>(body: () => AsyncGenerator<Result<never, E>, Result<T, E>>): Promise<Result<T, E>>;
179
+
180
+ interface ErrorConfig {
181
+ withStackTrace: boolean;
182
+ }
183
+ interface ResultarError<T, E> {
184
+ data: {
185
+ type: string;
186
+ value: T | undefined;
187
+ } | {
188
+ type: string;
189
+ value: E | undefined;
190
+ };
191
+ message: string;
192
+ stack: string | undefined;
193
+ }
194
+ declare const createResultarError: <T, E>(message: string, result: Result<T, E>, config?: ErrorConfig) => ResultarError<T, E>;
195
+
196
+ export { type ErrorConfig as E, ResultAsync as R, fromPromise as a, Result as b, ok as c, err as d, errAsync as e, fromSafePromise as f, fromThrowable as g, safeTry as h, createResultarError as i, okAsync as o, safeTryAsync as s };
package/dist/index.cjs ADDED
@@ -0,0 +1,337 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Result: () => Result,
24
+ ResultAsync: () => ResultAsync,
25
+ err: () => err,
26
+ errAsync: () => errAsync,
27
+ fromPromise: () => fromPromise,
28
+ fromSafePromise: () => fromSafePromise,
29
+ fromThrowable: () => fromThrowable,
30
+ ok: () => ok,
31
+ okAsync: () => okAsync,
32
+ safeTry: () => safeTry,
33
+ safeTryAsync: () => safeTryAsync
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/error.ts
38
+ var defaultErrorConfig = {
39
+ withStackTrace: false
40
+ };
41
+ var createResultarError = (message, result, config = defaultErrorConfig) => {
42
+ const data = result.isOk() ? { type: "Ok", value: result.value } : { type: "Err", value: result.error };
43
+ const maybeStack = config.withStackTrace ? new Error().stack : void 0;
44
+ return {
45
+ data,
46
+ message,
47
+ stack: maybeStack
48
+ };
49
+ };
50
+
51
+ // src/result-async.ts
52
+ var ResultAsync = class _ResultAsync {
53
+ static fromSafePromise(promise) {
54
+ const newPromise = promise.then((value) => Result.ok(value));
55
+ return new _ResultAsync(newPromise);
56
+ }
57
+ static fromPromise(promise, errorFn) {
58
+ const newPromise = promise.then((value) => Result.ok(value)).catch((error) => Result.err(errorFn(error)));
59
+ return new _ResultAsync(newPromise);
60
+ }
61
+ innerPromise;
62
+ constructor(res) {
63
+ this.innerPromise = res;
64
+ }
65
+ then(successCallback, failureCallback) {
66
+ return this.innerPromise.then(successCallback, failureCallback);
67
+ }
68
+ mapErr(f) {
69
+ return new _ResultAsync(this.innerPromise.then(async (res) => {
70
+ if (res.isOk()) {
71
+ return okAsync(res.value);
72
+ }
73
+ return errAsync(await f(res.error));
74
+ }));
75
+ }
76
+ map(f) {
77
+ const x = new _ResultAsync(
78
+ this.innerPromise.then(async (res) => {
79
+ if (res.isErr()) {
80
+ return errAsync(res.error);
81
+ }
82
+ return okAsync(await f(res.value));
83
+ })
84
+ );
85
+ return x;
86
+ }
87
+ andThen(f) {
88
+ return new _ResultAsync(
89
+ this.innerPromise.then(async (res) => {
90
+ if (res.isErr()) {
91
+ return errAsync(res.error);
92
+ }
93
+ const newValue = f(res.value);
94
+ return newValue instanceof _ResultAsync ? newValue.innerPromise : newValue;
95
+ })
96
+ );
97
+ }
98
+ async match(ok2, _err) {
99
+ return this.innerPromise.then((res) => res.match(ok2, _err));
100
+ }
101
+ /**
102
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
103
+ */
104
+ async *safeUnwrap() {
105
+ return yield* await this.innerPromise.then((res) => res.safeUnwrap());
106
+ }
107
+ };
108
+ function fromSafePromise(promise) {
109
+ return ResultAsync.fromSafePromise(promise);
110
+ }
111
+ function fromPromise(promise, errorFn) {
112
+ return ResultAsync.fromPromise(promise, errorFn);
113
+ }
114
+ function okAsync(value) {
115
+ return new ResultAsync(Promise.resolve(Result.ok(value)));
116
+ }
117
+ function errAsync(error) {
118
+ return new ResultAsync(Promise.resolve(Result.err(error)));
119
+ }
120
+ function safeTryAsync(body) {
121
+ return new ResultAsync(
122
+ (async () => {
123
+ const n = await body().next();
124
+ if (n.value.isOk()) {
125
+ return okAsync(n.value.value);
126
+ }
127
+ return errAsync(n.value.error);
128
+ })()
129
+ );
130
+ }
131
+
132
+ // src/result.ts
133
+ var Result = class _Result {
134
+ constructor(state) {
135
+ this.state = state;
136
+ if (state.ok) {
137
+ this.value = state.value;
138
+ this.error = void 0;
139
+ } else {
140
+ this.error = state.error;
141
+ this.value = void 0;
142
+ }
143
+ }
144
+ /**
145
+ * Wraps a function with a try catch, creating a new function with the same
146
+ * arguments but returning `Ok` if successful, `Err` if the function throws
147
+ *
148
+ * @param fn function to wrap with ok on success or err on failure
149
+ * @param errorFn when an error is thrown, this will wrap the error result if provided
150
+ */
151
+ static fromThrowable(fn, errorFn) {
152
+ return (...args) => {
153
+ try {
154
+ const result = fn(...args);
155
+ return ok(result);
156
+ } catch (error) {
157
+ if (errorFn) {
158
+ return err(errorFn(error));
159
+ }
160
+ return err(error);
161
+ }
162
+ };
163
+ }
164
+ static ok(value) {
165
+ return new _Result({ ok: true, value });
166
+ }
167
+ static err(error) {
168
+ return new _Result({ ok: false, error });
169
+ }
170
+ value;
171
+ error;
172
+ /**
173
+ * Used to check if a `Result` is an `OK`
174
+ *
175
+ * @returns `true` if the result is an `OK` variant of Result
176
+ */
177
+ isOk() {
178
+ return this.state.ok;
179
+ }
180
+ /**
181
+ * Used to check if a `Result` is an `Err`
182
+ *
183
+ * @returns `true` if the result is an `Err` variant of Result
184
+ */
185
+ isErr() {
186
+ return !this.state.ok;
187
+ }
188
+ map(f) {
189
+ if (this.state.ok) {
190
+ const value = f(this.value);
191
+ return ok(value);
192
+ }
193
+ return err(this.error);
194
+ }
195
+ /**
196
+ * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
197
+ * contained `Err` value, leaving an `Ok` value untouched.
198
+ *
199
+ * This function can be used to pass through a successful result while
200
+ * handling an error.
201
+ *
202
+ * @param f a function to apply to the error `Err` value
203
+ */
204
+ mapErr(fn) {
205
+ if (this.state.ok) {
206
+ return ok(this.value);
207
+ }
208
+ return err(fn(this.error));
209
+ }
210
+ andThen(f) {
211
+ if (this.state.ok) {
212
+ return f(this.value);
213
+ }
214
+ return err(this.error);
215
+ }
216
+ orElse(f) {
217
+ if (this.state.ok) {
218
+ return ok(this.value);
219
+ }
220
+ return f(this.error);
221
+ }
222
+ asyncAndThen(f) {
223
+ if (this.state.ok) {
224
+ return f(this.value);
225
+ }
226
+ return errAsync(this.error);
227
+ }
228
+ /**
229
+ * Maps a `Result<T, E>` to `ResultAsync<U, E>`
230
+ * by applying an async function to a contained `Ok` value, leaving an `Err`
231
+ * value untouched.
232
+ *
233
+ * @param f An async function to apply an `OK` value
234
+ */
235
+ asyncMap(f) {
236
+ if (this.state.ok) {
237
+ return ResultAsync.fromSafePromise(f(this.value));
238
+ }
239
+ return errAsync(this.error);
240
+ }
241
+ /**
242
+ * Unwrap the `Ok` value, or return the default if there is an `Err`
243
+ *
244
+ * @param v the default value to return if there is an `Err`
245
+ */
246
+ unwrapOr(defaultValue) {
247
+ if (this.state.ok) {
248
+ return this.value;
249
+ }
250
+ return defaultValue;
251
+ }
252
+ /**
253
+ *
254
+ * Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
255
+ * execute the function that matches the `Result` variant.
256
+ *
257
+ * Match callbacks do not necessitate to return a `Result`, however you can
258
+ * return a `Result` if you want to.
259
+ *
260
+ * `match` is like chaining `map` and `mapErr`, with the distinction that
261
+ * with `match` both functions must have the same return type.
262
+ *
263
+ * @param ok
264
+ * @param err
265
+ */
266
+ match(fnOk, fnErr) {
267
+ if (this.state.ok) {
268
+ return fnOk(this.value);
269
+ }
270
+ return fnErr(this.error);
271
+ }
272
+ /**
273
+ * **This method is unsafe, and should only be used in a test environments**
274
+ *
275
+ * Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
276
+ *
277
+ * @param config
278
+ */
279
+ _unsafeUnwrap(config) {
280
+ if (this.state.ok) {
281
+ return this.value;
282
+ }
283
+ throw createResultarError("Called `_unsafeUnwrap` on an Err", this, config);
284
+ }
285
+ /**
286
+ * **This method is unsafe, and should only be used in a test environments**
287
+ *
288
+ * takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
289
+ * otherwise it throws a custom object.
290
+ *
291
+ * @param config
292
+ */
293
+ _unsafeUnwrapErr(config) {
294
+ if (this.state.ok) {
295
+ throw createResultarError("Called `_unsafeUnwrapErr` on an Ok", this, config);
296
+ }
297
+ return this.error;
298
+ }
299
+ safeUnwrap() {
300
+ if (this.state.ok) {
301
+ const { value } = this;
302
+ return function* () {
303
+ return value;
304
+ }();
305
+ }
306
+ const { error } = this;
307
+ return function* () {
308
+ yield err(error);
309
+ throw new Error("Do not use this generator out of `safeTry`");
310
+ }();
311
+ }
312
+ };
313
+ var ok = (value) => Result.ok(value);
314
+ var err = (error) => Result.err(error);
315
+ var fromThrowable = (fn, errorFn) => Result.fromThrowable(fn, errorFn);
316
+ function safeTry(body) {
317
+ const n = body().next();
318
+ if (n instanceof Promise) {
319
+ return n.then((r) => r.value);
320
+ }
321
+ return n.value;
322
+ }
323
+ // Annotate the CommonJS export names for ESM import in node:
324
+ 0 && (module.exports = {
325
+ Result,
326
+ ResultAsync,
327
+ err,
328
+ errAsync,
329
+ fromPromise,
330
+ fromSafePromise,
331
+ fromThrowable,
332
+ ok,
333
+ okAsync,
334
+ safeTry,
335
+ safeTryAsync
336
+ });
337
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/error.ts","../src/result-async.ts","../src/result.ts"],"sourcesContent":["export * from './result.js'\nexport * from './result-async.js'\n","import { Result } from './result.js'\n\nexport interface ErrorConfig {\n withStackTrace: boolean\n}\n\nconst defaultErrorConfig: ErrorConfig = {\n withStackTrace: false,\n}\n\ninterface ResultarError<T, E> {\n data:\n | {\n type: string\n value: T | undefined\n }\n | {\n type: string\n value: E | undefined\n }\n message: string\n stack: string | undefined\n}\n\nexport const createResultarError = <T, E>(\n message: string,\n result: Result<T, E>,\n config: ErrorConfig = defaultErrorConfig,\n): ResultarError<T, E> => {\n const data = result.isOk()\n ? { type: 'Ok', value: result.value }\n : { type: 'Err', value: result.error }\n\n const maybeStack = config.withStackTrace ? new Error().stack : undefined // eslint-disable-line unicorn/error-message\n\n return {\n data,\n message,\n stack: maybeStack,\n }\n}\n","import {\n Result,\n} from './result.js'\n\nexport class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {\n static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>\n static fromSafePromise<T, E = never>(promise: Promise<T>): ResultAsync<T, E> {\n const newPromise = promise\n .then((value: T) => Result.ok(value))\n\n return new ResultAsync<T, E>(newPromise)\n }\n\n static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>\n static fromPromise<T, E>(promise: Promise<T>, errorFn: (e: unknown) => E): ResultAsync<T, E> {\n const newPromise = promise\n .then((value: T) => Result.ok(value))\n .catch(error => Result.err(errorFn(error)))\n\n return new ResultAsync<T, E>(newPromise)\n }\n\n private readonly innerPromise: Promise<Result<T, E>>\n\n constructor(res: Promise<Result<T, E>>) {\n this.innerPromise = res\n }\n\n then<A, B>( // eslint-disable-line unicorn/no-thenable\n successCallback?: (res: Result<T, E>) => A | PromiseLike<A>,\n failureCallback?: (reason: unknown) => B | PromiseLike<B>,\n ): PromiseLike<A | B> {\n return this.innerPromise.then(successCallback, failureCallback)\n }\n\n mapErr<U>(f: (t: E) => U | Promise<U>): ResultAsync<T, U> {\n return new ResultAsync<T, U>(this.innerPromise.then(async res => {\n if (res.isOk()) {\n return okAsync(res.value)\n }\n\n return errAsync(await f(res.error))\n }))\n }\n\n map<X>(f: (t: T) => X | Promise<X>): ResultAsync<X, E> {\n const x = new ResultAsync(\n this.innerPromise.then(async (res: Result<T, E>) => {\n if (res.isErr()) {\n return errAsync(res.error)\n }\n\n return okAsync(await f(res.value))\n }),\n )\n\n return x\n }\n\n andThen<R extends Result<unknown, unknown>>(\n f: (t: T) => R,\n ): ResultAsync<R, R | E>\n andThen<R extends ResultAsync<unknown, unknown>>(\n f: (t: T) => R,\n ): ResultAsync<R, R | E>\n andThen<X, Y>(f: (t: T) => ResultAsync<X, Y>): ResultAsync<X, E | Y>\n andThen<X, Y>(f: (t: T) => ResultAsync<X, E>): ResultAsync<X, E | Y> {\n return new ResultAsync<X, E | Y>(\n this.innerPromise.then(async res => {\n if (res.isErr()) {\n return errAsync(res.error)\n }\n\n const newValue = f(res.value)\n return newValue instanceof ResultAsync ? newValue.innerPromise : newValue\n }),\n )\n }\n\n async match<X>(ok: (t: T) => X, _err: (e: E) => X): Promise<X> {\n return this.innerPromise.then(res => res.match(ok, _err))\n }\n\n /**\n * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.\n */\n async * safeUnwrap(): AsyncGenerator<Result<never, E>, T> {\n return yield * await this.innerPromise.then(res => res.safeUnwrap())\n }\n}\n\nexport function fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>\nexport function fromSafePromise<T, E = never>(promise:\n| PromiseLike<T>\n| Promise<T>): ResultAsync<T, E> {\n return ResultAsync.fromSafePromise(promise)\n}\n\nexport function fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>\nexport function fromPromise<T, E>(promise:\n| PromiseLike<T>\n| Promise<T>, errorFn: (e: unknown) => E): ResultAsync<T, E> {\n return ResultAsync.fromPromise(promise, errorFn)\n}\n\nexport function okAsync<T, E = never>(value: T): ResultAsync<T, E> {\n return new ResultAsync<T, E>(Promise.resolve(Result.ok(value)))\n}\n\nexport function errAsync<T = never, E = unknown>(error: E): ResultAsync<T, E> {\n return new ResultAsync<T, E>(Promise.resolve(Result.err(error)))\n}\n\nexport function safeTryAsync<T, E>(\n body: () => AsyncGenerator<Result<never, E>, Result<T, E>>,\n): ResultAsync<T, E> {\n return new ResultAsync<T, E>(\n (async () => {\n const n = await body().next()\n if (n.value.isOk()) {\n return okAsync(n.value.value)\n }\n\n return errAsync(n.value.error)\n })(),\n )\n}\n\n","import { ErrorConfig, createResultarError } from './error.js'\nimport { ResultAsync, errAsync } from './result-async.js'\n\ninterface Ok<T> {\n ok: true\n value: T\n}\n\ninterface Err<E> {\n ok: false\n error: E\n}\n\nexport class Result<T, E> {\n /**\n * Wraps a function with a try catch, creating a new function with the same\n * arguments but returning `Ok` if successful, `Err` if the function throws\n *\n * @param fn function to wrap with ok on success or err on failure\n * @param errorFn when an error is thrown, this will wrap the error result if provided\n */\n static fromThrowable<Fn extends (...args: readonly any[]) => unknown, E>(\n fn: Fn,\n errorFn?: (e: any) => E,\n ): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E> {\n return (...args) => {\n try {\n const result = fn(...args)\n return ok(result as ReturnType<Fn>)\n } catch (error) {\n if (errorFn) {\n return err(errorFn(error))\n }\n\n return err(error as E)\n }\n }\n }\n\n static ok<T, E=never>(value: T): Result<T, E> {\n return new Result<T, E>({ ok: true, value })\n }\n\n static err<T=never, E=unknown>(error: E): Result<T, E> {\n return new Result<T, E>({ ok: false, error })\n }\n\n readonly value: T\n readonly error: E\n\n private constructor(private readonly state: Ok<T> | Err<E>) {\n if (state.ok) {\n this.value = state.value\n this.error = undefined as E\n } else {\n this.error = state.error\n this.value = undefined as T\n }\n }\n\n /**\n * Used to check if a `Result` is an `OK`\n *\n * @returns `true` if the result is an `OK` variant of Result\n */\n isOk(): boolean {\n return this.state.ok\n }\n\n /**\n * Used to check if a `Result` is an `Err`\n *\n * @returns `true` if the result is an `Err` variant of Result\n */\n isErr(): boolean {\n return !this.state.ok\n }\n\n /**\n * Maps a `Result<T, E>` to `Result<U, E>`\n * by applying a function to a contained `Ok` value, leaving an `Err` value\n * untouched.\n *\n * @param f The function to apply an `OK` value\n * @returns the result of applying `f` or an `Err` untouched\n */\n map<X, Y>(f: (t: T) => Exclude<X, Promise<any>>): Result<X, E | Y>\n map<X>(f: (t: T) => Exclude<X, Promise<any>>): Result<X, E> {\n if (this.state.ok) {\n const value = f(this.value)\n return ok(value)\n }\n\n return err(this.error as Exclude<E, Promise<any>>)\n }\n\n /**\n * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a\n * contained `Err` value, leaving an `Ok` value untouched.\n *\n * This function can be used to pass through a successful result while\n * handling an error.\n *\n * @param f a function to apply to the error `Err` value\n */\n mapErr<X>(fn: (t: Exclude<E, Promise<any>>) => Exclude<X, Promise<any>>): Result<T, X> {\n if (this.state.ok) {\n return ok(this.value as Exclude<T, Promise<any>>)\n }\n\n return err(fn(this.error as Exclude<E, Promise<any>>))\n }\n\n /**\n * Similar to `map` Except you must return a new `Result`.\n *\n * This is useful for when you need to do a subsequent computation using the\n * inner `T` value, but that computation might fail.\n * Additionally, `andThen` is really useful as a tool to flatten a\n * `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).\n *\n * @param f The function to apply to the current value\n */\n andThen<X, Y>(f: (t: T) => Exclude<Result<X, Y>, Promise<any>>): Result<X, E | Y>\n andThen<X, Y>(f: (t: T) => Exclude<Result<X, Y>, Promise<any>>): Result<X, E | Y> {\n if (this.state.ok) {\n return f(this.value)\n }\n\n return err(this.error as Exclude<E, Promise<any>>)\n }\n\n /**\n * Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.\n *\n * This is useful for error recovery.\n *\n *\n * @param f A function to apply to an `Err` value, leaving `Ok` values\n * untouched.\n */\n orElse<Y>(f: (t: E) => Result<T, Y>): Result<T, Y>\n orElse<Y>(f: (t: E) => Result<T, Y>): Result<T, E | Y> {\n if (this.state.ok) {\n return ok(this.value as Exclude<T, Promise<any>>)\n }\n\n return f(this.error)\n }\n\n /**\n * Similar to `map` Except you must return a new `Result`.\n *\n * This is useful for when you need to do a subsequent async computation using\n * the inner `T` value, but that computation might fail. Must return a ResultAsync\n *\n * @param f The function that returns a `ResultAsync` to apply to the current\n * value\n */\n asyncAndThen<X, Y>(f: (t: T) => ResultAsync<X, Y>): ResultAsync<X, E | Y>\n asyncAndThen<X, Y>(f: (t: T) => ResultAsync<X, E>): ResultAsync<X, E | Y> {\n if (this.state.ok) {\n return f(this.value)\n }\n\n return errAsync(this.error)\n }\n\n /**\n * Maps a `Result<T, E>` to `ResultAsync<U, E>`\n * by applying an async function to a contained `Ok` value, leaving an `Err`\n * value untouched.\n *\n * @param f An async function to apply an `OK` value\n */\n asyncMap<X>(f: (t: T) => Promise<X>): ResultAsync<X, E> {\n if (this.state.ok) {\n return ResultAsync.fromSafePromise(f(this.value))\n }\n\n return errAsync(this.error)\n }\n\n /**\n * Unwrap the `Ok` value, or return the default if there is an `Err`\n *\n * @param v the default value to return if there is an `Err`\n */\n unwrapOr<A>(defaultValue: A): T | A {\n if (this.state.ok) {\n return this.value\n }\n\n return defaultValue\n }\n\n /**\n *\n * Given 2 functions (one for the `Ok` variant and one for the `Err` variant)\n * execute the function that matches the `Result` variant.\n *\n * Match callbacks do not necessitate to return a `Result`, however you can\n * return a `Result` if you want to.\n *\n * `match` is like chaining `map` and `mapErr`, with the distinction that\n * with `match` both functions must have the same return type.\n *\n * @param ok\n * @param err\n */\n match<X>(fnOk: (t: T) => X, fnErr: (e: E) => X): X {\n if (this.state.ok) {\n return fnOk(this.value)\n }\n\n return fnErr(this.error)\n }\n\n /**\n * **This method is unsafe, and should only be used in a test environments**\n *\n * Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.\n *\n * @param config\n */\n _unsafeUnwrap(config?: ErrorConfig): T {\n if (this.state.ok) {\n return this.value\n }\n\n throw createResultarError('Called `_unsafeUnwrap` on an Err', this, config) // eslint-disable-line @typescript-eslint/no-throw-literal\n }\n\n /**\n * **This method is unsafe, and should only be used in a test environments**\n *\n * takes a `Result<T, E>` and returns a `E` when the result is an `Err`,\n * otherwise it throws a custom object.\n *\n * @param config\n */\n _unsafeUnwrapErr(config?: ErrorConfig): E {\n if (this.state.ok) {\n throw createResultarError('Called `_unsafeUnwrapErr` on an Ok', this, config) // eslint-disable-line @typescript-eslint/no-throw-literal\n }\n\n return this.error\n }\n\n safeUnwrap(): Generator<Result<never, E>, T> {\n if (this.state.ok) {\n const { value } = this\n /* eslint-disable-next-line require-yield */\n return (function * () {\n return value\n })()\n }\n\n const { error } = this\n return (function * () {\n yield err(error)\n\n throw new Error('Do not use this generator out of `safeTry`')\n })()\n }\n}\n\nexport const ok = <T, E = never>(value: T): Result<T, E> => Result.ok(value)\nexport const err = <T = never, E = unknown>(error: E): Result<T, E> => Result.err(error)\nexport const fromThrowable = <Fn extends (...args: readonly any[]) => unknown, E>(\n fn: Fn,\n errorFn?: (e: any) => E,\n): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E> => Result.fromThrowable(fn, errorFn)\n\n/**\n * Evaluates the given generator to a Result returned or an Err yielded from it,\n * whichever comes first.\n *\n * This function, in combination with `Result.safeUnwrap()`, is intended to emulate\n * Rust's ? operator.\n * See `/tests/safeTry.test.ts` for examples.\n *\n * @param body - What is evaluated. In body, `yield* result.safeUnwrap()` works as\n * Rust's `result?` expression.\n * @returns The first occurence of either an yielded Err or a returned Result.\n */\nexport function safeTry<T, E>(body: () => Generator<Result<never, E>, Result<T, E>>): Result<T, E>\n/**\n * Evaluates the given generator to a Result returned or an Err yielded from it,\n * whichever comes first.\n *\n * This function, in combination with `Result.safeUnwrap()`, is intended to emulate\n * Rust's ? operator.\n * See `/tests/safeTry.test.ts` for examples.\n *\n * @param body - What is evaluated. In body, `yield* result.safeUnwrap()` and\n * `yield* resultAsync.safeUnwrap()` work as Rust's `result?` expression.\n * @returns The first occurence of either an yielded Err or a returned Result.\n */\n// NOTE:\n// Since body is potentially throwable because `await` can be used in it,\n// Promise<Result<T, E>>, not ResultAsync<T, E>, is used as the return type.\nexport function safeTry<T, E>(\n body: () => AsyncGenerator<Result<never, E>, Result<T, E>>,\n): Promise<Result<T, E>>\nexport function safeTry<T, E>(\n body:\n | (() => Generator<Result<never, E>, Result<T, E>>)\n | (() => AsyncGenerator<Result<never, E>, Result<T, E>>),\n): Result<T, E> | Promise<Result<T, E>> {\n const n = body().next()\n if (n instanceof Promise) {\n return n.then(r => r.value)\n }\n\n return n.value\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAM,qBAAkC;AAAA,EACtC,gBAAgB;AAClB;AAgBO,IAAM,sBAAsB,CACjC,SACA,QACA,SAAsB,uBACE;AACxB,QAAM,OAAO,OAAO,KAAK,IACrB,EAAE,MAAM,MAAM,OAAO,OAAO,MAAM,IAClC,EAAE,MAAM,OAAO,OAAO,OAAO,MAAM;AAEvC,QAAM,aAAa,OAAO,iBAAiB,IAAI,MAAM,EAAE,QAAQ;AAE/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT;AACF;;;ACpCO,IAAM,cAAN,MAAM,aAAuD;AAAA,EAElE,OAAO,gBAA8B,SAAwC;AAC3E,UAAM,aAAa,QAChB,KAAK,CAAC,UAAa,OAAO,GAAG,KAAK,CAAC;AAEtC,WAAO,IAAI,aAAkB,UAAU;AAAA,EACzC;AAAA,EAGA,OAAO,YAAkB,SAAqB,SAA+C;AAC3F,UAAM,aAAa,QAChB,KAAK,CAAC,UAAa,OAAO,GAAG,KAAK,CAAC,EACnC,MAAM,WAAS,OAAO,IAAI,QAAQ,KAAK,CAAC,CAAC;AAE5C,WAAO,IAAI,aAAkB,UAAU;AAA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AiCtF,SAAS,QACd,MAGsC;AACtC,QAAM,IAAI,KAAK,EAAE,KAAK;AACtB,MAAI,aAAa,SAAS;AACxB,WAAO,EAAE,KAAK,OAAK,EAAE,KAAK;AAAA,EAC5B;AAEA,SAAO,EAAE;AACX;","names":["ok"]}
@@ -0,0 +1 @@
1
+ export { b as Result, R as ResultAsync, d as err, e as errAsync, a as fromPromise, f as fromSafePromise, g as fromThrowable, c as ok, o as okAsync, h as safeTry, s as safeTryAsync } from './index-CyqyqPfg.cjs';
@@ -0,0 +1 @@
1
+ export { b as Result, R as ResultAsync, d as err, e as errAsync, a as fromPromise, f as fromSafePromise, g as fromThrowable, c as ok, o as okAsync, h as safeTry, s as safeTryAsync } from './index-CyqyqPfg.js';
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import {
2
+ Result,
3
+ ResultAsync,
4
+ err,
5
+ errAsync,
6
+ fromPromise,
7
+ fromSafePromise,
8
+ fromThrowable,
9
+ ok,
10
+ okAsync,
11
+ safeTry,
12
+ safeTryAsync
13
+ } from "./chunk-DBDW2LXV.js";
14
+ import "./chunk-FBVQYZXO.js";
15
+ export {
16
+ Result,
17
+ ResultAsync,
18
+ err,
19
+ errAsync,
20
+ fromPromise,
21
+ fromSafePromise,
22
+ fromThrowable,
23
+ ok,
24
+ okAsync,
25
+ safeTry,
26
+ safeTryAsync
27
+ };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}