@zokugun/xtry 0.6.3 → 0.6.4

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.
Files changed (59) hide show
  1. package/lib/cjs/async.cjs +25 -23
  2. package/lib/cjs/async.d.cts +7 -6
  3. package/lib/cjs/defer.cjs +44 -37
  4. package/lib/cjs/defer.d.cts +15 -15
  5. package/lib/cjs/index.cjs +31 -29
  6. package/lib/cjs/index.d.cts +7 -6
  7. package/lib/cjs/partial.cjs +40 -41
  8. package/lib/cjs/partial.d.cts +24 -27
  9. package/lib/cjs/result.cjs +19 -24
  10. package/lib/cjs/result.d.cts +16 -19
  11. package/lib/cjs/stringify-error.cjs +19 -12
  12. package/lib/cjs/stringify-error.d.cts +1 -4
  13. package/lib/cjs/sync.cjs +25 -23
  14. package/lib/cjs/sync.d.cts +7 -6
  15. package/lib/cjs/try.cjs +64 -45
  16. package/lib/cjs/try.d.cts +7 -10
  17. package/lib/cjs/utils/is-promise-like.cjs +4 -6
  18. package/lib/cjs/utils/is-promise-like.d.cts +3 -0
  19. package/lib/cjs/utils/types.cjs +2 -0
  20. package/lib/cjs/utils/types.d.cts +5 -6
  21. package/lib/esm/async.d.mts +7 -0
  22. package/lib/esm/async.mjs +5 -0
  23. package/lib/esm/defer.d.mts +19 -0
  24. package/lib/esm/defer.mjs +45 -0
  25. package/lib/esm/index.d.mts +7 -0
  26. package/lib/esm/index.mjs +5 -0
  27. package/lib/esm/partial.d.mts +27 -0
  28. package/lib/esm/partial.mjs +43 -0
  29. package/lib/esm/result.d.mts +18 -0
  30. package/lib/esm/result.mjs +18 -0
  31. package/lib/esm/stringify-error.d.mts +1 -0
  32. package/lib/esm/stringify-error.mjs +18 -0
  33. package/lib/esm/sync.d.mts +7 -0
  34. package/lib/esm/sync.mjs +5 -0
  35. package/lib/esm/try.d.mts +9 -0
  36. package/lib/esm/try.mjs +65 -0
  37. package/lib/esm/utils/is-promise-like.d.mts +3 -0
  38. package/lib/esm/utils/is-promise-like.mjs +3 -0
  39. package/lib/esm/utils/types.d.mts +5 -0
  40. package/lib/esm/utils/types.mjs +1 -0
  41. package/package.json +31 -16
  42. package/lib/esm/async.d.ts +0 -6
  43. package/lib/esm/async.js +0 -7
  44. package/lib/esm/defer.d.ts +0 -19
  45. package/lib/esm/defer.js +0 -41
  46. package/lib/esm/index.d.ts +0 -6
  47. package/lib/esm/index.js +0 -7
  48. package/lib/esm/partial.d.ts +0 -30
  49. package/lib/esm/partial.js +0 -44
  50. package/lib/esm/result.d.ts +0 -21
  51. package/lib/esm/result.js +0 -22
  52. package/lib/esm/stringify-error.d.ts +0 -4
  53. package/lib/esm/stringify-error.js +0 -13
  54. package/lib/esm/sync.d.ts +0 -6
  55. package/lib/esm/sync.js +0 -7
  56. package/lib/esm/try.d.ts +0 -12
  57. package/lib/esm/try.js +0 -49
  58. package/lib/esm/utils/is-promise-like.js +0 -7
  59. package/lib/esm/utils/types.d.ts +0 -6
