@ts-type/bluebird 1.0.1 → 1.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/CHANGELOG.md +28 -0
- package/README.md +33 -3
- package/index.d.ts +45 -0
- package/index.js.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.3](https://github.com/bluelovers/ws-ts-type/compare/@ts-type/bluebird@1.0.2...@ts-type/bluebird@1.0.3) (2026-03-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @ts-type/bluebird
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.0.2](https://github.com/bluelovers/ws-ts-type/compare/@ts-type/bluebird@1.0.1...@ts-type/bluebird@1.0.2) (2026-03-07)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### 📚 Documentation
|
|
19
|
+
|
|
20
|
+
* enhance documentation and JSDoc comments across multiple packages ([88ee99b](https://github.com/bluelovers/ws-ts-type/commit/88ee99b3a489645ca53093357cc3523dbe7996e0))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### 🛠 Build System
|
|
24
|
+
|
|
25
|
+
* 更新多個套件的 test 指令為 jest ([61ea53b](https://github.com/bluelovers/ws-ts-type/commit/61ea53bf15fc3ed0e216793200604ae5a52079c9))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### ♻️ Chores
|
|
29
|
+
|
|
30
|
+
* migrate from yarn to pnpm and enhance test infrastructure ([8a5daa2](https://github.com/bluelovers/ws-ts-type/commit/8a5daa2f2022eaf025c3349d4fe5dc8971f8c077))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## 1.0.1 (2022-10-10)
|
|
7
35
|
|
|
8
36
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ts-type/bluebird
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bluebird Promise 類型的增強類型定義
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Enhanced type definitions for Bluebird Promise
|
|
6
|
+
|
|
7
|
+
## 功能特點 / Features
|
|
8
|
+
|
|
9
|
+
- Bluebird Promise 類型別名
|
|
10
|
+
- Bluebird Promise type aliases
|
|
11
|
+
- 函式包裝為 Bluebird Promise
|
|
12
|
+
- Wrap functions to return Bluebird Promise
|
|
13
|
+
- 支援 promisifyAll 類型
|
|
14
|
+
- Support promisifyAll types
|
|
15
|
+
- 元組轉換為 Inspection 類型
|
|
16
|
+
- Tuple to Inspection type conversion
|
|
17
|
+
|
|
18
|
+
## 安裝 / Install
|
|
6
19
|
|
|
7
20
|
```bash
|
|
8
21
|
yarn add @ts-type/bluebird
|
|
@@ -10,3 +23,20 @@ yarn-tool add @ts-type/bluebird
|
|
|
10
23
|
yt add @ts-type/bluebird
|
|
11
24
|
```
|
|
12
25
|
|
|
26
|
+
## 使用範例 / Usage Example
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import type { IBluebird, ITSBluebirdPromisifyAll, ITSResultArrayToBluebirdInspection } from '@ts-type/bluebird';
|
|
30
|
+
import Bluebird from 'bluebird';
|
|
31
|
+
|
|
32
|
+
// 使用 Bluebird 類型別名
|
|
33
|
+
type MyPromise = IBluebird<string>;
|
|
34
|
+
|
|
35
|
+
// 將物件方法轉換為 Bluebird Promise
|
|
36
|
+
interface IOriginal {
|
|
37
|
+
fetchData(): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type IPromisified = ITSBluebirdPromisifyAll<IOriginal>;
|
|
41
|
+
```
|
|
42
|
+
|
package/index.d.ts
CHANGED
|
@@ -2,17 +2,62 @@ import Bluebird from 'bluebird';
|
|
|
2
2
|
import { ITSKeyOfRecordExtractToKey } from 'ts-type/lib/helper/record/pick-type';
|
|
3
3
|
import { ITSAnyFunction } from 'ts-type/lib/type/base';
|
|
4
4
|
import { ITSAwaitedReturnType } from 'ts-type/lib/helper/promise';
|
|
5
|
+
/**
|
|
6
|
+
* Bluebird Promise 類型的別名
|
|
7
|
+
* Bluebird Promise type alias
|
|
8
|
+
*
|
|
9
|
+
* @typeParam T - Promise 解決值的類型 / Type of the resolved value
|
|
10
|
+
*/
|
|
5
11
|
export type IBluebird<T> = Bluebird<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Bluebird Promise 類型的別名(較短名稱)
|
|
14
|
+
* Bluebird Promise type alias (shorter name)
|
|
15
|
+
*
|
|
16
|
+
* @typeParam T - Promise 解決值的類型 / Type of the resolved value
|
|
17
|
+
*/
|
|
6
18
|
export type ITSBluebird<T> = Bluebird<T>;
|
|
19
|
+
/**
|
|
20
|
+
* 將函式包裝為回傳 Bluebird Promise 的函式
|
|
21
|
+
* Wrap a function to return Bluebird Promise
|
|
22
|
+
*
|
|
23
|
+
* @typeParam T - 原函式類型 / Original function type
|
|
24
|
+
* @example
|
|
25
|
+
* function add(a: number, b: number): number { return a + b; }
|
|
26
|
+
* const bluebirdAdd = wrapFunctionBluebird(add);
|
|
27
|
+
* // bluebirdAdd(1, 2) returns Bluebird<number>
|
|
28
|
+
*/
|
|
7
29
|
export type ITSWrapFunctionBluebird<T extends (...args: any[]) => any> = (...args: Parameters<T>) => IBluebird<ITSAwaitedReturnType<T>>;
|
|
30
|
+
/**
|
|
31
|
+
* 將物件的所有函式屬性轉換為 Bluebird Promise 版本
|
|
32
|
+
* Convert all function properties of an object to Bluebird Promise version
|
|
33
|
+
*
|
|
34
|
+
* @typeParam T - 目標物件類型 / Target object type
|
|
35
|
+
* @typeParam K - 提取的函式鍵名 / Extracted function keys
|
|
36
|
+
*/
|
|
8
37
|
export type ITSBluebirdPromisifyAll<T extends {
|
|
9
38
|
[p: string | symbol]: ITSAnyFunction;
|
|
10
39
|
}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {
|
|
11
40
|
[P in K]: (...argv: Parameters<T[P]>) => IBluebird<ITSAwaitedReturnType<T[P]>>;
|
|
12
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* 將物件的所有函式屬性轉換為標準 Promise 版本(非 Bluebird)
|
|
44
|
+
* Convert all function properties of an object to standard Promise version (non-Bluebird)
|
|
45
|
+
*
|
|
46
|
+
* @typeParam T - 目標物件類型 / Target object type
|
|
47
|
+
* @typeParam K - 提取的函式鍵名 / Extracted function keys
|
|
48
|
+
*/
|
|
13
49
|
export type ITSPromisifyAll<T extends {
|
|
14
50
|
[p: string | symbol]: ITSAnyFunction;
|
|
15
51
|
}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {
|
|
16
52
|
[P in K]: (...argv: Parameters<T[P]>) => Promise<ITSAwaitedReturnType<T[P]>>;
|
|
17
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* 將元組類型轉換為 Bluebird Inspection 類型的元組
|
|
56
|
+
* Convert tuple type to tuple of Bluebird Inspection types
|
|
57
|
+
*
|
|
58
|
+
* 用於處理 Promise.allSettled 的結果類型
|
|
59
|
+
* Used for handling Promise.allSettled result types
|
|
60
|
+
*
|
|
61
|
+
* @typeParam T - 輸入的元組類型 / Input tuple type
|
|
62
|
+
*/
|
|
18
63
|
export type ITSResultArrayToBluebirdInspection<T> = T extends [infer T1, infer T2, infer T3, infer T4, infer T5] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>, Bluebird.Inspection<T5>] : T extends [infer T1, infer T2, infer T3, infer T4] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>] : T extends [infer T1, infer T2, infer T3] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>] : T extends [infer T1, infer T2] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>] : T extends [infer T1] ? [Bluebird.Inspection<T1>] : T extends (infer R)[] ? Bluebird.Inspection<R>[] : never;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"","sourcesContent":["import Bluebird from 'bluebird';\n\nimport { ITSKeyOfRecordExtractToKey } from 'ts-type/lib/helper/record/pick-type';\nimport { ITSAnyFunction } from 'ts-type/lib/type/base';\nimport { ITSAwaitedReturnType } from 'ts-type/lib/helper/promise';\n\nexport type IBluebird<T> = Bluebird<T>;\nexport type ITSBluebird<T> = Bluebird<T>;\n\nexport type ITSWrapFunctionBluebird<T extends (...args: any[]) => any> =\n\t(...args: Parameters<T>) => IBluebird<ITSAwaitedReturnType<T>>;\n\nexport type ITSBluebirdPromisifyAll<T extends {\n\t[p: string | symbol]: ITSAnyFunction\n}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {\n\t[P in K]: (...argv: Parameters<T[P]>) => IBluebird<ITSAwaitedReturnType<T[P]>>\n}\n\nexport type ITSPromisifyAll<T extends {\n\t[p: string | symbol]: ITSAnyFunction\n}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {\n\t[P in K]: (...argv: Parameters<T[P]>) => Promise<ITSAwaitedReturnType<T[P]>>\n}\n\nexport type ITSResultArrayToBluebirdInspection<T> = T extends [infer T1, infer T2, infer T3, infer T4, infer T5]\n\t? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>, Bluebird.Inspection<T5>]\n\t: T extends [infer T1, infer T2, infer T3, infer T4]\n\t\t? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>]\n\t\t: T extends [infer T1, infer T2, infer T3]\n\t\t\t? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>]\n\t\t\t: T extends [infer T1, infer T2] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>] : T extends [infer T1]\n\t\t\t\t? [Bluebird.Inspection<T1>]\n\t\t\t\t: T extends (infer R)[] ? Bluebird.Inspection<R>[] : never;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"","sourcesContent":["import Bluebird from 'bluebird';\n\nimport { ITSKeyOfRecordExtractToKey } from 'ts-type/lib/helper/record/pick-type';\nimport { ITSAnyFunction } from 'ts-type/lib/type/base';\nimport { ITSAwaitedReturnType } from 'ts-type/lib/helper/promise';\n\n/**\n * Bluebird Promise 類型的別名\n * Bluebird Promise type alias\n *\n * @typeParam T - Promise 解決值的類型 / Type of the resolved value\n */\nexport type IBluebird<T> = Bluebird<T>;\n\n/**\n * Bluebird Promise 類型的別名(較短名稱)\n * Bluebird Promise type alias (shorter name)\n *\n * @typeParam T - Promise 解決值的類型 / Type of the resolved value\n */\nexport type ITSBluebird<T> = Bluebird<T>;\n\n/**\n * 將函式包裝為回傳 Bluebird Promise 的函式\n * Wrap a function to return Bluebird Promise\n *\n * @typeParam T - 原函式類型 / Original function type\n * @example\n * function add(a: number, b: number): number { return a + b; }\n * const bluebirdAdd = wrapFunctionBluebird(add);\n * // bluebirdAdd(1, 2) returns Bluebird<number>\n */\nexport type ITSWrapFunctionBluebird<T extends (...args: any[]) => any> =\n\t(...args: Parameters<T>) => IBluebird<ITSAwaitedReturnType<T>>;\n\n/**\n * 將物件的所有函式屬性轉換為 Bluebird Promise 版本\n * Convert all function properties of an object to Bluebird Promise version\n *\n * @typeParam T - 目標物件類型 / Target object type\n * @typeParam K - 提取的函式鍵名 / Extracted function keys\n */\nexport type ITSBluebirdPromisifyAll<T extends {\n\t[p: string | symbol]: ITSAnyFunction\n}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {\n\t[P in K]: (...argv: Parameters<T[P]>) => IBluebird<ITSAwaitedReturnType<T[P]>>\n}\n\n/**\n * 將物件的所有函式屬性轉換為標準 Promise 版本(非 Bluebird)\n * Convert all function properties of an object to standard Promise version (non-Bluebird)\n *\n * @typeParam T - 目標物件類型 / Target object type\n * @typeParam K - 提取的函式鍵名 / Extracted function keys\n */\nexport type ITSPromisifyAll<T extends {\n\t[p: string | symbol]: ITSAnyFunction\n}, K extends ITSKeyOfRecordExtractToKey<T, Function> = ITSKeyOfRecordExtractToKey<T, Function>> = Omit<T, K> & {\n\t[P in K]: (...argv: Parameters<T[P]>) => Promise<ITSAwaitedReturnType<T[P]>>\n}\n\n/**\n * 將元組類型轉換為 Bluebird Inspection 類型的元組\n * Convert tuple type to tuple of Bluebird Inspection types\n *\n * 用於處理 Promise.allSettled 的結果類型\n * Used for handling Promise.allSettled result types\n *\n * @typeParam T - 輸入的元組類型 / Input tuple type\n */\nexport type ITSResultArrayToBluebirdInspection<T> = T extends [infer T1, infer T2, infer T3, infer T4, infer T5]\n\t? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>, Bluebird.Inspection<T5>]\n\t: T extends [infer T1, infer T2, infer T3, infer T4]\n\t\t? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>]\n\t\t: T extends [infer T1, infer T2, infer T3]\n\t\t\t? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>]\n\t\t\t: T extends [infer T1, infer T2] ? [Bluebird.Inspection<T1>, Bluebird.Inspection<T2>] : T extends [infer T1]\n\t\t\t\t? [Bluebird.Inspection<T1>]\n\t\t\t\t: T extends (infer R)[] ? Bluebird.Inspection<R>[] : never;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-type/bluebird",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Bluebird Promise 類型的增強類型定義 | Enhanced type definitions for Bluebird Promise",
|
|
5
5
|
"keywords": [
|
|
6
6
|
".d.ts",
|
|
7
7
|
"@types",
|
|
@@ -49,19 +49,20 @@
|
|
|
49
49
|
"lint": "yarn run lint:eslint",
|
|
50
50
|
"lint:eslint": "ynpx eslint --ext .ts,.tsx,.mts,.cts ./",
|
|
51
51
|
"pretest": "echo pretest",
|
|
52
|
-
"test": "
|
|
52
|
+
"test": "jest --passWithNoTests",
|
|
53
53
|
"test:jest": "jest --passWithNoTests",
|
|
54
|
+
"test:jest:coverage": "node --run test:jest -- --coverage",
|
|
54
55
|
"test:jest:snapshot": "yarn run test:jest -- -u",
|
|
55
56
|
"test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
|
|
56
57
|
"test:snapshot": "yarn run test -- -u",
|
|
57
58
|
"test:tsd": "ynpx tsd",
|
|
58
|
-
"test:tsdx": "
|
|
59
|
+
"test:tsdx": "tsdx test --passWithNoTests",
|
|
59
60
|
"build:dts:bundle": "ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle",
|
|
60
61
|
"build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts",
|
|
61
62
|
"build:dts:tsc": "yarn run build:dts:tsc:emit && yarn run build:dts:copy",
|
|
62
63
|
"build:dts:tsc:emit": "tsc --emitDeclarationOnly --declaration --noEmit false",
|
|
63
64
|
"build:microbundle": "ynpx microbundle --target node",
|
|
64
|
-
"build:tsdx": "
|
|
65
|
+
"build:tsdx": "tsdx build --target node --name index",
|
|
65
66
|
"ci:install": "echo ci:install",
|
|
66
67
|
"ci:build": "echo ci:build",
|
|
67
68
|
"preversion": "echo preversion && yarn run test",
|
|
@@ -83,11 +84,10 @@
|
|
|
83
84
|
},
|
|
84
85
|
"dependencies": {
|
|
85
86
|
"@types/bluebird": "*",
|
|
86
|
-
"ts-type": "^3.0.
|
|
87
|
+
"ts-type": "^3.0.3"
|
|
87
88
|
},
|
|
88
|
-
"packageManager": "yarn@1.22.19",
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "4ef633a04245358fed59633c9d9ceff0607d30d3"
|
|
93
93
|
}
|