until-async 3.0.2 → 3.0.3
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 +1 -1
- package/build/index.d.ts +12 -0
- package/{lib → build}/index.js +2 -3
- package/build/index.js.map +1 -0
- package/package.json +14 -13
- package/lib/index.d.ts +0 -16
- package/lib/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ This has been intentionally introduced to await a single logical unit as opposed
|
|
|
94
94
|
// a rather complex piece of logic. This way any rejections
|
|
95
95
|
// or exceptions happening within the given function
|
|
96
96
|
// can be handled via the same "error".
|
|
97
|
-
const [error, data] = until(async () => {
|
|
97
|
+
const [error, data] = await until(async () => {
|
|
98
98
|
const user = await fetchUser()
|
|
99
99
|
const nextUser = normalizeUser(user)
|
|
100
100
|
const transaction = await saveModel('user', user)
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type UntilResult<RejectionReason, ResolveData> = [reason: RejectionReason, data: null] | [reason: null, data: ResolveData];
|
|
2
|
+
/**
|
|
3
|
+
* Gracefully handles a callback that returns a promise.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* await until(() => Promise.resolve(123))
|
|
7
|
+
* // [null, 123]
|
|
8
|
+
*
|
|
9
|
+
* await until(() => Promise.reject(new Error('Oops!')))
|
|
10
|
+
* // [new Error('Oops!'), null]
|
|
11
|
+
*/
|
|
12
|
+
export declare function until<RejectionReason = Error, ResolveData = unknown>(callback: () => Promise<ResolveData>): Promise<UntilResult<RejectionReason, ResolveData>>;
|
package/{lib → build}/index.js
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/index.ts
|
|
2
2
|
/**
|
|
3
3
|
* Gracefully handles a callback that returns a promise.
|
|
4
4
|
*
|
|
@@ -18,7 +18,6 @@ async function until(callback) {
|
|
|
18
18
|
return [error, null];
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
21
|
export { until };
|
|
22
|
+
|
|
24
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export type UntilResult<RejectionReason, ResolveData> =\n | [reason: RejectionReason, data: null]\n | [reason: null, data: ResolveData]\n\n/**\n * Gracefully handles a callback that returns a promise.\n *\n * @example\n * await until(() => Promise.resolve(123))\n * // [null, 123]\n *\n * await until(() => Promise.reject(new Error('Oops!')))\n * // [new Error('Oops!'), null]\n */\nexport async function until<RejectionReason = Error, ResolveData = unknown>(\n callback: () => Promise<ResolveData>,\n): Promise<UntilResult<RejectionReason, ResolveData>> {\n try {\n const data = await callback().catch((error) => {\n throw error\n })\n return [null, data]\n } catch (error: any) {\n return [error, null]\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,eAAsB,MACpB,UACoD;CACpD,IAAI;EAIF,OAAO,CAAC,MAAM,MAHK,SAAS,CAAC,CAAC,OAAO,UAAU;GAC7C,MAAM;EACR,CAAC,CACiB;CACpB,SAAS,OAAY;EACnB,OAAO,CAAC,OAAO,IAAI;CACrB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "until-async",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3",
|
|
5
5
|
"description": "Gracefully handle a Promise using async/await.",
|
|
6
|
-
"main": "./
|
|
7
|
-
"types": "./
|
|
6
|
+
"main": "./build/index.js",
|
|
7
|
+
"types": "./build/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
9
10
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"default": "./
|
|
11
|
+
"types": "./build/index.d.ts",
|
|
12
|
+
"default": "./build/index.js"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"homepage": "https://github.com/kettanaito/until-async",
|
|
@@ -23,8 +24,8 @@
|
|
|
23
24
|
"license": "MIT",
|
|
24
25
|
"funding": "https://github.com/sponsors/kettanaito",
|
|
25
26
|
"files": [
|
|
26
|
-
"
|
|
27
|
-
"src"
|
|
27
|
+
"./build",
|
|
28
|
+
"./src"
|
|
28
29
|
],
|
|
29
30
|
"keywords": [
|
|
30
31
|
"async",
|
|
@@ -35,12 +36,12 @@
|
|
|
35
36
|
"util"
|
|
36
37
|
],
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@ossjs/release": "^0.
|
|
39
|
-
"@rolldown/binding-darwin-arm64": "1.
|
|
40
|
-
"publint": "^0.3.
|
|
41
|
-
"tsdown": "
|
|
42
|
-
"typescript": "^
|
|
43
|
-
"vitest": "^
|
|
39
|
+
"@ossjs/release": "^0.11.2",
|
|
40
|
+
"@rolldown/binding-darwin-arm64": "1.3.3",
|
|
41
|
+
"publint": "^0.3.25",
|
|
42
|
+
"tsdown": "0.23.7",
|
|
43
|
+
"typescript": "^7.0.2",
|
|
44
|
+
"vitest": "^5.1.1"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"dev": "tsdown -w",
|
package/lib/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/index.d.ts
|
|
2
|
-
type UntilResult<RejectionReason, ResolveData> = [reason: RejectionReason, data: null] | [reason: null, data: ResolveData];
|
|
3
|
-
/**
|
|
4
|
-
* Gracefully handles a callback that returns a promise.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* await until(() => Promise.resolve(123))
|
|
8
|
-
* // [null, 123]
|
|
9
|
-
*
|
|
10
|
-
* await until(() => Promise.reject(new Error('Oops!')))
|
|
11
|
-
* // [new Error('Oops!'), null]
|
|
12
|
-
*/
|
|
13
|
-
declare function until<RejectionReason = Error, ResolveData = unknown>(callback: () => Promise<ResolveData>): Promise<UntilResult<RejectionReason, ResolveData>>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { UntilResult, until };
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["error: any"],"sources":["../src/index.ts"],"sourcesContent":["export type UntilResult<RejectionReason, ResolveData> =\n | [reason: RejectionReason, data: null]\n | [reason: null, data: ResolveData]\n\n/**\n * Gracefully handles a callback that returns a promise.\n *\n * @example\n * await until(() => Promise.resolve(123))\n * // [null, 123]\n *\n * await until(() => Promise.reject(new Error('Oops!')))\n * // [new Error('Oops!'), null]\n */\nexport async function until<RejectionReason = Error, ResolveData = unknown>(\n callback: () => Promise<ResolveData>,\n): Promise<UntilResult<RejectionReason, ResolveData>> {\n try {\n const data = await callback().catch((error) => {\n throw error\n })\n return [null, data]\n } catch (error: any) {\n return [error, null]\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,eAAsB,MACpB,UACoD;AACpD,KAAI;AAIF,SAAO,CAAC,MAHK,MAAM,UAAU,CAAC,OAAO,UAAU;AAC7C,SAAM;IACN,CACiB;UACZA,OAAY;AACnB,SAAO,CAAC,OAAO,KAAK"}
|