package/lib/cjs/async.cjs CHANGED
@@ -1,23 +1,25 @@
1
- const require__home_runner_work_node_xtry_node_xtry_src_result = require('./result.cjs');
2
- const require__home_runner_work_node_xtry_node_xtry_src_defer = require('./defer.cjs');
3
- const require__home_runner_work_node_xtry_node_xtry_src_partial = require('./partial.cjs');
4
- const require__home_runner_work_node_xtry_node_xtry_src_stringify_error = require('./stringify-error.cjs');
5
- const require__home_runner_work_node_xtry_node_xtry_src_try = require('./try.cjs');
6
-
7
- exports.OK = require__home_runner_work_node_xtry_node_xtry_src_result.OK;
8
- exports.OK_FALSE = require__home_runner_work_node_xtry_node_xtry_src_result.OK_FALSE;
9
- exports.OK_NULL = require__home_runner_work_node_xtry_node_xtry_src_result.OK_NULL;
10
- exports.OK_TRUE = require__home_runner_work_node_xtry_node_xtry_src_result.OK_TRUE;
11
- exports.YOK = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK;
12
- exports.YOK_FALSE = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_FALSE;
13
- exports.YOK_NULL = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_NULL;
14
- exports.YOK_TRUE = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_TRUE;
15
- exports.err = require__home_runner_work_node_xtry_node_xtry_src_result.err;
16
- exports.ok = require__home_runner_work_node_xtry_node_xtry_src_result.ok;
17
- exports.stringifyError = require__home_runner_work_node_xtry_node_xtry_src_stringify_error.stringifyError;
18
- exports.xdefer = require__home_runner_work_node_xtry_node_xtry_src_defer.xdeferAsync;
19
- exports.xtry = require__home_runner_work_node_xtry_node_xtry_src_try.xtryAsync;
20
- exports.yep = require__home_runner_work_node_xtry_node_xtry_src_partial.yep;
21
- exports.yerr = require__home_runner_work_node_xtry_node_xtry_src_partial.yerr;
22
- exports.yok = require__home_runner_work_node_xtry_node_xtry_src_partial.yok;
23
- exports.yres = require__home_runner_work_node_xtry_node_xtry_src_partial.yresAsync;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xtry = exports.stringifyError = exports.OK_FALSE = exports.OK_TRUE = exports.OK_NULL = exports.OK = exports.err = exports.ok = exports.YOK_FALSE = exports.YOK_TRUE = exports.YOK_NULL = exports.YOK = exports.yep = exports.yres = exports.yerr = exports.yok = exports.xdefer = void 0;
4
+ var defer_js_1 = require("./defer.cjs");
5
+ Object.defineProperty(exports, "xdefer", { enumerable: true, get: function () { return defer_js_1.xdeferAsync; } });
6
+ var partial_js_1 = require("./partial.cjs");
7
+ Object.defineProperty(exports, "yok", { enumerable: true, get: function () { return partial_js_1.yok; } });
8
+ Object.defineProperty(exports, "yerr", { enumerable: true, get: function () { return partial_js_1.yerr; } });
9
+ Object.defineProperty(exports, "yres", { enumerable: true, get: function () { return partial_js_1.yresAsync; } });
10
+ Object.defineProperty(exports, "yep", { enumerable: true, get: function () { return partial_js_1.yep; } });
11
+ Object.defineProperty(exports, "YOK", { enumerable: true, get: function () { return partial_js_1.YOK; } });
12
+ Object.defineProperty(exports, "YOK_NULL", { enumerable: true, get: function () { return partial_js_1.YOK_NULL; } });
13
+ Object.defineProperty(exports, "YOK_TRUE", { enumerable: true, get: function () { return partial_js_1.YOK_TRUE; } });
14
+ Object.defineProperty(exports, "YOK_FALSE", { enumerable: true, get: function () { return partial_js_1.YOK_FALSE; } });
15
+ var result_js_1 = require("./result.cjs");
16
+ Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return result_js_1.ok; } });
17
+ Object.defineProperty(exports, "err", { enumerable: true, get: function () { return result_js_1.err; } });
18
+ Object.defineProperty(exports, "OK", { enumerable: true, get: function () { return result_js_1.OK; } });
19
+ Object.defineProperty(exports, "OK_NULL", { enumerable: true, get: function () { return result_js_1.OK_NULL; } });
20
+ Object.defineProperty(exports, "OK_TRUE", { enumerable: true, get: function () { return result_js_1.OK_TRUE; } });
21
+ Object.defineProperty(exports, "OK_FALSE", { enumerable: true, get: function () { return result_js_1.OK_FALSE; } });
22
+ var stringify_error_js_1 = require("./stringify-error.cjs");
23
+ Object.defineProperty(exports, "stringifyError", { enumerable: true, get: function () { return stringify_error_js_1.stringifyError; } });
24
+ var try_js_1 = require("./try.cjs");
25
+ Object.defineProperty(exports, "xtry", { enumerable: true, get: function () { return try_js_1.xtryAsync; } });
@@ -1,6 +1,7 @@
1
- import { Failure, OK, OK_FALSE, OK_NULL, OK_TRUE, Result, Success, err, ok } from "./result.cjs";
2
- import { xdeferAsync } from "./defer.cjs";
3
- import { YFailure, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, YResult, YSuccess, yep, yerr, yok, yresAsync } from "./partial.cjs";
4
- import { stringifyError } from "./stringify-error.cjs";
5
- import { xtryAsync } from "./try.cjs";
6
- export { type Failure, OK, OK_FALSE, OK_NULL, OK_TRUE, type Result, type Success, type YFailure, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, type YResult, type YSuccess, err, ok, stringifyError, xdeferAsync as xdefer, xtryAsync as xtry, yep, yerr, yok, yresAsync as yres };
1
+ export { xdeferAsync as xdefer } from './defer.cjs';
2
+ export type { YResult, YSuccess, YFailure } from './partial.cjs';
3
+ export { yok, yerr, yresAsync as yres, yep, YOK, YOK_NULL, YOK_TRUE, YOK_FALSE } from './partial.cjs';
4
+ export type { Success, Failure, Result } from './result.cjs';
5
+ export { ok, err, OK, OK_NULL, OK_TRUE, OK_FALSE } from './result.cjs';
6
+ export { stringifyError } from './stringify-error.cjs';
7
+ export { xtryAsync as xtry } from './try.cjs';
package/lib/cjs/defer.cjs CHANGED
@@ -1,43 +1,50 @@
1
- const require__home_runner_work_node_xtry_node_xtry_src_result = require('./result.cjs');
2
- const require__home_runner_work_node_xtry_node_xtry_src_utils_is_promise_like = require('./utils/is-promise-like.cjs');
3
-
4
- //#region src/defer.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xdefer = xdefer;
4
+ exports.xdeferAsync = xdeferAsync;
5
+ exports.xdeferSync = xdeferSync;
6
+ const result_js_1 = require("./result.cjs");
7
+ const is_promise_like_js_1 = require("./utils/is-promise-like.cjs");
5
8
  function xdefer(callback) {
6
- return (result) => {
7
- const finalize = (deferResult) => {
8
- if (deferResult.fails) {
9
- if (result?.fails) return result;
10
- return deferResult;
11
- }
12
- return result ?? require__home_runner_work_node_xtry_node_xtry_src_result.ok();
13
- };
14
- const deferredValue = callback instanceof Function ? callback() : callback;
15
- if (require__home_runner_work_node_xtry_node_xtry_src_utils_is_promise_like.isPromiseLike(deferredValue)) return Promise.resolve(deferredValue).then(finalize);
16
- return finalize(deferredValue);
17
- };
9
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
10
+ return ((result) => {
11
+ const finalize = (deferResult) => {
12
+ if (deferResult.fails) {
13
+ if ((result)?.fails) {
14
+ return result;
15
+ }
16
+ return deferResult;
17
+ }
18
+ return (result) ?? (0, result_js_1.ok)();
19
+ };
20
+ const deferredValue = callback instanceof Function ? callback() : callback;
21
+ if ((0, is_promise_like_js_1.isPromiseLike)(deferredValue)) {
22
+ return Promise.resolve(deferredValue).then(finalize);
23
+ }
24
+ return finalize(deferredValue);
25
+ });
18
26
  }
