@rzl-zone/utils-js 3.1.3-beta.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -32
- package/dist/NumberRangeUnion-B6bhM2s7.d.ts +33 -0
- package/dist/{any-BmdI8UbK.d.ts → any-v4TsK9ES.d.ts} +25 -26
- package/dist/{arrays-normalize-recursive-CnjYJ9xg.d.ts → arrays-normalize-recursive-BqmVuFlD.d.ts} +20 -20
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +96 -70
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-2CQX5CBG.js +1 -0
- package/dist/chunk-2IOOEY45.cjs +1 -0
- package/dist/chunk-3IBQ5MOM.js +1 -0
- package/dist/chunk-3VA554KW.js +1 -0
- package/dist/chunk-5757UBXJ.cjs +1 -0
- package/dist/chunk-5IGC6PBH.js +1 -0
- package/dist/chunk-5KJFVIQT.cjs +1 -0
- package/dist/chunk-6JFCSH7J.js +1 -0
- package/dist/chunk-6JFZL7YE.cjs +1 -0
- package/dist/chunk-7ODAAXX5.cjs +1 -0
- package/dist/chunk-BAV5T2E3.cjs +1 -0
- package/dist/chunk-CAH33WOQ.cjs +1 -0
- package/dist/chunk-CKTLUNWX.js +1 -0
- package/dist/chunk-CMW2TBOQ.js +1 -0
- package/dist/chunk-D3ENH7H6.cjs +1 -0
- package/dist/chunk-DEZZUYE2.js +1 -0
- package/dist/chunk-DVMHRLKP.cjs +1 -0
- package/dist/chunk-DWF2R5GD.cjs +1 -0
- package/dist/chunk-E55EQK2U.cjs +1 -0
- package/dist/chunk-E74U6CYP.cjs +1 -0
- package/dist/chunk-EL6A35UR.cjs +1 -0
- package/dist/chunk-F6IPNNSJ.cjs +1 -0
- package/dist/chunk-FJZGG54N.cjs +1 -0
- package/dist/chunk-FWCKOJZM.js +1 -0
- package/dist/chunk-FWHNWL2P.cjs +1 -0
- package/dist/chunk-GGEADHZO.js +1 -0
- package/dist/chunk-GQR4R5WY.js +1 -0
- package/dist/chunk-H66AC7GK.cjs +1 -0
- package/dist/chunk-HQWOFR56.cjs +1 -0
- package/dist/chunk-HYRQMTRH.cjs +1 -0
- package/dist/chunk-IRFL4MAX.js +1 -0
- package/dist/chunk-IVL7CKVH.cjs +1 -0
- package/dist/chunk-IZPBKKPO.js +1 -0
- package/dist/chunk-JBQMXC5I.cjs +1 -0
- package/dist/chunk-JEQEF5WD.js +1 -0
- package/dist/chunk-JMJQCN74.js +1 -0
- package/dist/chunk-JYQTCICM.js +1 -0
- package/dist/chunk-KHO2SBNA.cjs +1 -0
- package/dist/chunk-KVAL5PAG.cjs +1 -0
- package/dist/chunk-L5RDAVVH.js +1 -0
- package/dist/chunk-LS6U7FAY.cjs +1 -0
- package/dist/chunk-NBZWMBO6.js +1 -0
- package/dist/chunk-NRF6LWBC.cjs +1 -0
- package/dist/chunk-OI5XKNZO.js +1 -0
- package/dist/chunk-ONZFBJVW.js +1 -0
- package/dist/chunk-OYTYSY7G.js +1 -0
- package/dist/chunk-PET42Z7W.js +1 -0
- package/dist/chunk-PZQ6I4JJ.cjs +1 -0
- package/dist/chunk-QBKAEVYG.js +1 -0
- package/dist/chunk-QNKGP5DY.js +1 -0
- package/dist/chunk-RIPKY4RU.js +1 -0
- package/dist/chunk-RZW35UN5.cjs +1 -0
- package/dist/chunk-SBFNXGTJ.js +1 -0
- package/dist/chunk-SBKGWRS5.js +1 -0
- package/dist/chunk-SIM77PU4.js +1 -0
- package/dist/chunk-T2T7K3KR.js +1 -0
- package/dist/chunk-T7PU2V7X.cjs +1 -0
- package/dist/chunk-UDA26MCU.cjs +1 -0
- package/dist/chunk-V45XJKHW.cjs +1 -0
- package/dist/chunk-VJDDGRIK.cjs +1 -0
- package/dist/chunk-W2WNBUDE.js +1 -0
- package/dist/chunk-WVSPXFTY.js +1 -0
- package/dist/chunk-XABCB3Y7.cjs +1 -0
- package/dist/chunk-XEDXFSGI.js +1 -0
- package/dist/chunk-YKPSRP5G.js +1 -0
- package/dist/chunk-YLA3DURS.cjs +1 -0
- package/dist/chunk-YWHHVDT4.js +1 -0
- package/dist/chunk-ZETAZZLD.cjs +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +515 -321
- package/dist/conversions/index.js +1 -1
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +25 -20
- package/dist/events/index.js +1 -1
- package/dist/{extends-Bk_SBGdT.d.ts → extends-DtdRjDyU.d.ts} +63 -87
- package/dist/formatters/index.cjs +1 -0
- package/dist/formatters/index.d.ts +2106 -0
- package/dist/formatters/index.js +1 -0
- package/dist/generators/index.cjs +1 -0
- package/dist/{generator → generators}/index.d.ts +57 -59
- package/dist/generators/index.js +1 -0
- package/dist/{if-CvT4R7Kh.d.ts → if-ChM35c_q.d.ts} +6 -5
- package/dist/{is-array--YjXV-Wx.d.ts → is-array-BJeHxPM3.d.ts} +287 -542
- package/dist/{isPlainObject-BVhBAPHX.d.ts → isPlainObject-DGJkcFYw.d.ts} +6 -6
- package/dist/{never-BfayMBF9.d.ts → never-D89PbPh5.d.ts} +10 -19
- package/dist/next/index.cjs +1 -8
- package/dist/next/index.d.ts +15 -12
- package/dist/next/index.js +1 -8
- package/dist/next/server/index.cjs +1 -2
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +1 -2
- package/dist/{nils-DMz3kU7M.d.ts → nils-CO8zLHSB.d.ts} +39 -65
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +4 -4
- package/dist/operations/index.js +1 -1
- package/dist/or-C6qzKt2I.d.ts +82 -0
- package/dist/override-CL2olHE5.d.ts +59 -0
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.js +1 -1
- package/dist/pick-BSMX6Xe2.d.ts +15 -0
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +425 -106
- package/dist/predicates/index.js +1 -1
- package/dist/prettify-3o8_Kw6b.d.ts +564 -0
- package/dist/promises/index.cjs +1 -0
- package/dist/promises/index.d.ts +107 -0
- package/dist/promises/index.js +1 -0
- package/dist/promises-LU7K00H0.d.ts +72 -0
- package/dist/rzl-utils.global.js +1 -4
- package/dist/{string-XA-til3C.d.ts → string-B1jlOnws.d.ts} +82 -121
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +209 -210
- package/dist/strings/index.js +1 -1
- package/dist/tailwind/index.cjs +1 -0
- package/dist/tailwind/index.d.ts +571 -0
- package/dist/tailwind/index.js +1 -0
- package/dist/types/index.d.ts +899 -1181
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +113 -108
- package/dist/urls/index.js +1 -1
- package/package.json +45 -47
- package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +0 -26
- package/dist/chunk-26W3VZIK.cjs +0 -1
- package/dist/chunk-2KRCHXFG.cjs +0 -2
- package/dist/chunk-33ZLH266.js +0 -1
- package/dist/chunk-4L4EJTNZ.js +0 -1
- package/dist/chunk-56QBKKRE.js +0 -1
- package/dist/chunk-5Q37AP7P.js +0 -1
- package/dist/chunk-5SZUSNGZ.js +0 -1
- package/dist/chunk-7CHFAMS2.js +0 -1
- package/dist/chunk-7MMJZ6HS.js +0 -1
- package/dist/chunk-7TC6DE3J.cjs +0 -1
- package/dist/chunk-7VX33E3V.js +0 -1
- package/dist/chunk-7YWAQOA4.cjs +0 -1
- package/dist/chunk-BEZPD44N.cjs +0 -1
- package/dist/chunk-BI263OHW.js +0 -1
- package/dist/chunk-CII6WWLO.cjs +0 -1
- package/dist/chunk-D5TYPCWU.cjs +0 -1
- package/dist/chunk-EEQY5QUG.js +0 -1
- package/dist/chunk-ELDDNERR.js +0 -1
- package/dist/chunk-ESJYBIYH.js +0 -1
- package/dist/chunk-EWYPSKKM.js +0 -1
- package/dist/chunk-EXCOQLWX.cjs +0 -1
- package/dist/chunk-FIEZKTAZ.cjs +0 -1
- package/dist/chunk-FWQVTMYA.cjs +0 -1
- package/dist/chunk-G4EWCRKS.js +0 -1
- package/dist/chunk-G5LXIEFO.js +0 -0
- package/dist/chunk-G7R5XZRM.cjs +0 -1
- package/dist/chunk-GGEV7LXX.cjs +0 -1
- package/dist/chunk-HJOZOENU.cjs +0 -1
- package/dist/chunk-IRDZVLNZ.cjs +0 -1
- package/dist/chunk-IW73G523.cjs +0 -1
- package/dist/chunk-IY5OZAB3.cjs +0 -1
- package/dist/chunk-J4NCYYGS.js +0 -1
- package/dist/chunk-J7JAZAJD.js +0 -1
- package/dist/chunk-JYNSO7ZY.js +0 -1
- package/dist/chunk-K3UVKYEU.js +0 -1
- package/dist/chunk-LQ76EDZG.js +0 -1
- package/dist/chunk-MMSYCIJ2.cjs +0 -1
- package/dist/chunk-MROH35V3.cjs +0 -1
- package/dist/chunk-NJSAV73S.js +0 -1
- package/dist/chunk-NNM7QCNB.js +0 -1
- package/dist/chunk-NR44SNYE.js +0 -1
- package/dist/chunk-NXMTWY77.js +0 -1
- package/dist/chunk-OZCQZO2V.cjs +0 -4
- package/dist/chunk-PUQXRLZH.cjs +0 -1
- package/dist/chunk-Q3NTKN5I.cjs +0 -1
- package/dist/chunk-QDNSC57Z.js +0 -4
- package/dist/chunk-QGXTL5ZH.js +0 -2
- package/dist/chunk-QSQDP7L2.cjs +0 -1
- package/dist/chunk-RV2VULM7.cjs +0 -1
- package/dist/chunk-S5M33A4O.js +0 -1
- package/dist/chunk-SGTHOQQ2.js +0 -1
- package/dist/chunk-SL3RQOWA.js +0 -1
- package/dist/chunk-SW6HYEW7.cjs +0 -1
- package/dist/chunk-SYJC7UAW.js +0 -1
- package/dist/chunk-SZPWZZYG.cjs +0 -1
- package/dist/chunk-UA4B7JBO.cjs +0 -1
- package/dist/chunk-UQDJF5RR.cjs +0 -1
- package/dist/chunk-UTQUYABU.cjs +0 -1
- package/dist/chunk-VPW3DRV5.js +0 -1
- package/dist/chunk-W32WALNU.js +0 -1
- package/dist/chunk-XGZ6K753.cjs +0 -1
- package/dist/chunk-YFTR64N5.cjs +0 -1
- package/dist/chunk-ZFDS7W6B.cjs +0 -1
- package/dist/chunk-ZQOLZE6Z.cjs +0 -1
- package/dist/env/index.cjs +0 -1
- package/dist/env/index.d.ts +0 -16
- package/dist/env/index.js +0 -1
- package/dist/formatting/index.cjs +0 -1
- package/dist/formatting/index.d.ts +0 -950
- package/dist/formatting/index.js +0 -1
- package/dist/generator/index.cjs +0 -1
- package/dist/generator/index.js +0 -1
- package/dist/omit-VvmIsZmX.d.ts +0 -28
- package/dist/prettify-C4xLcYOP.d.ts +0 -353
- package/dist/promise/index.cjs +0 -1
- package/dist/promise/index.d.ts +0 -31
- package/dist/promise/index.js +0 -1
- package/dist/stylings/index.cjs +0 -1
- package/dist/stylings/index.d.ts +0 -41
- package/dist/stylings/index.js +0 -1
- package/dist/type-data-DDs-u2kq.d.ts +0 -261
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import{C as CustomPromiseType}from'../promises-LU7K00H0.js';
|
|
2
|
+
/** -------------------------------------------------------------
|
|
3
|
+
* * ***Utility Class: `CustomPromise`.***
|
|
4
|
+
* -------------------------------------------------------------
|
|
5
|
+
* **A strongly typed extension of the native {@link Promise | **`Promise`**}.**
|
|
6
|
+
* 1. **Behaves exactly like a normal Promise** for `then`/`catch`
|
|
7
|
+
* and `await` semantics.
|
|
8
|
+
* 2. **Stores the final resolution or rejection internally** so
|
|
9
|
+
* it can be retrieved by a custom `finish` handler.
|
|
10
|
+
* 3. **Adds a `finish` method** which runs once after settlement
|
|
11
|
+
* with access to both the fulfilled value *and* the rejection
|
|
12
|
+
* reason (only one will be defined).
|
|
13
|
+
* - **Key Differences from a Native `Promise`:**
|
|
14
|
+
* - Every call to `then`/`catch` returns **`CustomPromise`**
|
|
15
|
+
* again, so the `finish` method remains available on the
|
|
16
|
+
* entire chain.
|
|
17
|
+
* - `finish` provides a tuple-like callback:
|
|
18
|
+
* - `val` → defined when fulfilled.
|
|
19
|
+
* - `err` → defined when rejected.
|
|
20
|
+
* @template Success Type of the resolved value.
|
|
21
|
+
* @template Error Type of the rejection reason (default `unknown`).
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import type { CustomPromiseType } from "@rzl-zone/types";
|
|
25
|
+
* import { CustomPromise } from "@rzl-zone/promises";
|
|
26
|
+
*
|
|
27
|
+
* type User = { id: number; name: string };
|
|
28
|
+
* type ApiError = { message: string };
|
|
29
|
+
*
|
|
30
|
+
* function fetchUser(): CustomPromiseType<User, ApiError> {
|
|
31
|
+
* return new CustomPromise<User, ApiError>((resolve, reject) => {
|
|
32
|
+
* setTimeout(
|
|
33
|
+
* () =>
|
|
34
|
+
* void (Math.random() > 0.5
|
|
35
|
+
* ? resolve({ id: 1, name: "Alice" })
|
|
36
|
+
* : reject({ message: "Random failure" })),
|
|
37
|
+
* 500
|
|
38
|
+
* );
|
|
39
|
+
* });
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* fetchUser()
|
|
43
|
+
* .then(user => {
|
|
44
|
+
* console.log("SUCCESS:", user);
|
|
45
|
+
* return user;
|
|
46
|
+
* })
|
|
47
|
+
* .catch(err => {
|
|
48
|
+
* console.error("ERROR:", err);
|
|
49
|
+
* throw err;
|
|
50
|
+
* })
|
|
51
|
+
* .finish((val, err) => {
|
|
52
|
+
* // Runs once after settle, regardless of outcome
|
|
53
|
+
* console.log("FINISH:", { val, err });
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
* ---
|
|
57
|
+
* - **Implementation Notes:**
|
|
58
|
+
* - Uses `Object.setPrototypeOf` to preserve the prototype chain
|
|
59
|
+
* for environments targeting ES5 or when subclassing Promise.
|
|
60
|
+
* - Internal `_value` and `_error` are updated as soon as the
|
|
61
|
+
* executor resolves or rejects, guaranteeing `finish` receives
|
|
62
|
+
* the final state even when added after settlement.
|
|
63
|
+
*/
|
|
64
|
+
declare class CustomPromise<Success,Error=unknown>extends Promise<Success>implements CustomPromiseType<Success,Error>{private _value?;private _error?;private _finish;constructor(executor:(resolve:(v:Success)=>void,reject:(e:Error)=>void)=>void);then<TResult1=Success,TResult2=never>(onfulfilled?:((value:Success)=>TResult1|PromiseLike<TResult1>)|null,onrejected?:((reason:Error)=>TResult2|PromiseLike<TResult2>)|null):CustomPromise<TResult1|TResult2,Error>;catch<TResult=never>(onrejected?:((reason:Error)=>TResult|PromiseLike<TResult>)|null):CustomPromise<Success|TResult,Error>;
|
|
65
|
+
/**
|
|
66
|
+
* Registers a callback to be invoked **exactly once** when the
|
|
67
|
+
* promise settles, with access to both the resolved value and
|
|
68
|
+
* the rejection reason.
|
|
69
|
+
*
|
|
70
|
+
* If the promise is already settled when `finish` is called,
|
|
71
|
+
* the callback executes immediately on the same tick.
|
|
72
|
+
*
|
|
73
|
+
* @param cb Callback receiving the final `(value, error)`.
|
|
74
|
+
* @returns `this` for fluent chaining.
|
|
75
|
+
*/
|
|
76
|
+
finish(cb:(val?:Success,err?:Error)=>void):this;}
|
|
77
|
+
/** ------------------------------------------------------------
|
|
78
|
+
* * ***Utility: `delay`.***
|
|
79
|
+
* ------------------------------------------------------------
|
|
80
|
+
* **Creates a Promise-based delay that resolves after a given number
|
|
81
|
+
* of milliseconds, optionally supports cancellation with `AbortSignal`.**
|
|
82
|
+
* - **Behavior:**
|
|
83
|
+
* - Validates `milliSeconds` is a non-zero, non-negative integer.
|
|
84
|
+
* - Validates `signal` is an `AbortSignal` instance when provided.
|
|
85
|
+
* - Cleans up event listeners and timers properly.
|
|
86
|
+
* @param {number} [milliSeconds=1000]
|
|
87
|
+
* The duration of the delay in milliseconds, default is `1000`.
|
|
88
|
+
* @param {AbortSignal} [signal]
|
|
89
|
+
* An optional `AbortSignal` that can cancel the delay.
|
|
90
|
+
* @returns {Promise<void>}
|
|
91
|
+
* A promise that resolves after the specified delay or
|
|
92
|
+
* rejects with an `AbortError` if aborted.
|
|
93
|
+
* @throws {TypeError} Validates `milliSeconds` and `signal`:
|
|
94
|
+
* - If `milliSeconds` **is not a valid** an `integer-number`, `NaN`, `negative-number`, or `≤ 0`.
|
|
95
|
+
* - If `signal` **is not a valid** an`AbortSignal`.
|
|
96
|
+
* @throws {DOMException}
|
|
97
|
+
* If the delay is aborted using the signal, rejects with `"AbortError"`.
|
|
98
|
+
* @example
|
|
99
|
+
* // Waits for 2 seconds
|
|
100
|
+
* await delay(2000);
|
|
101
|
+
*
|
|
102
|
+
* // Delay with AbortSignal
|
|
103
|
+
* const controller = new AbortController();
|
|
104
|
+
* delay(5000, controller.signal).catch(err => console.log(err.name)); // "AbortError"
|
|
105
|
+
* controller.abort();
|
|
106
|
+
*/
|
|
107
|
+
declare const delay:(milliSeconds?:number,signal?:AbortSignal)=>Promise<void>;export{CustomPromise,delay};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{CustomPromise,delay}from"../chunk-QBKAEVYG.js";import"../chunk-WVSPXFTY.js";import"../chunk-PET42Z7W.js";import"../chunk-QNKGP5DY.js";import"../chunk-CMW2TBOQ.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** --------------------------------------------------
|
|
2
|
+
* * ***Utility Type: `Awaitable`.***
|
|
3
|
+
* --------------------------------------------------
|
|
4
|
+
* **Represents a type that can be awaited:**
|
|
5
|
+
* - Either a plain value `T` or a `PromiseLike<T>`.
|
|
6
|
+
* @template T - The inner value type.
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* async function wrap<T>(v: Awaitable<T>): Promise<T> {
|
|
10
|
+
* return await v;
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* const a = wrap(42); // Promise<number>
|
|
14
|
+
* const b = wrap(Promise.resolve("hi")); // Promise<string>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
type Awaitable<T>=T|PromiseLike<T>;interface CustomPromiseLike<OnSuccess,OnError>{
|
|
18
|
+
/**
|
|
19
|
+
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
20
|
+
* @param onfulfilled The callback to execute when the Promise is resolved.
|
|
21
|
+
* @param onrejected The callback to execute when the Promise is rejected.
|
|
22
|
+
* @returns A Promise for the completion of which ever callback is executed.
|
|
23
|
+
*/
|
|
24
|
+
then<TResult1=OnSuccess,TResult2=never>(onfulfilled?:((value:OnSuccess)=>TResult1|PromiseLike<TResult1>)|null|undefined,onrejected?:((reason:OnError)=>TResult2|PromiseLike<TResult2>)|null|undefined):CustomPromiseType<TResult1|TResult2,OnError>;
|
|
25
|
+
/**
|
|
26
|
+
* Attaches a callback for only the rejection of the Promise.
|
|
27
|
+
* @param onrejected The callback to execute when the Promise is rejected.
|
|
28
|
+
* @returns A Promise for the completion of the callback.
|
|
29
|
+
*/
|
|
30
|
+
catch<TResult=never>(onrejected?:((reason:OnError)=>TResult|PromiseLike<TResult>)|null|undefined):CustomPromiseType<OnSuccess|TResult,OnError>;
|
|
31
|
+
/**
|
|
32
|
+
* Registers a callback to be invoked **exactly once** when the
|
|
33
|
+
* promise settles, with access to both the resolved value and
|
|
34
|
+
* the rejection reason.
|
|
35
|
+
*
|
|
36
|
+
* If the promise is already settled when `finish` is called,
|
|
37
|
+
* the callback executes immediately on the same tick.
|
|
38
|
+
*
|
|
39
|
+
* @param cb Callback receiving the final `(value, error)`.
|
|
40
|
+
* @returns `this` for fluent chaining.
|
|
41
|
+
*/
|
|
42
|
+
finish(cb:(value:OnSuccess|undefined,error:OnError|undefined)=>void):CustomPromiseType<OnSuccess,OnError>;}
|
|
43
|
+
/** --------------------------------------------------
|
|
44
|
+
* * ***Utility Type: `CustomPromiseType`.***
|
|
45
|
+
* --------------------------------------------------
|
|
46
|
+
* **Extends the native `Promise` type to provide explicit typing
|
|
47
|
+
* for both the resolved (`onSuccess`) and rejected (`onError`) values,
|
|
48
|
+
* plus an optional `finish` hook.**
|
|
49
|
+
* - **Behavior:**
|
|
50
|
+
* - ✅ **Strongly types** `success`, `error`, and `finish` handlers.
|
|
51
|
+
* - ⚙️ `finish` runs exactly once after the promise settles (similar to `finish`).
|
|
52
|
+
* @template OnSuccess - The type of the fulfilled value.
|
|
53
|
+
* @template OnError - The type of the rejection reason, defaults to `unknown`.
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import type { CustomPromiseType } from "@rzl-zone/types";
|
|
57
|
+
* import { CustomsPromise } from "@rzl-zone/promises";
|
|
58
|
+
*
|
|
59
|
+
* const fetchUser = (): CustomPromiseType<User, ApiError> =>
|
|
60
|
+
* CustomsPromise<User, ApiError>((resolve, reject) => {
|
|
61
|
+
* apiCall().then(resolve).catch(reject);
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* fetchUser()
|
|
65
|
+
* .then(user => console.log(user))
|
|
66
|
+
* .catch(err => console.error(err))
|
|
67
|
+
* .finish((result, error) => {
|
|
68
|
+
* console.log("always runs", { result, error });
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
type CustomPromiseType<OnSuccess,OnError=unknown>=CustomPromiseLike<OnSuccess,OnError>;export type{Awaitable as A,CustomPromiseType as C};
|