ts-data-forge 14.5.0 → 14.6.1
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.
- package/dist/array/impl/array-utils-element-access.mjs +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +3 -3
- package/dist/array/impl/array-utils-search.mjs +1 -1
- package/dist/collections/imap-mapped.mjs +5 -4
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.mjs +1 -1
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +3 -1
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/entry-point.mjs +8 -6
- package/dist/entry-point.mjs.map +1 -1
- package/dist/functional/async-result/async-result.d.mts +16 -0
- package/dist/functional/async-result/async-result.d.mts.map +1 -0
- package/dist/functional/async-result/async-result.mjs +3 -0
- package/dist/functional/async-result/async-result.mjs.map +1 -0
- package/dist/functional/async-result/impl/async-result-flat-map.d.mts +39 -0
- package/dist/functional/async-result/impl/async-result-flat-map.d.mts.map +1 -0
- package/dist/functional/async-result/impl/async-result-flat-map.mjs +25 -0
- package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -0
- package/dist/functional/async-result/impl/async-result-from-promise.d.mts +47 -0
- package/dist/functional/async-result/impl/async-result-from-promise.d.mts.map +1 -0
- package/dist/functional/async-result/impl/async-result-from-promise.mjs +11 -0
- package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -0
- package/dist/functional/async-result/impl/async-result-from-throwable.d.mts +53 -0
- package/dist/functional/async-result/impl/async-result-from-throwable.d.mts.map +1 -0
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs +17 -0
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -0
- package/dist/functional/async-result/impl/async-result-map-err.d.mts +35 -0
- package/dist/functional/async-result/impl/async-result-map-err.d.mts.map +1 -0
- package/dist/functional/async-result/impl/async-result-map-err.mjs +23 -0
- package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -0
- package/dist/functional/async-result/impl/async-result-map.d.mts +45 -0
- package/dist/functional/async-result/impl/async-result-map.d.mts.map +1 -0
- package/dist/functional/async-result/impl/async-result-map.mjs +23 -0
- package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -0
- package/dist/functional/async-result/impl/async-result-unwrap-or.d.mts +34 -0
- package/dist/functional/async-result/impl/async-result-unwrap-or.d.mts.map +1 -0
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +10 -0
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -0
- package/dist/functional/async-result/impl/index.d.mts +8 -0
- package/dist/functional/async-result/impl/index.d.mts.map +1 -0
- package/dist/functional/async-result/impl/index.mjs +7 -0
- package/dist/functional/async-result/impl/index.mjs.map +1 -0
- package/dist/functional/async-result/impl/types.d.mts +45 -0
- package/dist/functional/async-result/impl/types.d.mts.map +1 -0
- package/dist/functional/async-result/impl/types.mjs +2 -0
- package/dist/functional/async-result/impl/types.mjs.map +1 -0
- package/dist/functional/async-result/index.d.mts +2 -0
- package/dist/functional/async-result/index.d.mts.map +1 -0
- package/dist/functional/async-result/index.mjs +3 -0
- package/dist/functional/async-result/index.mjs.map +1 -0
- package/dist/functional/index.d.mts +1 -0
- package/dist/functional/index.d.mts.map +1 -1
- package/dist/functional/index.mjs +8 -6
- package/dist/functional/index.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.d.mts +5 -0
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/json/json.mjs +2 -2
- package/dist/number/enum/int8.mjs +1 -1
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/refined-number-utils.mjs +1 -1
- package/dist/object/object.mjs +1 -1
- package/package.json +7 -7
- package/src/array/impl/array-utils-length-constraint-preservation.test.mts +2 -2
- package/src/collections/imap-mapped.mts +4 -4
- package/src/collections/imap.mts +1 -1
- package/src/collections/imap.test.mts +1 -1
- package/src/collections/iset-mapped.mts +2 -1
- package/src/collections/iset.mts +1 -1
- package/src/functional/async-result/async-result.mts +17 -0
- package/src/functional/async-result/impl/async-result-flat-map.mts +99 -0
- package/src/functional/async-result/impl/async-result-from-promise.mts +69 -0
- package/src/functional/async-result/impl/async-result-from-throwable.mts +78 -0
- package/src/functional/async-result/impl/async-result-map-err.mts +84 -0
- package/src/functional/async-result/impl/async-result-map.mts +94 -0
- package/src/functional/async-result/impl/async-result-unwrap-or.mts +42 -0
- package/src/functional/async-result/impl/index.mts +7 -0
- package/src/functional/async-result/impl/types.mts +51 -0
- package/src/functional/async-result/index.mts +1 -0
- package/src/functional/async-result.test.mts +291 -0
- package/src/functional/index.mts +1 -0
- package/src/functional/optional.test.mts +2 -1
- package/src/functional/result/impl/result-from-promise.mts +5 -0
- package/src/functional/result.test.mts +0 -2
- package/src/guard/is-non-empty-string.test.mts +2 -2
- package/src/guard/is-non-null-object.test.mts +3 -3
- package/src/guard/is-primitive.test.mts +3 -3
- package/src/guard/is-type.test.mts +3 -3
- package/src/json/json.test.mts +1 -1
- package/src/number/enum/int8.mts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-from-promise.mjs","sources":["../../../../src/functional/async-result/impl/async-result-from-promise.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Converts a `Promise` into an `AsyncResult`. If the input Promise resolves,\n * the `AsyncResult` resolves to `Ok` with the resolved value. If the input\n * Promise rejects, the rejection reason is passed through `mapError` and the\n * `AsyncResult` resolves to `Err` with the mapped error.\n *\n * Passing `mapError` is what gives the error channel a concrete type `E`.\n * Omitting it carries the rejection reason through untouched, leaving the\n * error channel as `unknown` — the same contract as `Result.fromPromise`.\n *\n * @example\n *\n * ```ts\n * const resolved = await AsyncResult.fromPromise(\n * Promise.resolve('ok'),\n * (error) => `failed: ${String(error)}`,\n * );\n *\n * const rejected = await AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * (error) => (isError(error) ? error.message : 'unknown'),\n * );\n *\n * assert.deepStrictEqual(resolved, Result.ok('ok'));\n *\n * assert.deepStrictEqual(rejected, Result.err('boom'));\n *\n * // Without `mapError`, the rejection reason is carried as-is.\n * const untyped = await AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * );\n *\n * assert.isTrue(Result.isErr(untyped));\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value.\n * @param promise The Promise to convert.\n * @param mapError The function applied to the rejection reason to produce the\n * error value. Omit it to carry the rejection reason as `unknown`.\n * @returns An `AsyncResult<S, E>` that never rejects for the input Promise's\n * failure.\n */\nexport function fromPromise<S>(promise: Promise<S>): AsyncResult<S, unknown>;\n\nexport function fromPromise<S, E>(\n promise: Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E>;\n\nexport function fromPromise<S, E>(\n promise: Promise<S>,\n mapError?: (error: unknown) => E,\n): AsyncResult<S, E> | AsyncResult<S, unknown> {\n return mapError === undefined\n ? fromPromiseImpl(promise, (error: unknown) => error)\n : fromPromiseImpl(promise, mapError);\n}\n\nconst fromPromiseImpl = <S, E>(\n promise: Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E> =>\n promise\n .then((value) => Result.ok(value))\n .catch((error: unknown) => Result.err(mapError(error)));\n"],"names":["Result.ok","Result.err"],"mappings":";;;;AAqDO,SAAS,WAAA,CACd,SACA,QAAA,EAC6C;AAC7C,EAAA,OAAO,QAAA,KAAa,MAAA,GAChB,eAAA,CAAgB,OAAA,EAAS,CAAC,UAAmB,KAAK,CAAA,GAClD,eAAA,CAAgB,OAAA,EAAS,QAAQ,CAAA;AACvC;AAEA,MAAM,eAAA,GAAkB,CACtB,OAAA,EACA,QAAA,KAEA,QACG,IAAA,CAAK,CAAC,UAAUA,EAAO,CAAG,KAAK,CAAC,CAAA,CAChC,MAAM,CAAC,KAAA,KAAmBC,GAAO,CAAI,QAAA,CAAS,KAAK,CAAC,CAAC,CAAA;;;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a function returning a `Promise` in an `AsyncResult`. Both a
|
|
4
|
+
* synchronous `throw` while calling `fn` and an asynchronous rejection of the
|
|
5
|
+
* returned Promise are caught, passed through `mapError`, and carried as
|
|
6
|
+
* `Err`.
|
|
7
|
+
*
|
|
8
|
+
* Passing `mapError` is what gives the error channel a concrete type `E`.
|
|
9
|
+
* Omitting it carries the thrown value through untouched, leaving the error
|
|
10
|
+
* channel as `unknown`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const success = await AsyncResult.fromThrowable(
|
|
16
|
+
* () => Promise.resolve(2),
|
|
17
|
+
* (error) => `failed: ${String(error)}`,
|
|
18
|
+
* );
|
|
19
|
+
*
|
|
20
|
+
* const failure = await AsyncResult.fromThrowable(
|
|
21
|
+
* (): Promise<number> => {
|
|
22
|
+
* throw new Error('boom');
|
|
23
|
+
* },
|
|
24
|
+
* (error) => (isError(error) ? error.message : 'unknown'),
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* assert.deepStrictEqual(success, Result.ok(2));
|
|
28
|
+
*
|
|
29
|
+
* assert.deepStrictEqual(failure, Result.err('boom'));
|
|
30
|
+
*
|
|
31
|
+
* // Without `mapError`, the thrown value is carried as-is.
|
|
32
|
+
* const untyped = await AsyncResult.fromThrowable(
|
|
33
|
+
* (): Promise<number> => {
|
|
34
|
+
* throw new Error('boom');
|
|
35
|
+
* },
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* assert.isTrue(Result.isErr(untyped));
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @template S The type of the success value.
|
|
42
|
+
* @template E The type of the error value.
|
|
43
|
+
* @param fn The function to execute; it may throw synchronously or return a
|
|
44
|
+
* rejecting Promise.
|
|
45
|
+
* @param mapError The function applied to the thrown value or rejection
|
|
46
|
+
* reason to produce the error value. Omit it to carry the thrown value as
|
|
47
|
+
* `unknown`.
|
|
48
|
+
* @returns An `AsyncResult<S, E>` containing either the resolved value or the
|
|
49
|
+
* mapped error.
|
|
50
|
+
*/
|
|
51
|
+
export declare function fromThrowable<S>(fn: () => Promise<S>): AsyncResult<S, unknown>;
|
|
52
|
+
export declare function fromThrowable<S, E>(fn: () => Promise<S>, mapError: (error: unknown) => E): AsyncResult<S, E>;
|
|
53
|
+
//# sourceMappingURL=async-result-from-throwable.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-from-throwable.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-from-throwable.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAEhF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAChC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,GAC9B,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { err } from '../../result/impl/result-err.mjs';
|
|
2
|
+
import { ok } from '../../result/impl/result-ok.mjs';
|
|
3
|
+
import '@sindresorhus/is';
|
|
4
|
+
|
|
5
|
+
function fromThrowable(fn, mapError) {
|
|
6
|
+
return mapError === void 0 ? fromThrowableImpl(fn, (error) => error) : fromThrowableImpl(fn, mapError);
|
|
7
|
+
}
|
|
8
|
+
const fromThrowableImpl = async (fn, mapError) => {
|
|
9
|
+
try {
|
|
10
|
+
return ok(await fn());
|
|
11
|
+
} catch (error) {
|
|
12
|
+
return err(mapError(error));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { fromThrowable };
|
|
17
|
+
//# sourceMappingURL=async-result-from-throwable.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-from-throwable.mjs","sources":["../../../../src/functional/async-result/impl/async-result-from-throwable.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Wraps a function returning a `Promise` in an `AsyncResult`. Both a\n * synchronous `throw` while calling `fn` and an asynchronous rejection of the\n * returned Promise are caught, passed through `mapError`, and carried as\n * `Err`.\n *\n * Passing `mapError` is what gives the error channel a concrete type `E`.\n * Omitting it carries the thrown value through untouched, leaving the error\n * channel as `unknown`.\n *\n * @example\n *\n * ```ts\n * const success = await AsyncResult.fromThrowable(\n * () => Promise.resolve(2),\n * (error) => `failed: ${String(error)}`,\n * );\n *\n * const failure = await AsyncResult.fromThrowable(\n * (): Promise<number> => {\n * throw new Error('boom');\n * },\n * (error) => (isError(error) ? error.message : 'unknown'),\n * );\n *\n * assert.deepStrictEqual(success, Result.ok(2));\n *\n * assert.deepStrictEqual(failure, Result.err('boom'));\n *\n * // Without `mapError`, the thrown value is carried as-is.\n * const untyped = await AsyncResult.fromThrowable(\n * (): Promise<number> => {\n * throw new Error('boom');\n * },\n * );\n *\n * assert.isTrue(Result.isErr(untyped));\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value.\n * @param fn The function to execute; it may throw synchronously or return a\n * rejecting Promise.\n * @param mapError The function applied to the thrown value or rejection\n * reason to produce the error value. Omit it to carry the thrown value as\n * `unknown`.\n * @returns An `AsyncResult<S, E>` containing either the resolved value or the\n * mapped error.\n */\nexport function fromThrowable<S>(fn: () => Promise<S>): AsyncResult<S, unknown>;\n\nexport function fromThrowable<S, E>(\n fn: () => Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E>;\n\nexport function fromThrowable<S, E>(\n fn: () => Promise<S>,\n mapError?: (error: unknown) => E,\n): AsyncResult<S, E> | AsyncResult<S, unknown> {\n return mapError === undefined\n ? fromThrowableImpl(fn, (error: unknown) => error)\n : fromThrowableImpl(fn, mapError);\n}\n\nconst fromThrowableImpl = async <S, E>(\n fn: () => Promise<S>,\n mapError: (error: unknown) => E,\n): AsyncResult<S, E> => {\n try {\n return Result.ok(await fn());\n } catch (error) {\n return Result.err(mapError(error));\n }\n};\n"],"names":["Result.ok","Result.err"],"mappings":";;;;AA2DO,SAAS,aAAA,CACd,IACA,QAAA,EAC6C;AAC7C,EAAA,OAAO,QAAA,KAAa,MAAA,GAChB,iBAAA,CAAkB,EAAA,EAAI,CAAC,UAAmB,KAAK,CAAA,GAC/C,iBAAA,CAAkB,EAAA,EAAI,QAAQ,CAAA;AACpC;AAEA,MAAM,iBAAA,GAAoB,OACxB,EAAA,EACA,QAAA,KACsB;AACtB,EAAA,IAAI;AACF,IAAA,OAAOA,EAAO,CAAG,MAAM,EAAA,EAAI,CAAA;AAAA,EAC7B,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,GAAO,CAAI,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EACnC;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Maps an `AsyncResult<S, E>` to `AsyncResult<S, E2>` by applying a function
|
|
4
|
+
* to the error value. The mapping function may be synchronous or return a
|
|
5
|
+
* `Promise`; both are handled transparently. If the `AsyncResult` resolves to
|
|
6
|
+
* `Ok`, the original `Ok` is passed through and the function is not called.
|
|
7
|
+
*
|
|
8
|
+
* If `mapFn` throws or returns a rejecting Promise, the rejection propagates
|
|
9
|
+
* as-is — it is **not** caught and converted into an `Err`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const errValue = AsyncResult.fromPromise(
|
|
15
|
+
* Promise.reject(new Error('boom')),
|
|
16
|
+
* () => 'failure',
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* const uppercased = await AsyncResult.mapErr(errValue, (error) =>
|
|
20
|
+
* error.toUpperCase(),
|
|
21
|
+
* );
|
|
22
|
+
*
|
|
23
|
+
* assert.deepStrictEqual(uppercased, Result.err('FAILURE'));
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @template S The type of the success value.
|
|
27
|
+
* @template E The type of the error value of the input.
|
|
28
|
+
* @template E2 The type of the error value returned by the mapping function.
|
|
29
|
+
* @param asyncResult The `AsyncResult` to map.
|
|
30
|
+
* @param mapFn The function to apply to the error value if present.
|
|
31
|
+
* @returns A new `AsyncResult<S, E2>`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function mapErr<S, E, E2>(asyncResult: AsyncResult<S, E>, mapFn: (error: E) => E2 | Promise<E2>): AsyncResult<S, E2>;
|
|
34
|
+
export declare function mapErr<E, E2>(mapFn: (error: E) => E2 | Promise<E2>): <S>(asyncResult: AsyncResult<S, E>) => AsyncResult<S, E2>;
|
|
35
|
+
//# sourceMappingURL=async-result-map-err.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-map-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map-err.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAC7B,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,GACpC,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAQtB,wBAAgB,MAAM,CAAC,CAAC,EAAE,EAAE,EAC1B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,GACpC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { err } from '../../result/impl/result-err.mjs';
|
|
2
|
+
import { isOk } from '../../result/impl/result-is-ok.mjs';
|
|
3
|
+
import '@sindresorhus/is';
|
|
4
|
+
|
|
5
|
+
function mapErr(...args) {
|
|
6
|
+
switch (args.length) {
|
|
7
|
+
case 2: {
|
|
8
|
+
const [asyncResult, mapFn] = args;
|
|
9
|
+
return mapErrImpl(asyncResult, mapFn);
|
|
10
|
+
}
|
|
11
|
+
case 1: {
|
|
12
|
+
const [mapFn] = args;
|
|
13
|
+
return (asyncResult) => mapErrImpl(asyncResult, mapFn);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const mapErrImpl = async (asyncResult, mapFn) => {
|
|
18
|
+
const result = await asyncResult;
|
|
19
|
+
return isOk(result) ? result : err(await mapFn(result.value));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { mapErr };
|
|
23
|
+
//# sourceMappingURL=async-result-map-err.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-map-err.mjs","sources":["../../../../src/functional/async-result/impl/async-result-map-err.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Maps an `AsyncResult<S, E>` to `AsyncResult<S, E2>` by applying a function\n * to the error value. The mapping function may be synchronous or return a\n * `Promise`; both are handled transparently. If the `AsyncResult` resolves to\n * `Ok`, the original `Ok` is passed through and the function is not called.\n *\n * If `mapFn` throws or returns a rejecting Promise, the rejection propagates\n * as-is — it is **not** caught and converted into an `Err`.\n *\n * @example\n *\n * ```ts\n * const errValue = AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * () => 'failure',\n * );\n *\n * const uppercased = await AsyncResult.mapErr(errValue, (error) =>\n * error.toUpperCase(),\n * );\n *\n * assert.deepStrictEqual(uppercased, Result.err('FAILURE'));\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value of the input.\n * @template E2 The type of the error value returned by the mapping function.\n * @param asyncResult The `AsyncResult` to map.\n * @param mapFn The function to apply to the error value if present.\n * @returns A new `AsyncResult<S, E2>`.\n */\nexport function mapErr<S, E, E2>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (error: E) => E2 | Promise<E2>,\n): AsyncResult<S, E2>;\n\n// Curried version\n//\n// Unlike `Result.mapErr`, the returned function can simply be generic over\n// `S`: an `AsyncResult` is a `Promise`, not a discriminated union, so there\n// is no literal-narrowing problem that would require the whole-result\n// generic trick used by the synchronous combinators.\nexport function mapErr<E, E2>(\n mapFn: (error: E) => E2 | Promise<E2>,\n): <S>(asyncResult: AsyncResult<S, E>) => AsyncResult<S, E2>;\n\nexport function mapErr<S, E, E2>(\n ...args:\n | readonly [\n asyncResult: AsyncResult<S, E>,\n mapFn: (error: E) => E2 | Promise<E2>,\n ]\n | readonly [mapFn: (error: E) => E2 | Promise<E2>]\n):\n | AsyncResult<S, E2>\n | ((asyncResult: AsyncResult<S, E>) => AsyncResult<S, E2>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is asyncResult\n const [asyncResult, mapFn] = args;\n\n return mapErrImpl(asyncResult, mapFn);\n }\n\n case 1: {\n // Curried version: first argument is mapping function\n const [mapFn] = args;\n\n return (asyncResult: AsyncResult<S, E>) => mapErrImpl(asyncResult, mapFn);\n }\n }\n}\n\nconst mapErrImpl = async <S, E, E2>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (error: E) => E2 | Promise<E2>,\n): AsyncResult<S, E2> => {\n const result = await asyncResult;\n\n return Result.isOk(result) ? result : Result.err(await mapFn(result.value));\n};\n"],"names":["Result.isOk","Result.err"],"mappings":";;;;AAiDO,SAAS,UACX,IAAA,EAQwD;AAC3D,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,WAAA,EAAa,KAAK,CAAA,GAAI,IAAA;AAE7B,MAAA,OAAO,UAAA,CAAW,aAAa,KAAK,CAAA;AAAA,IACtC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,WAAA,KAAmC,UAAA,CAAW,WAAA,EAAa,KAAK,CAAA;AAAA,IAC1E;AAAA;AAEJ;AAEA,MAAM,UAAA,GAAa,OACjB,WAAA,EACA,KAAA,KACuB;AACvB,EAAA,MAAM,SAAS,MAAM,WAAA;AAErB,EAAA,OAAOA,IAAO,CAAK,MAAM,CAAA,GAAI,MAAA,GAASC,GAAO,CAAI,MAAM,KAAA,CAAM,MAAA,CAAO,KAAK,CAAC,CAAA;AAC5E,CAAA;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Maps an `AsyncResult<S, E>` to `AsyncResult<S2, E>` by applying a function
|
|
4
|
+
* to the success value. The mapping function may be synchronous or return a
|
|
5
|
+
* `Promise`; both are handled transparently. If the `AsyncResult` resolves to
|
|
6
|
+
* `Err`, the original `Err` is passed through and the function is not called.
|
|
7
|
+
*
|
|
8
|
+
* If `mapFn` throws or returns a rejecting Promise, the rejection propagates
|
|
9
|
+
* as-is — it is **not** caught and converted into an `Err`. `map` performs no
|
|
10
|
+
* implicit error conversion; write a fallible step as
|
|
11
|
+
* `AsyncResult.flatMap` combined with `AsyncResult.fromThrowable` instead, so
|
|
12
|
+
* that the error type stays explicit.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* const okValue = AsyncResult.fromPromise(
|
|
18
|
+
* Promise.resolve(5),
|
|
19
|
+
* () => 'failed',
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* const doubled = await AsyncResult.map(okValue, (value) => value * 2);
|
|
23
|
+
*
|
|
24
|
+
* assert.deepStrictEqual(doubled, Result.ok(10));
|
|
25
|
+
*
|
|
26
|
+
* const double = AsyncResult.map((value: number) => value * 2);
|
|
27
|
+
*
|
|
28
|
+
* const curried = await double(
|
|
29
|
+
* AsyncResult.fromPromise(Promise.resolve(21), () => 'failed'),
|
|
30
|
+
* );
|
|
31
|
+
*
|
|
32
|
+
* assert.deepStrictEqual(curried, Result.ok(42));
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @template S The type of the success value of the input.
|
|
36
|
+
* @template S2 The type of the success value returned by the mapping
|
|
37
|
+
* function.
|
|
38
|
+
* @template E The type of the error value.
|
|
39
|
+
* @param asyncResult The `AsyncResult` to map.
|
|
40
|
+
* @param mapFn The function to apply to the success value if present.
|
|
41
|
+
* @returns A new `AsyncResult<S2, E>`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function map<S, S2, E>(asyncResult: AsyncResult<S, E>, mapFn: (value: S) => Promise<S2> | S2): AsyncResult<S2, E>;
|
|
44
|
+
export declare function map<S, S2>(mapFn: (value: S) => Promise<S2> | S2): <E>(asyncResult: AsyncResult<S, E>) => AsyncResult<S2, E>;
|
|
45
|
+
//# sourceMappingURL=async-result-map.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-map.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAC1B,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GACpC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAQtB,wBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EACvB,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GACpC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isErr } from '../../result/impl/result-is-err.mjs';
|
|
2
|
+
import { ok } from '../../result/impl/result-ok.mjs';
|
|
3
|
+
import '@sindresorhus/is';
|
|
4
|
+
|
|
5
|
+
function map(...args) {
|
|
6
|
+
switch (args.length) {
|
|
7
|
+
case 2: {
|
|
8
|
+
const [asyncResult, mapFn] = args;
|
|
9
|
+
return mapImpl(asyncResult, mapFn);
|
|
10
|
+
}
|
|
11
|
+
case 1: {
|
|
12
|
+
const [mapFn] = args;
|
|
13
|
+
return (asyncResult) => mapImpl(asyncResult, mapFn);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const mapImpl = async (asyncResult, mapFn) => {
|
|
18
|
+
const result = await asyncResult;
|
|
19
|
+
return isErr(result) ? result : ok(await mapFn(result.value));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { map };
|
|
23
|
+
//# sourceMappingURL=async-result-map.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-map.mjs","sources":["../../../../src/functional/async-result/impl/async-result-map.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Maps an `AsyncResult<S, E>` to `AsyncResult<S2, E>` by applying a function\n * to the success value. The mapping function may be synchronous or return a\n * `Promise`; both are handled transparently. If the `AsyncResult` resolves to\n * `Err`, the original `Err` is passed through and the function is not called.\n *\n * If `mapFn` throws or returns a rejecting Promise, the rejection propagates\n * as-is — it is **not** caught and converted into an `Err`. `map` performs no\n * implicit error conversion; write a fallible step as\n * `AsyncResult.flatMap` combined with `AsyncResult.fromThrowable` instead, so\n * that the error type stays explicit.\n *\n * @example\n *\n * ```ts\n * const okValue = AsyncResult.fromPromise(\n * Promise.resolve(5),\n * () => 'failed',\n * );\n *\n * const doubled = await AsyncResult.map(okValue, (value) => value * 2);\n *\n * assert.deepStrictEqual(doubled, Result.ok(10));\n *\n * const double = AsyncResult.map((value: number) => value * 2);\n *\n * const curried = await double(\n * AsyncResult.fromPromise(Promise.resolve(21), () => 'failed'),\n * );\n *\n * assert.deepStrictEqual(curried, Result.ok(42));\n * ```\n *\n * @template S The type of the success value of the input.\n * @template S2 The type of the success value returned by the mapping\n * function.\n * @template E The type of the error value.\n * @param asyncResult The `AsyncResult` to map.\n * @param mapFn The function to apply to the success value if present.\n * @returns A new `AsyncResult<S2, E>`.\n */\nexport function map<S, S2, E>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (value: S) => Promise<S2> | S2,\n): AsyncResult<S2, E>;\n\n// Curried version\n//\n// Unlike `Result.map`, the returned function can simply be generic over `E`:\n// an `AsyncResult` is a `Promise`, not a discriminated union, so there is no\n// literal-narrowing problem that would require the whole-result generic\n// trick used by the synchronous combinators.\nexport function map<S, S2>(\n mapFn: (value: S) => Promise<S2> | S2,\n): <E>(asyncResult: AsyncResult<S, E>) => AsyncResult<S2, E>;\n\nexport function map<S, S2, E>(\n ...args:\n | readonly [\n asyncResult: AsyncResult<S, E>,\n mapFn: (value: S) => Promise<S2> | S2,\n ]\n | readonly [mapFn: (value: S) => Promise<S2> | S2]\n):\n | AsyncResult<S2, E>\n | ((asyncResult: AsyncResult<S, E>) => AsyncResult<S2, E>) {\n switch (args.length) {\n case 2: {\n // Direct version: first argument is asyncResult\n const [asyncResult, mapFn] = args;\n\n return mapImpl(asyncResult, mapFn);\n }\n\n case 1: {\n // Curried version\n const [mapFn] = args;\n\n return (asyncResult: AsyncResult<S, E>) => mapImpl(asyncResult, mapFn);\n }\n }\n}\n\nconst mapImpl = async <S, S2, E>(\n asyncResult: AsyncResult<S, E>,\n mapFn: (value: S) => Promise<S2> | S2,\n): AsyncResult<S2, E> => {\n const result = await asyncResult;\n\n return Result.isErr(result) ? result : Result.ok(await mapFn(result.value));\n};\n"],"names":["Result.isErr","Result.ok"],"mappings":";;;;AA2DO,SAAS,OACX,IAAA,EAQwD;AAC3D,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,WAAA,EAAa,KAAK,CAAA,GAAI,IAAA;AAE7B,MAAA,OAAO,OAAA,CAAQ,aAAa,KAAK,CAAA;AAAA,IACnC;AAAA,IAEA,KAAK,CAAA,EAAG;AAEN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,WAAA,KAAmC,OAAA,CAAQ,WAAA,EAAa,KAAK,CAAA;AAAA,IACvE;AAAA;AAEJ;AAEA,MAAM,OAAA,GAAU,OACd,WAAA,EACA,KAAA,KACuB;AACvB,EAAA,MAAM,SAAS,MAAM,WAAA;AAErB,EAAA,OAAOA,KAAO,CAAM,MAAM,CAAA,GAAI,MAAA,GAASC,EAAO,CAAG,MAAM,KAAA,CAAM,MAAA,CAAO,KAAK,CAAC,CAAA;AAC5E,CAAA;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps an `AsyncResult`, resolving to the success value or a default value
|
|
4
|
+
* if it resolves to `Err`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const okValue = AsyncResult.fromPromise(
|
|
10
|
+
* Promise.resolve(10),
|
|
11
|
+
* () => 'failed',
|
|
12
|
+
* );
|
|
13
|
+
*
|
|
14
|
+
* const errValue = AsyncResult.fromPromise(
|
|
15
|
+
* Promise.reject(new Error('boom')),
|
|
16
|
+
* () => 'failed',
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* assert.isTrue((await AsyncResult.unwrapOr(okValue, 0)) === 10);
|
|
20
|
+
*
|
|
21
|
+
* assert.isTrue((await AsyncResult.unwrapOr(errValue, 0)) === 0);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @template S The type of the success value.
|
|
25
|
+
* @template E The type of the error value.
|
|
26
|
+
* @template D The type of the default value.
|
|
27
|
+
* @param asyncResult The `AsyncResult` to unwrap.
|
|
28
|
+
* @param defaultValue The value to resolve to if `asyncResult` resolves to
|
|
29
|
+
* `Err`.
|
|
30
|
+
* @returns A Promise of the success value if `Ok`, otherwise of
|
|
31
|
+
* `defaultValue`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const unwrapOr: <S, E, D>(asyncResult: AsyncResult<S, E>, defaultValue: D) => Promise<D | S>;
|
|
34
|
+
//# sourceMappingURL=async-result-unwrap-or.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-unwrap-or.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-unwrap-or.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,QAAQ,GAAU,CAAC,EAAE,CAAC,EAAE,CAAC,eACvB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,gBAChB,CAAC,KACd,OAAO,CAAC,CAAC,GAAG,CAAC,CAIf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isOk } from '../../result/impl/result-is-ok.mjs';
|
|
2
|
+
import '@sindresorhus/is';
|
|
3
|
+
|
|
4
|
+
const unwrapOr = async (asyncResult, defaultValue) => {
|
|
5
|
+
const result = await asyncResult;
|
|
6
|
+
return isOk(result) ? result.value : defaultValue;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { unwrapOr };
|
|
10
|
+
//# sourceMappingURL=async-result-unwrap-or.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-result-unwrap-or.mjs","sources":["../../../../src/functional/async-result/impl/async-result-unwrap-or.mts"],"sourcesContent":["import { Result } from '../../result/index.mjs';\nimport { type AsyncResult } from '../async-result.mjs';\n\n/**\n * Unwraps an `AsyncResult`, resolving to the success value or a default value\n * if it resolves to `Err`.\n *\n * @example\n *\n * ```ts\n * const okValue = AsyncResult.fromPromise(\n * Promise.resolve(10),\n * () => 'failed',\n * );\n *\n * const errValue = AsyncResult.fromPromise(\n * Promise.reject(new Error('boom')),\n * () => 'failed',\n * );\n *\n * assert.isTrue((await AsyncResult.unwrapOr(okValue, 0)) === 10);\n *\n * assert.isTrue((await AsyncResult.unwrapOr(errValue, 0)) === 0);\n * ```\n *\n * @template S The type of the success value.\n * @template E The type of the error value.\n * @template D The type of the default value.\n * @param asyncResult The `AsyncResult` to unwrap.\n * @param defaultValue The value to resolve to if `asyncResult` resolves to\n * `Err`.\n * @returns A Promise of the success value if `Ok`, otherwise of\n * `defaultValue`.\n */\nexport const unwrapOr = async <S, E, D>(\n asyncResult: AsyncResult<S, E>,\n defaultValue: D,\n): Promise<D | S> => {\n const result = await asyncResult;\n\n return Result.isOk(result) ? result.value : defaultValue;\n};\n"],"names":["Result.isOk"],"mappings":";;;AAkCO,MAAM,QAAA,GAAW,OACtB,WAAA,EACA,YAAA,KACmB;AACnB,EAAA,MAAM,SAAS,MAAM,WAAA;AAErB,EAAA,OAAOA,IAAO,CAAK,MAAM,CAAA,GAAI,OAAO,KAAA,GAAQ,YAAA;AAC9C;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './async-result-flat-map.mjs';
|
|
2
|
+
export * from './async-result-from-promise.mjs';
|
|
3
|
+
export * from './async-result-from-throwable.mjs';
|
|
4
|
+
export * from './async-result-map-err.mjs';
|
|
5
|
+
export * from './async-result-map.mjs';
|
|
6
|
+
export * from './async-result-unwrap-or.mjs';
|
|
7
|
+
export * from './types.mjs';
|
|
8
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { flatMap } from './async-result-flat-map.mjs';
|
|
2
|
+
export { fromPromise } from './async-result-from-promise.mjs';
|
|
3
|
+
export { fromThrowable } from './async-result-from-throwable.mjs';
|
|
4
|
+
export { mapErr } from './async-result-map-err.mjs';
|
|
5
|
+
export { map } from './async-result-map.mjs';
|
|
6
|
+
export { unwrapOr } from './async-result-unwrap-or.mjs';
|
|
7
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Err, type Ok } from '../../../types.mjs';
|
|
2
|
+
import { type UnknownResult } from '../../result/index.mjs';
|
|
3
|
+
import { type AsyncResult } from '../async-result.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* Base type for any `AsyncResult`, used for generic constraints. Represents
|
|
6
|
+
* an `AsyncResult` with unknown success and error types.
|
|
7
|
+
*/
|
|
8
|
+
export type UnknownAsyncResult = AsyncResult<unknown, unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the success value type `S` from a `Result.Ok<S>`, or from an
|
|
11
|
+
* `AsyncResult` resolving to one. Distributes over unions, so an
|
|
12
|
+
* `Ok<S> | Err<E>` union resolves to `S`.
|
|
13
|
+
*
|
|
14
|
+
* @template R The `Result` or `AsyncResult` type to unwrap.
|
|
15
|
+
*/
|
|
16
|
+
export type UnwrapOk<R extends UnknownAsyncResult | UnknownResult> = UnwrapOkImpl<SyncResultOf<R>>;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts the error value type `E` from a `Result.Err<E>`, or from an
|
|
19
|
+
* `AsyncResult` resolving to one. Distributes over unions, so an
|
|
20
|
+
* `Ok<S> | Err<E>` union resolves to `E`.
|
|
21
|
+
*
|
|
22
|
+
* @template R The `Result` or `AsyncResult` type to unwrap.
|
|
23
|
+
*/
|
|
24
|
+
export type UnwrapErr<R extends UnknownAsyncResult | UnknownResult> = UnwrapErrImpl<SyncResultOf<R>>;
|
|
25
|
+
/**
|
|
26
|
+
* @template R The `Result` or `AsyncResult` type.
|
|
27
|
+
* @internal
|
|
28
|
+
* Resolves an `AsyncResult` to its `Result`, leaving a plain `Result`
|
|
29
|
+
* unchanged. Distributive.
|
|
30
|
+
*/
|
|
31
|
+
type SyncResultOf<R> = R extends Promise<infer P> ? P : R;
|
|
32
|
+
/**
|
|
33
|
+
* @template R The `Result` type to unwrap.
|
|
34
|
+
* @internal
|
|
35
|
+
* Distributive extraction of the `Ok` value type.
|
|
36
|
+
*/
|
|
37
|
+
type UnwrapOkImpl<R> = R extends Ok<infer S> ? S : never;
|
|
38
|
+
/**
|
|
39
|
+
* @template R The `Result` type to unwrap.
|
|
40
|
+
* @internal
|
|
41
|
+
* Distributive extraction of the `Err` value type.
|
|
42
|
+
*/
|
|
43
|
+
type UnwrapErrImpl<R> = R extends Err<infer E> ? E : never;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/types.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,kBAAkB,GAAG,aAAa,IAC/D,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,kBAAkB,GAAG,aAAa,IAChE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjC;;;;;GAKG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE1D;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzD;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/functional/async-result/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/functional/index.mts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/functional/index.mts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import * as index from './async-result/impl/index.mjs';
|
|
2
|
+
export { index as AsyncResult };
|
|
1
3
|
export { match } from './match.mjs';
|
|
2
|
-
import * as index from './optional/impl/index.mjs';
|
|
3
|
-
export { index as Optional };
|
|
4
|
+
import * as index$1 from './optional/impl/index.mjs';
|
|
5
|
+
export { index$1 as Optional };
|
|
4
6
|
export { pipe } from './pipe.mjs';
|
|
5
|
-
import * as index$
|
|
6
|
-
export { index$
|
|
7
|
-
import * as index$
|
|
8
|
-
export { index$
|
|
7
|
+
import * as index$2 from './result/impl/index.mjs';
|
|
8
|
+
export { index$2 as Result };
|
|
9
|
+
import * as index$3 from './ternary-result/impl/index.mjs';
|
|
10
|
+
export { index$3 as TernaryResult };
|
|
9
11
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -11,6 +11,11 @@ type UnwrapPromise<P extends Promise<unknown>> = P extends Promise<infer V> ? V
|
|
|
11
11
|
* input Promise rejects, the `Result` will be `Err` with the rejection
|
|
12
12
|
* reason.
|
|
13
13
|
*
|
|
14
|
+
* The error channel is `unknown`, since the rejection reason is carried
|
|
15
|
+
* through untouched. For a concrete error type, use `AsyncResult.fromPromise`
|
|
16
|
+
* with a `mapError` function; called without one it behaves exactly as this
|
|
17
|
+
* function does.
|
|
18
|
+
*
|
|
14
19
|
* @example
|
|
15
20
|
*
|
|
16
21
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-from-promise.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,IAC3C,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"result-from-promise.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,IAC3C,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,WAC3C,CAAC,KACT,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAEmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-from-promise.mjs","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"sourcesContent":["import { type Ok } from '../../../types.mjs';\nimport { type Result } from '../result.mjs';\nimport { err } from './result-err.mjs';\nimport { ok } from './result-ok.mjs';\n\n/**\n * @template P The Promise type.\n * @internal\n * Utility type to extract the resolved value type from a Promise.\n */\ntype UnwrapPromise<P extends Promise<unknown>> =\n P extends Promise<infer V> ? V : never;\n\n/**\n * Converts a Promise into a Promise that resolves to a `Result`. If the input\n * Promise resolves, the `Result` will be `Ok` with the resolved value. If the\n * input Promise rejects, the `Result` will be `Err` with the rejection\n * reason.\n *\n * @example\n *\n * ```ts\n * const successPromise = Result.fromPromise(Promise.resolve('ok'));\n *\n * const failurePromise = Result.fromPromise(\n * Promise.reject(new Error('fail')),\n * );\n *\n * const resolved = await successPromise;\n *\n * const rejected = await failurePromise;\n *\n * assert.deepStrictEqual(resolved, Result.ok('ok'));\n *\n * assert.isTrue(Result.isErr(rejected));\n * ```\n *\n * @template P The type of the input Promise.\n * @param promise The Promise to convert.\n * @returns A Promise that resolves to `Result<UnwrapPromise<P>, unknown>`.\n */\nexport const fromPromise = <P extends Promise<unknown>>(\n promise: P,\n): Promise<Result<UnwrapPromise<P>, unknown>> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n promise.then((v) => ok(v) as Ok<UnwrapPromise<P>>).catch(err);\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"result-from-promise.mjs","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"sourcesContent":["import { type Ok } from '../../../types.mjs';\nimport { type Result } from '../result.mjs';\nimport { err } from './result-err.mjs';\nimport { ok } from './result-ok.mjs';\n\n/**\n * @template P The Promise type.\n * @internal\n * Utility type to extract the resolved value type from a Promise.\n */\ntype UnwrapPromise<P extends Promise<unknown>> =\n P extends Promise<infer V> ? V : never;\n\n/**\n * Converts a Promise into a Promise that resolves to a `Result`. If the input\n * Promise resolves, the `Result` will be `Ok` with the resolved value. If the\n * input Promise rejects, the `Result` will be `Err` with the rejection\n * reason.\n *\n * The error channel is `unknown`, since the rejection reason is carried\n * through untouched. For a concrete error type, use `AsyncResult.fromPromise`\n * with a `mapError` function; called without one it behaves exactly as this\n * function does.\n *\n * @example\n *\n * ```ts\n * const successPromise = Result.fromPromise(Promise.resolve('ok'));\n *\n * const failurePromise = Result.fromPromise(\n * Promise.reject(new Error('fail')),\n * );\n *\n * const resolved = await successPromise;\n *\n * const rejected = await failurePromise;\n *\n * assert.deepStrictEqual(resolved, Result.ok('ok'));\n *\n * assert.isTrue(Result.isErr(rejected));\n * ```\n *\n * @template P The type of the input Promise.\n * @param promise The Promise to convert.\n * @returns A Promise that resolves to `Result<UnwrapPromise<P>, unknown>`.\n */\nexport const fromPromise = <P extends Promise<unknown>>(\n promise: P,\n): Promise<Result<UnwrapPromise<P>, unknown>> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n promise.then((v) => ok(v) as Ok<UnwrapPromise<P>>).catch(err);\n"],"names":[],"mappings":";;;AA8CO,MAAM,cAAc,CACzB,OAAA;AAAA;AAAA,EAGA,OAAA,CAAQ,KAAK,CAAC,CAAA,KAAM,GAAG,CAAC,CAAyB,CAAA,CAAE,KAAA,CAAM,GAAG;AAAA;;;;"}
|
package/dist/json/json.mjs
CHANGED
|
@@ -34,13 +34,13 @@ import '../number/enum/int8.mjs';
|
|
|
34
34
|
import '../number/enum/uint8.mjs';
|
|
35
35
|
import '../number/num.mjs';
|
|
36
36
|
import '../number/refined-number-utils.mjs';
|
|
37
|
-
import { isRecord } from '../guard/is-record.mjs';
|
|
38
|
-
import { pipe } from '../functional/pipe.mjs';
|
|
39
37
|
import { err } from '../functional/result/impl/result-err.mjs';
|
|
40
38
|
import { ok } from '../functional/result/impl/result-ok.mjs';
|
|
39
|
+
import { isRecord } from '../guard/is-record.mjs';
|
|
41
40
|
import '@sindresorhus/is';
|
|
42
41
|
import { castMutable } from '../others/cast-mutable.mjs';
|
|
43
42
|
import { unknownToString } from '../others/unknown-to-string.mjs';
|
|
43
|
+
import { pipe } from '../functional/pipe.mjs';
|
|
44
44
|
import '../collections/imap-mapped.mjs';
|
|
45
45
|
import '../collections/imap.mjs';
|
|
46
46
|
import '../collections/iset-mapped.mjs';
|
|
@@ -21,7 +21,7 @@ const castType = (x) => (
|
|
|
21
21
|
);
|
|
22
22
|
const fromNumber = (a) => castType(fromNumberImpl(a));
|
|
23
23
|
const abs = (x) => (
|
|
24
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
24
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion, @typescript-eslint/no-unnecessary-type-assertion -- unnecessary only under the strict standard library; the stock one types `Math.abs` as returning `number`
|
|
25
25
|
Math.abs(x)
|
|
26
26
|
);
|
|
27
27
|
const min_ = (...values) => castType(Math.min(...values));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int8.mjs","sources":["../../../src/number/enum/int8.mts"],"sourcesContent":["import {\n type AbsoluteValue,\n type Int16,\n type StrictExclude,\n type Int8 as TtfImported_Int8,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Int8 = TtfImported_Int8;\n\nconst typeNameInMessage = 'an integer in [-128, 127]';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n fromNumber: fromNumberImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n Int16,\n -128,\n 127\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: -128,\n MAX_VALUE: 127,\n typeNameInMessage,\n} as const);\n\nconst is = (x: number): x is Int8 => isImpl(x);\n\nconst castType = (x: number): Int8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Int8;\n\nconst fromNumber = (a: number): Int8 => castType(fromNumberImpl(a));\n\nconst abs = <N extends Int8>(x: N): AbsoluteValue<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
1
|
+
{"version":3,"file":"int8.mjs","sources":["../../../src/number/enum/int8.mts"],"sourcesContent":["import {\n type AbsoluteValue,\n type Int16,\n type StrictExclude,\n type Int8 as TtfImported_Int8,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type Int8 = TtfImported_Int8;\n\nconst typeNameInMessage = 'an integer in [-128, 127]';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n castType: castTypeImpl,\n fromNumber: fromNumberImpl,\n is: isImpl,\n random: randomImpl,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n Int16,\n -128,\n 127\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: -128,\n MAX_VALUE: 127,\n typeNameInMessage,\n} as const);\n\nconst is = (x: number): x is Int8 => isImpl(x);\n\nconst castType = (x: number): Int8 =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n castTypeImpl(x) as Int8;\n\nconst fromNumber = (a: number): Int8 => castType(fromNumberImpl(a));\n\nconst abs = <N extends Int8>(x: N): AbsoluteValue<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, @typescript-eslint/no-unnecessary-type-assertion -- unnecessary only under the strict standard library; the stock one types `Math.abs` as returning `number`\n Math.abs(x) as unknown as AbsoluteValue<N>;\n\nconst min_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.min(...values));\n\nconst max_ = (...values: readonly Int8[]): Int8 =>\n castType(Math.max(...values));\n\nconst pow = (x: Int8, y: Int8): Int8 => fromNumber(x ** y);\n\nconst add = (x: Int8, y: Int8): Int8 => fromNumber(x + y);\n\nconst sub = (x: Int8, y: Int8): Int8 => fromNumber(x - y);\n\nconst mul = (x: Int8, y: Int8): Int8 => fromNumber(x * y);\n\nconst div = (x: Int8, y: StrictExclude<Int8, 0>): Int8 =>\n fromNumber(Math.floor(x / y));\n\nconst random = (min: Int8, max: Int8): Int8 =>\n castType(randomImpl(castTypeImpl(min), castTypeImpl(max)));\n\n/**\n * Type guard that checks if a value is an integer in [-128, 127].\n *\n * Returns `true` for an integer in [-128, 127] — a value with no fractional\n * component.\n *\n * @param value - The value to check\n * @returns `true` if the value is an integer in [-128, 127], `false` otherwise\n */\nexport const isInt8 = is;\n\n/**\n * Casts a `number` to the `Int8` branded type.\n *\n * Validates that the value is an integer in [-128, 127] and returns it with the\n * `Int8` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as an `Int8`\n * @throws {TypeError} If the value is not an integer in [-128, 127]\n */\nexport const asInt8 = castType;\n\n/**\n * Namespace providing type-safe operations for the `Int8` branded type.\n *\n * The `Int8` type represents an integer in [-128, 127]. Division (`div`) uses\n * floor division.\n */\nexport const Int8 = {\n /**\n * Type guard that checks if a value is an integer in [-128, 127].\n *\n * @param value - The value to check\n * @returns `true` if the value is an integer in [-128, 127], `false` otherwise\n * @see {@link isInt8} for usage examples\n */\n is,\n\n /**\n * The smallest value representable as `Int8` (the lower saturation target of\n * `fromNumber`).\n */\n MIN_VALUE,\n\n /**\n * The largest value representable as `Int8` (the upper saturation target of\n * `fromNumber`).\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given integers.\n *\n * @param values - The integers to compare (at least one required)\n * @returns The smallest value as an `Int8`\n */\n min: min_,\n\n /**\n * Returns the largest of the given integers.\n *\n * @param values - The integers to compare (at least one required)\n * @returns The largest value as an `Int8`\n */\n max: max_,\n\n /**\n * Converts an arbitrary `number` into an `Int8`, rounding to the nearest\n * integer and saturating the result into the range `[MIN_VALUE, MAX_VALUE]`.\n *\n * Unlike `asInt8`, this is total: out-of-range inputs are clamped to the\n * nearest representable `Int8` instead of throwing.\n *\n * @param value - The value to convert\n * @returns The value as an `Int8`\n */\n fromNumber,\n\n /**\n * Returns the absolute value of an integer in [-128, 127].\n *\n * The result is non-negative and keeps the `Int8` brand.\n *\n * @param a - The integer value\n * @returns The absolute value as a non-negative `Int8`\n */\n abs,\n\n /**\n * Generates a random `Int8` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `Int8` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as an `Int8` (floored to an\n * integer).\n *\n * @param a - The base integer\n * @param b - The exponent integer\n * @returns `a ** b` as an `Int8`\n */\n pow,\n\n /**\n * Adds two integers, returning `a + b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The sum of `a` and `b` as an `Int8`\n */\n add,\n\n /**\n * Subtracts two integers, returning `a - b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The difference of `a` and `b` as an `Int8`\n */\n sub,\n\n /**\n * Multiplies two integers, returning `a * b` as an `Int8`.\n *\n * @param a - The first integer\n * @param b - The second integer\n * @returns The product of `a` and `b` as an `Int8`\n */\n mul,\n\n /**\n * Divides two integers using floor division (`⌊a / b⌋`): the result is `a /\n * b` rounded toward negative infinity, as an `Int8`.\n *\n * @param a - The dividend\n * @param b - The divisor (must be non-zero)\n * @returns The floored quotient as an `Int8`\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof Int8,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n Int16,\n 'int' | 'range'\n >\n>('=');\n"],"names":[],"mappings":";;AAWA,MAAM,iBAAA,GAAoB,2BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,UAAA,EAAY,cAAA;AAAA,EACZ,EAAA,EAAI,MAAA;AAAA,EACJ,MAAA,EAAQ;AACV,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,IAAA;AAAA,EACX,SAAA,EAAW,GAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,EAAA,GAAK,CAAC,CAAA,KAAyB,MAAA,CAAO,CAAC,CAAA;AAE7C,MAAM,WAAW,CAAC,CAAA;AAAA;AAAA,EAEhB,aAAa,CAAC;AAAA,CAAA;AAEhB,MAAM,aAAa,CAAC,CAAA,KAAoB,QAAA,CAAS,cAAA,CAAe,CAAC,CAAC,CAAA;AAElE,MAAM,MAAM,CAAiB,CAAA;AAAA;AAAA,EAE3B,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA;AAEZ,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,IAAA,GAAO,IAAI,MAAA,KACf,QAAA,CAAS,KAAK,GAAA,CAAI,GAAG,MAAM,CAAC,CAAA;AAE9B,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,UAAA,CAAW,KAAK,CAAC,CAAA;AAEzD,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,UAAA,CAAW,IAAI,CAAC,CAAA;AAExD,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,UAAA,CAAW,IAAI,CAAC,CAAA;AAExD,MAAM,MAAM,CAAC,CAAA,EAAS,CAAA,KAAkB,UAAA,CAAW,IAAI,CAAC,CAAA;AAExD,MAAM,GAAA,GAAM,CAAC,CAAA,EAAS,CAAA,KACpB,WAAW,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,CAAC,CAAC,CAAA;AAE9B,MAAM,MAAA,GAAS,CAAC,GAAA,EAAW,GAAA,KACzB,QAAA,CAAS,UAAA,CAAW,YAAA,CAAa,GAAG,CAAA,EAAG,YAAA,CAAa,GAAG,CAAC,CAAC,CAAA;AAWpD,MAAM,MAAA,GAAS;AAYf,MAAM,MAAA,GAAS;AAQf,MAAM,IAAA,GAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYL,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
|
package/dist/object/object.mjs
CHANGED
|
@@ -34,9 +34,9 @@ import '../number/enum/int8.mjs';
|
|
|
34
34
|
import '../number/enum/uint8.mjs';
|
|
35
35
|
import '../number/num.mjs';
|
|
36
36
|
import '../number/refined-number-utils.mjs';
|
|
37
|
+
import { isSome } from '../functional/optional/impl/optional-is-some.mjs';
|
|
37
38
|
import { hasKey } from '../guard/has-key.mjs';
|
|
38
39
|
import { isRecord } from '../guard/is-record.mjs';
|
|
39
|
-
import { isSome } from '../functional/optional/impl/optional-is-some.mjs';
|
|
40
40
|
import '@sindresorhus/is';
|
|
41
41
|
import { isNonEmpty } from '../array/impl/array-utils-length-bounded-array-guard.mjs';
|
|
42
42
|
import '../collections/imap-mapped.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-data-forge",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.6.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -46,20 +46,20 @@
|
|
|
46
46
|
"@types/react": "19.2.18",
|
|
47
47
|
"@vitest/browser-playwright": "4.1.11",
|
|
48
48
|
"dedent": "1.7.2",
|
|
49
|
-
"eslint-config-typed": "5.10.
|
|
50
|
-
"eslint-plugin-ts-fortress": "1.0.
|
|
51
|
-
"eslint-plugin-ts-type-forge": "0.7.
|
|
49
|
+
"eslint-config-typed": "5.10.1",
|
|
50
|
+
"eslint-plugin-ts-fortress": "1.0.6",
|
|
51
|
+
"eslint-plugin-ts-type-forge": "0.7.2",
|
|
52
52
|
"immer": "11.1.18",
|
|
53
53
|
"playwright": "1.62.1",
|
|
54
54
|
"prettier": "3.9.6",
|
|
55
55
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
56
56
|
"prettier-plugin-packagejson": "3.0.2",
|
|
57
57
|
"react": "19.2.8",
|
|
58
|
-
"rollup": "4.62.
|
|
59
|
-
"ts-repo-utils": "10.
|
|
58
|
+
"rollup": "4.62.5",
|
|
59
|
+
"ts-repo-utils": "10.4.0",
|
|
60
60
|
"typedoc": "0.28.20",
|
|
61
61
|
"typedoc-github-theme": "0.4.0",
|
|
62
|
-
"vite": "8.2.
|
|
62
|
+
"vite": "8.2.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"typescript": ">=4.8"
|