19
27
  function xdeferAsync(callback) {
20
- return async (result) => {
21
- const deferResult = await (callback instanceof Promise ? callback : callback());
22
- if (deferResult.fails) {
23
- if (result?.fails) return result;
24
- return deferResult;
25
- }
26
- return result ?? require__home_runner_work_node_xtry_node_xtry_src_result.ok();
27
- };
28
+ return (async (result) => {
29
+ const deferResult = await (callback instanceof Promise ? callback : callback());
30
+ if (deferResult.fails) {
31
+ if (result?.fails) {
32
+ return result;
33
+ }
34
+ return deferResult;
35
+ }
36
+ return result ?? (0, result_js_1.ok)();
37
+ });
28
38
  }
29
39
  function xdeferSync(callback) {
30
- return (result) => {
31
- const deferResult = callback();
32
- if (deferResult.fails) {
33
- if (result?.fails) return result;
34
- return deferResult;
35
- }
36
- return result ?? require__home_runner_work_node_xtry_node_xtry_src_result.ok();
37
- };
40
+ return ((result) => {
41
+ const deferResult = callback();
42
+ if (deferResult.fails) {
43
+ if (result?.fails) {
44
+ return result;
45
+ }
46
+ return deferResult;
47
+ }
48
+ return result ?? (0, result_js_1.ok)();
49
+ });
38
50
  }
39
-
40
- //#endregion
41
- exports.xdefer = xdefer;
42
- exports.xdeferAsync = xdeferAsync;
43
- exports.xdeferSync = xdeferSync;
@@ -1,19 +1,19 @@
1
- import { Result, Success } from "./result.cjs";
2
- import { NonPromiseCallback, PromiseCallback } from "./utils/types.cjs";
3
-
4
- //#region src/defer.d.ts
1
+ import { type Failure, type Result, type Success } from './result.cjs';
2
+ import { type NonPromiseCallback, type PromiseCallback } from './utils/types.cjs';
5
3
  type DeferAsync<E> = {
6
- (): Promise<Success<void>>;
7
- (result: UnknownResult<E>): Promise<UnknownResult<E>>;
4
+ (): Promise<Success<void>>;
5
+ <T>(result: Success<T>): Promise<Result<T, E>>;
6
+ <F>(result: Failure<F>): Promise<Failure<F>>;
7
+ <T, F>(result: Result<T, F>): Promise<Result<T, E | F>>;
8
8
  };
9
9
  type DeferSync<E> = {
10
- (): Success<void>;
11
- (result: UnknownResult<E>): UnknownResult<E>;
10
+ (): Success<void>;
11
+ <T>(result: Success<T>): Result<T, E>;
12
+ <F>(result: Failure<F>): Failure<F>;
13
+ <T, F>(result: Result<T, F>): Result<T, E | F>;
12
14
  };
13
- type UnknownResult<E> = Result<unknown, E>;
14
- declare function xdefer<E>(callback: NonPromiseCallback<UnknownResult<E>>): DeferSync<E>;
15
- declare function xdefer<E>(callback: PromiseCallback<UnknownResult<E>>): DeferAsync<E>;
16
- declare function xdeferAsync<E>(callback: PromiseCallback<UnknownResult<E>>): DeferAsync<E>;
17
- declare function xdeferSync<E>(callback: NonPromiseCallback<UnknownResult<E>>): DeferSync<E>;
18
- //#endregion
19
- export { xdefer, xdeferAsync, xdeferSync };
15
+ export declare function xdefer<E>(callback: NonPromiseCallback<Result<unknown, E>>): DeferSync<E>;
16
+ export declare function xdefer<E>(callback: PromiseCallback<Result<unknown, E>>): DeferAsync<E>;
17
+ export declare function xdeferAsync<E>(callback: PromiseCallback<Result<unknown, E>>): DeferAsync<E>;
18
+ export declare function xdeferSync<E>(callback: NonPromiseCallback<Result<unknown, E>>): DeferSync<E>;
19
+ export {};
package/lib/cjs/index.cjs CHANGED
@@ -1,29 +1,31 @@
1
- const require__home_runner_work_node_xtry_node_xtry_src_result = require('./result.cjs');
2
- const require__home_runner_work_node_xtry_node_xtry_src_defer = require('./defer.cjs');
3
- const require__home_runner_work_node_xtry_node_xtry_src_partial = require('./partial.cjs');
4
- const require__home_runner_work_node_xtry_node_xtry_src_stringify_error = require('./stringify-error.cjs');
5
- const require__home_runner_work_node_xtry_node_xtry_src_try = require('./try.cjs');
6
-
7
- exports.OK = require__home_runner_work_node_xtry_node_xtry_src_result.OK;
8
- exports.OK_FALSE = require__home_runner_work_node_xtry_node_xtry_src_result.OK_FALSE;
9
- exports.OK_NULL = require__home_runner_work_node_xtry_node_xtry_src_result.OK_NULL;
10
- exports.OK_TRUE = require__home_runner_work_node_xtry_node_xtry_src_result.OK_TRUE;
11
- exports.YOK = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK;
12
- exports.YOK_FALSE = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_FALSE;
13
- exports.YOK_NULL = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_NULL;
14
- exports.YOK_TRUE = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_TRUE;
15
- exports.err = require__home_runner_work_node_xtry_node_xtry_src_result.err;
16
- exports.ok = require__home_runner_work_node_xtry_node_xtry_src_result.ok;
17
- exports.stringifyError = require__home_runner_work_node_xtry_node_xtry_src_stringify_error.stringifyError;
18
- exports.xdefer = require__home_runner_work_node_xtry_node_xtry_src_defer.xdefer;
19
- exports.xdeferAsync = require__home_runner_work_node_xtry_node_xtry_src_defer.xdeferAsync;
20
- exports.xdeferSync = require__home_runner_work_node_xtry_node_xtry_src_defer.xdeferSync;
21
- exports.xtry = require__home_runner_work_node_xtry_node_xtry_src_try.xtry;
22
- exports.xtryAsync = require__home_runner_work_node_xtry_node_xtry_src_try.xtryAsync;
23
- exports.xtrySync = require__home_runner_work_node_xtry_node_xtry_src_try.xtrySync;
24
- exports.yep = require__home_runner_work_node_xtry_node_xtry_src_partial.yep;
25
- exports.yerr = require__home_runner_work_node_xtry_node_xtry_src_partial.yerr;
26
- exports.yok = require__home_runner_work_node_xtry_node_xtry_src_partial.yok;
27
- exports.yres = require__home_runner_work_node_xtry_node_xtry_src_partial.yres;
28
- exports.yresAsync = require__home_runner_work_node_xtry_node_xtry_src_partial.yresAsync;
29
- exports.yresSync = require__home_runner_work_node_xtry_node_xtry_src_partial.yresSync;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xtrySync = exports.xtryAsync = exports.xtry = exports.stringifyError = exports.OK_FALSE = exports.OK_TRUE = exports.OK_NULL = exports.OK = exports.err = exports.ok = exports.YOK_FALSE = exports.YOK_TRUE = exports.YOK_NULL = exports.YOK = exports.yep = exports.yresSync = exports.yresAsync = exports.yres = exports.yerr = exports.yok = exports.xdeferSync = exports.xdeferAsync = exports.xdefer = void 0;
4
+ var defer_js_1 = require("./defer.cjs");
5
+ Object.defineProperty(exports, "xdefer", { enumerable: true, get: function () { return defer_js_1.xdefer; } });
6
+ Object.defineProperty(exports, "xdeferAsync", { enumerable: true, get: function () { return defer_js_1.xdeferAsync; } });
7
+ Object.defineProperty(exports, "xdeferSync", { enumerable: true, get: function () { return defer_js_1.xdeferSync; } });
8
+ var partial_js_1 = require("./partial.cjs");
9
+ Object.defineProperty(exports, "yok", { enumerable: true, get: function () { return partial_js_1.yok; } });
10
+ Object.defineProperty(exports, "yerr", { enumerable: true, get: function () { return partial_js_1.yerr; } });
11
+ Object.defineProperty(exports, "yres", { enumerable: true, get: function () { return partial_js_1.yres; } });
12
+ Object.defineProperty(exports, "yresAsync", { enumerable: true, get: function () { return partial_js_1.yresAsync; } });
13
+ Object.defineProperty(exports, "yresSync", { enumerable: true, get: function () { return partial_js_1.yresSync; } });
14
+ Object.defineProperty(exports, "yep", { enumerable: true, get: function () { return partial_js_1.yep; } });
15
+ Object.defineProperty(exports, "YOK", { enumerable: true, get: function () { return partial_js_1.YOK; } });
16
+ Object.defineProperty(exports, "YOK_NULL", { enumerable: true, get: function () { return partial_js_1.YOK_NULL; } });
17
+ Object.defineProperty(exports, "YOK_TRUE", { enumerable: true, get: function () { return partial_js_1.YOK_TRUE; } });
18
+ Object.defineProperty(exports, "YOK_FALSE", { enumerable: true, get: function () { return partial_js_1.YOK_FALSE; } });
19
+ var result_js_1 = require("./result.cjs");
20
+ Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return result_js_1.ok; } });
21
+ Object.defineProperty(exports, "err", { enumerable: true, get: function () { return result_js_1.err; } });
22
+ Object.defineProperty(exports, "OK", { enumerable: true, get: function () { return result_js_1.OK; } });
23
+ Object.defineProperty(exports, "OK_NULL", { enumerable: true, get: function () { return result_js_1.OK_NULL; } });
24
+ Object.defineProperty(exports, "OK_TRUE", { enumerable: true, get: function () { return result_js_1.OK_TRUE; } });
25
+ Object.defineProperty(exports, "OK_FALSE", { enumerable: true, get: function () { return result_js_1.OK_FALSE; } });
26
+ var stringify_error_js_1 = require("./stringify-error.cjs");
27
+ Object.defineProperty(exports, "stringifyError", { enumerable: true, get: function () { return stringify_error_js_1.stringifyError; } });
28
+ var try_js_1 = require("./try.cjs");
29
+ Object.defineProperty(exports, "xtry", { enumerable: true, get: function () { return try_js_1.xtry; } });
30
+ Object.defineProperty(exports, "xtryAsync", { enumerable: true, get: function () { return try_js_1.xtryAsync; } });
31
+ Object.defineProperty(exports, "xtrySync", { enumerable: true, get: function () { return try_js_1.xtrySync; } });
@@ -1,6 +1,7 @@
1
- import { Failure, OK, OK_FALSE, OK_NULL, OK_TRUE, Result, Success, err, ok } from "./result.cjs";
2
- import { xdefer, xdeferAsync, xdeferSync } from "./defer.cjs";
3
- import { YFailure, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, YResult, YSuccess, yep, yerr, yok, yres, yresAsync, yresSync } from "./partial.cjs";
4
- import { stringifyError } from "./stringify-error.cjs";
5
- import { xtry, xtryAsync, xtrySync } from "./try.cjs";
6
- export { type Failure, OK, OK_FALSE, OK_NULL, OK_TRUE, type Result, type Success, type YFailure, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, type YResult, type YSuccess, err, ok, stringifyError, xdefer, xdeferAsync, xdeferSync, xtry, xtryAsync, xtrySync, yep, yerr, yok, yres, yresAsync, yresSync };
1
+ export { xdefer, xdeferAsync, xdeferSync } from './defer.cjs';
2
+ export type { YResult, YSuccess, YFailure } from './partial.cjs';
3
+ export { yok, yerr, yres, yresAsync, yresSync, yep, YOK, YOK_NULL, YOK_TRUE, YOK_FALSE } from './partial.cjs';
4
+ export type { Success, Failure, Result } from './result.cjs';
5
+ export { ok, err, OK, OK_NULL, OK_TRUE, OK_FALSE } from './result.cjs';
6
+ export { stringifyError } from './stringify-error.cjs';
7
+ export { xtry, xtryAsync, xtrySync } from './try.cjs';
@@ -1,53 +1,52 @@
1
- const require__home_runner_work_node_xtry_node_xtry_src_utils_is_promise_like = require('./utils/is-promise-like.cjs');
2
-
3
- //#region src/partial.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.YOK_FALSE = exports.YOK_TRUE = exports.YOK_NULL = exports.YOK = void 0;
4
+ exports.yok = yok;
5
+ exports.yerr = yerr;
6
+ exports.yres = yres;
7
+ exports.yresSync = yresSync;
8
+ exports.yresAsync = yresAsync;
9
+ exports.yep = yep;
10
+ const is_promise_like_js_1 = require("./utils/is-promise-like.cjs");
4
11
  function yok(value) {
5
- return {
6
- fails: false,
7
- success: true,
8
- value,
9
- error: void 0
10
- };
12
+ return {
13
+ fails: false,
14
+ success: true,
15
+ value: value,
16
+ error: undefined,
17
+ };
11
18
  }
12
19
  function yerr(miscue) {
13
- return {
14
- fails: false,
15
- success: false,
16
- miscue,
17
- value: void 0,
18
- error: void 0
19
- };
20
+ return {
21
+ fails: false,
22
+ success: false,
23
+ miscue,
24
+ value: undefined,
25
+ error: undefined,
26
+ };
20
27
  }
21
28
  function yres(result) {
22
- if (require__home_runner_work_node_xtry_node_xtry_src_utils_is_promise_like.isPromiseLike(result)) return result.then(yresSync);
23
- return yresSync(result);
29
+ if ((0, is_promise_like_js_1.isPromiseLike)(result)) {
30
+ return result.then(yresSync);
31
+ }
32
+ return yresSync(result);
24
33
  }
25
34
  function yresSync(result) {
26
- if (result.fails) return result;
27
- return yep(result);
35
+ if (result.fails) {
36
+ return result;
37
+ }
38
+ return yep(result);
28
39
  }
29
40
  async function yresAsync(promise) {
30
- return promise.then(yresSync);
41
+ return promise.then(yresSync);
31
42
  }
32
43
  function yep(result) {
33
- return {
34
- ...result,
35
- success: true
36
- };
44
+ return {
45
+ ...result,
46
+ success: true,
47
+ };
37
48
  }
38
- const YOK = Object.freeze(yok());
39
- const YOK_NULL = Object.freeze(yok(null));
40
- const YOK_TRUE = Object.freeze(yok(true));
41
- const YOK_FALSE = Object.freeze(yok(false));
42
-
43
- //#endregion
44
- exports.YOK = YOK;
45
- exports.YOK_FALSE = YOK_FALSE;
46
- exports.YOK_NULL = YOK_NULL;
47
- exports.YOK_TRUE = YOK_TRUE;
48
- exports.yep = yep;
49
- exports.yerr = yerr;
50
- exports.yok = yok;
51
- exports.yres = yres;
52
- exports.yresAsync = yresAsync;
53
- exports.yresSync = yresSync;
49
+ exports.YOK = Object.freeze(yok());
50
+ exports.YOK_NULL = Object.freeze(yok(null));
51
+ exports.YOK_TRUE = Object.freeze(yok(true));
52
+ exports.YOK_FALSE = Object.freeze(yok(false));
@@ -1,30 +1,27 @@
1
- import { Failure, Result, Success } from "./result.cjs";
2
- import { NotPromise } from "./utils/types.cjs";
3
-
4
- //#region src/partial.d.ts
5
- type YResult<T, E, M> = Failure<E> | YSuccess<T> | YFailure<M>;
6
- type YSuccess<T> = Success<T> & {
7
- success: true;
1
+ import { type Result, type Failure, type Success } from './result.cjs';
2
+ import { type NotPromise } from './utils/types.cjs';
3
+ export type YResult<T, E, M> = Failure<E> | YSuccess<T> | YFailure<M>;
4
+ export type YSuccess<T> = Success<T> & {
5
+ success: true;
8
6
  };
9
- type YFailure<M> = {
10
- fails: false;
11
- success: false;
12
- miscue: M;
13
- value: undefined;
14
- error: undefined;
7
+ export type YFailure<M> = {
8
+ fails: false;
9
+ success: false;
10
+ miscue: M;
11
+ value: undefined;
12
+ error: undefined;
15
13
  };
16
- declare function yok(): YSuccess<void>;
17
- declare function yok<T>(value: T): YSuccess<T>;
18
- declare function yerr<M>(miscue: M): YFailure<M>;
14
+ export declare function yok(): YSuccess<void>;
15
+ export declare function yok<T>(value: T): YSuccess<T>;
16
+ export declare function yerr<M>(miscue: M): YFailure<M>;
19
17
  type YRResult<T, E> = Failure<E> | YSuccess<T>;
20
- declare function yres<T, E>(result: NotPromise<Result<T, E>>): YRResult<T, E>;
21
- declare function yres<T, E>(result: Promise<Result<T, E>>): Promise<YRResult<T, E>>;
22
- declare function yresSync<T, E>(result: NotPromise<Result<T, E>>): YRResult<T, E>;
23
- declare function yresAsync<T, E>(promise: Promise<Result<T, E>>): Promise<YRResult<T, E>>;
24
- declare function yep<T>(result: Success<T>): YSuccess<T>;
25
- declare const YOK: Readonly<YSuccess<void>>;
26
- declare const YOK_NULL: Readonly<YSuccess<any>>;
27
- declare const YOK_TRUE: Readonly<YSuccess<boolean>>;
28
- declare const YOK_FALSE: Readonly<YSuccess<boolean>>;
29
- //#endregion
30
- export { YFailure, YOK, YOK_FALSE, YOK_NULL, YOK_TRUE, YResult, YSuccess, yep, yerr, yok, yres, yresAsync, yresSync };
18
+ export declare function yres<T, E>(result: NotPromise<Result<T, E>>): YRResult<T, E>;
19
+ export declare function yres<T, E>(result: Promise<Result<T, E>>): Promise<YRResult<T, E>>;
20
+ export declare function yresSync<T, E>(result: NotPromise<Result<T, E>>): YRResult<T, E>;
21
+ export declare function yresAsync<T, E>(promise: Promise<Result<T, E>>): Promise<YRResult<T, E>>;
22
+ export declare function yep<T>(result: Success<T>): YSuccess<T>;
23
+ export declare const YOK: Readonly<YSuccess<void>>;
24
+ export declare const YOK_NULL: Readonly<YSuccess<null>>;
25
+ export declare const YOK_TRUE: Readonly<YSuccess<boolean>>;
26
+ export declare const YOK_FALSE: Readonly<YSuccess<boolean>>;
27
+ export {};
@@ -1,28 +1,23 @@
1
-
2
- //#region src/result.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OK_FALSE = exports.OK_TRUE = exports.OK_NULL = exports.OK = void 0;
4
+ exports.ok = ok;
5
+ exports.err = err;
3
6
  function ok(value) {
4
- return {
5
- fails: false,
6
- value,
7
- error: void 0
8
- };
7
+ return {
8
+ fails: false,
9
+ value: value,
10
+ error: undefined,
11
+ };
9
12
  }
10
13
  function err(error) {
11
- return {
12
- fails: true,
13
- value: void 0,
14
- error
15
- };
14
+ return {
15
+ fails: true,
16
+ value: undefined,
17
+ error,
18
+ };
16
19
  }
17
- const OK = Object.freeze(ok());
18
- const OK_NULL = Object.freeze(ok(null));
19
- const OK_TRUE = Object.freeze(ok(true));
20
- const OK_FALSE = Object.freeze(ok(false));
21
-
22
- //#endregion
23
- exports.OK = OK;
24
- exports.OK_FALSE = OK_FALSE;
25
- exports.OK_NULL = OK_NULL;
26
- exports.OK_TRUE = OK_TRUE;
27
- exports.err = err;
28
- exports.ok = ok;
20
+ exports.OK = Object.freeze(ok());
21
+ exports.OK_NULL = Object.freeze(ok(null));
22
+ exports.OK_TRUE = Object.freeze(ok(true));
23
+ exports.OK_FALSE = Object.freeze(ok(false));
@@ -1,21 +1,18 @@
1
- //#region src/result.d.ts
2
- type Success<T> = {
3
- fails: false;
4
- value: T;
5
- error: undefined;
1
+ export type Success<T> = {
2
+ fails: false;
3
+ value: T;
4
+ error: undefined;
6
5
  };
7
- type Failure<E> = {
8
- fails: true;
9
- value: undefined;
10
- error: E;
6
+ export type Failure<E> = {
7
+ fails: true;
8
+ value: undefined;
9
+ error: E;
11
10
  };
12
- type Result<T, E> = Success<T> | Failure<E>;
13
- declare function ok(): Success<void>;
14
- declare function ok<T>(value: T): Success<T>;
15
- declare function err<E>(error: E): Failure<E>;
16
- declare const OK: Readonly<Success<void>>;
17
- declare const OK_NULL: Readonly<Success<any>>;
18
- declare const OK_TRUE: Readonly<Success<boolean>>;
19
- declare const OK_FALSE: Readonly<Success<boolean>>;
20
- //#endregion
21
- export { Failure, OK, OK_FALSE, OK_NULL, OK_TRUE, Result, Success, err, ok };
11
+ export type Result<T, E> = Success<T> | Failure<E>;
12
+ export declare function ok(): Success<void>;
13
+ export declare function ok<T>(value: T): Success<T>;
14
+ export declare function err<E>(error: E): Failure<E>;
15
+ export declare const OK: Readonly<Success<void>>;
16
+ export declare const OK_NULL: Readonly<Success<null>>;
17
+ export declare const OK_TRUE: Readonly<Success<boolean>>;
18
+ export declare const OK_FALSE: Readonly<Success<boolean>>;
@@ -1,14 +1,21 @@
1
-
2
- //#region src/stringify-error.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyError = stringifyError;
3
4
  function stringifyError(error) {
4
- if (typeof error === "string") return error;
5
- if (error instanceof Error) return error.message ?? String(error);
6
- try {
7
- const json = JSON.stringify(error);
8
- if (typeof json === "string") return json;
9
- } catch {}
10
- return String(error);
5
+ if (typeof error === 'string') {
6
+ return error;
7
+ }
8
+ if (error instanceof Error) {
9
+ return error.message ?? String(error);
10
+ }
11
+ try {
12
+ const json = JSON.stringify(error);
13
+ if (typeof json === 'string') {
14
+ return json;
15
+ }
16
+ }
17
+ catch {
18
+ // fallthrough
19
+ }
20
+ return String(error);
11
21
  }
12
-
13
- //#endregion
14
- exports.stringifyError = stringifyError;
@@ -1,4 +1 @@
1
- //#region src/stringify-error.d.ts
2
- declare function stringifyError(error: unknown): string;
3
- //#endregion
4
- export { stringifyError };
1
+ export declare function stringifyError(error: unknown): string;
package/lib/cjs/sync.cjs CHANGED
@@ -1,23 +1,25 @@
1
- const require__home_runner_work_node_xtry_node_xtry_src_result = require('./result.cjs');
2
- const require__home_runner_work_node_xtry_node_xtry_src_defer = require('./defer.cjs');
3
- const require__home_runner_work_node_xtry_node_xtry_src_partial = require('./partial.cjs');
4
- const require__home_runner_work_node_xtry_node_xtry_src_stringify_error = require('./stringify-error.cjs');
5
- const require__home_runner_work_node_xtry_node_xtry_src_try = require('./try.cjs');
6
-
7
- exports.OK = require__home_runner_work_node_xtry_node_xtry_src_result.OK;
8
- exports.OK_FALSE = require__home_runner_work_node_xtry_node_xtry_src_result.OK_FALSE;
9
- exports.OK_NULL = require__home_runner_work_node_xtry_node_xtry_src_result.OK_NULL;
10
- exports.OK_TRUE = require__home_runner_work_node_xtry_node_xtry_src_result.OK_TRUE;
11
- exports.YOK = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK;
12
- exports.YOK_FALSE = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_FALSE;
13
- exports.YOK_NULL = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_NULL;
14
- exports.YOK_TRUE = require__home_runner_work_node_xtry_node_xtry_src_partial.YOK_TRUE;
15
- exports.err = require__home_runner_work_node_xtry_node_xtry_src_result.err;
16
- exports.ok = require__home_runner_work_node_xtry_node_xtry_src_result.ok;
17
- exports.stringifyError = require__home_runner_work_node_xtry_node_xtry_src_stringify_error.stringifyError;
18
- exports.xdefer = require__home_runner_work_node_xtry_node_xtry_src_defer.xdeferSync;
19
- exports.xtry = require__home_runner_work_node_xtry_node_xtry_src_try.xtrySync;
20
- exports.yep = require__home_runner_work_node_xtry_node_xtry_src_partial.yep;
21
- exports.yerr = require__home_runner_work_node_xtry_node_xtry_src_partial.yerr;
22
- exports.yok = require__home_runner_work_node_xtry_node_xtry_src_partial.yok;
23
- exports.yres = require__home_runner_work_node_xtry_node_xtry_src_partial.yresSync;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xtry = exports.stringifyError = exports.OK_FALSE = exports.OK_TRUE = exports.OK_NULL = exports.OK = exports.err = exports.ok = exports.YOK_FALSE = exports.YOK_TRUE = exports.YOK_NULL = exports.YOK = exports.yep = exports.yres = exports.yerr = exports.yok = exports.xdefer = void 0;
4
+ var defer_js_1 = require("./defer.cjs");
5
+ Object.defineProperty(exports, "xdefer", { enumerable: true, get: function () { return defer_js_1.xdeferSync; } });
6
+ var partial_js_1 = require("./partial.cjs");
7
+ Object.defineProperty(exports, "yok", { enumerable: true, get: function () { return partial_js_1.yok; } });
8
+ Object.defineProperty(exports, "yerr", { enumerable: true, get: function () { return partial_js_1.yerr; } });
9
+ Object.defineProperty(exports, "yres", { enumerable: true, get: function () { return partial_js_1.yresSync; } });
10
+ Object.defineProperty(exports, "yep", { enumerable: true, get: function () { return partial_js_1.yep; } });
11
+ Object.defineProperty(exports, "YOK", { enumerable: true, get: function () { return partial_js_1.YOK; } });
12
+ Object.defineProperty(exports, "YOK_NULL", { enumerable: true, get: function () { return partial_js_1.YOK_NULL; } });
13
+ Object.defineProperty(exports, "YOK_TRUE", { enumerable: true, get: function () { return partial_js_1.YOK_TRUE; } });
14
+ Object.defineProperty(exports, "YOK_FALSE", { enumerable: true, get: function () { return partial_js_1.YOK_FALSE; } });
15
+ var result_js_1 = require("./result.cjs");
16
+ Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return result_js_1.ok; } });
17
+ Object.defineProperty(exports, "err", { enumerable: true, get: function () { return result_js_1.err; } });
18
+ Object.defineProperty(exports, "OK", { enumerable: true, get: function () { return result_js_1.OK; } });
19
+ Object.defineProperty(exports, "OK_NULL", { enumerable: true, get: function () { return result_js_1.OK_NULL; } });
20
+ Object.defineProperty(exports, "OK_TRUE", { enumerable: true, get: function () { return result_js_1.OK_TRUE; } });
21
+ Object.defineProperty(exports, "OK_FALSE", { enumerable: true, get: function () { return result_js_1.OK_FALSE; } });
22
+ var stringify_error_js_1 = require("./stringify-error.cjs");
23
+ Object.defineProperty(exports, "stringifyError", { enumerable: true, get: function () { return stringify_error_js_1.stringifyError; } });
24
+ var try_js_1 = require("./try.cjs");
25
+ Object.defineProperty(exports, "xtry", { enumerable: true, get: function () { return try_js_1.xtrySync; } });