aveazul 2.0.0 → 2.1.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 +1 -1
- package/dist/aveazul.d.ts +18 -3
- package/dist/aveazul.js +4 -0
- package/dist/not-implemented.d.ts +11 -4
- package/dist/promisify-all.d.ts +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/aveazul.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PromisifyOptions } from "./promisify.js";
|
|
2
|
-
import { PromisifyAllOptions } from "./promisify-all.js";
|
|
1
|
+
import { type PromisifyOptions } from "./promisify.js";
|
|
2
|
+
import { type PromisifyAllOptions } from "./promisify-all.js";
|
|
3
3
|
import { Disposer } from "./disposer.js";
|
|
4
4
|
import { triggerUncaughtException } from "./util.js";
|
|
5
5
|
import { OperationalError, isOperationalError, isProgrammerError } from "./operational-error.js";
|
|
@@ -57,6 +57,21 @@ export type AveAzulInstance<T> = AveAzul<T>;
|
|
|
57
57
|
*/
|
|
58
58
|
declare class AveAzul<T> extends Promise<T> {
|
|
59
59
|
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void);
|
|
60
|
+
/**
|
|
61
|
+
* `resolve`/`reject`/`all` are inherited from Promise. Per the ECMAScript
|
|
62
|
+
* spec they construct through `this`, so at runtime they already hand back
|
|
63
|
+
* AveAzul instances -- but `PromiseConstructor` types them as plain `Promise`,
|
|
64
|
+
* which drops every AveAzul method (`.spread()`, `.disposer()`, ...). These
|
|
65
|
+
* ambient re-declarations state the real return types; they add `declare`, so
|
|
66
|
+
* nothing is emitted and no behavior changes. They match what the exported
|
|
67
|
+
* `AveAzulClass` interface has always promised.
|
|
68
|
+
*/
|
|
69
|
+
static resolve: {
|
|
70
|
+
<U>(value: U | PromiseLike<U>): AveAzul<U>;
|
|
71
|
+
(): AveAzul<void>;
|
|
72
|
+
};
|
|
73
|
+
static reject: <U = never>(reason?: unknown) => AveAzul<U>;
|
|
74
|
+
static all: <U>(values: Iterable<U | PromiseLike<U>>) => AveAzul<Awaited<U>[]>;
|
|
60
75
|
/**
|
|
61
76
|
* Note: Per ECMAScript specification, when extending Promise, both .then() and static methods
|
|
62
77
|
* (resolve, reject, all, etc) must return instances of the derived class (AveAzul), so there's
|
|
@@ -195,7 +210,7 @@ declare class AveAzul<T> extends Promise<T> {
|
|
|
195
210
|
* @param options - Additional options
|
|
196
211
|
* @returns The same promise instance
|
|
197
212
|
*/
|
|
198
|
-
asCallback(cb: ((err: Error | null, value?: T) => void) | undefined | null, options?: AsCallbackOptions): AveAzul<T>;
|
|
213
|
+
asCallback(cb: ((err: Error | null, value?: T) => void) | ((err: Error | null, ...values: any[]) => void) | undefined | null, options?: AsCallbackOptions): AveAzul<T>;
|
|
199
214
|
nodeify(cb: ((err: Error | null, value?: T) => void) | undefined | null, options?: AsCallbackOptions): AveAzul<T>;
|
|
200
215
|
/**
|
|
201
216
|
* Bluebird-style call() method for calling a method on the resolved value
|
package/dist/aveazul.js
CHANGED
|
@@ -415,6 +415,10 @@ class AveAzul extends Promise {
|
|
|
415
415
|
* @returns Promise that resolves with the function's return value
|
|
416
416
|
*/
|
|
417
417
|
static try(fn) {
|
|
418
|
+
// xaa.wrap() reports the function's declared return type, so a fn returning a
|
|
419
|
+
// thenable comes back as Promise<T | PromiseLike<T>>; pinning resolve()'s type
|
|
420
|
+
// argument to that keeps the inference off the narrower outer T. The awaited
|
|
421
|
+
// value is a T, which is what the cast records.
|
|
418
422
|
return AveAzul.resolve(xaa.wrap(fn));
|
|
419
423
|
}
|
|
420
424
|
/**
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* What these helpers actually need from their target: they only read/assign the
|
|
3
|
+
* target's `prototype` members and its own static keys, so any constructor will
|
|
4
|
+
* do — the real AveAzul class, or a stand-in in tests.
|
|
5
|
+
*/
|
|
6
|
+
export type NotImplementedTarget = {
|
|
7
|
+
prototype: object;
|
|
8
|
+
};
|
|
9
|
+
export declare function createInstanceNotImplemented(AveAzul: NotImplementedTarget): string[];
|
|
10
|
+
export declare function createStaticNotImplemented(AveAzul: NotImplementedTarget): string[];
|
|
11
|
+
export declare function setupNotImplemented(AveAzul: NotImplementedTarget): void;
|
package/dist/promisify-all.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PromisifyOptions } from "./promisify.js";
|
|
1
|
+
import { type PromisifyOptions } from "./promisify.js";
|
|
2
2
|
type FilterFunction = (name: string, value: unknown, target: object, passesDefaultFilter?: boolean) => boolean;
|
|
3
3
|
type PromisifierFunction = (fn: (...args: any[]) => void, defaultPromisifier: (fn: (...args: any[]) => void, dp: any, options: PromisifyAllOptions) => (...args: any[]) => Promise<unknown>, options: PromisifyAllOptions) => (...args: any[]) => Promise<unknown>;
|
|
4
4
|
export interface PromisifyAllOptions extends PromisifyOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aveazul",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Bluebird drop-in replacement built on native Promise",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
20
20
|
"test": "npm run vitest && npm run build && npm run demo:cjs && npm run demo:esm",
|
|
21
|
-
"ci:check": "tsc --noEmit -p tsconfig.json && npm test",
|
|
21
|
+
"ci:check": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json && npm test",
|
|
22
22
|
"vitest": "vitest run",
|
|
23
23
|
"test:watch": "vitest",
|
|
24
24
|
"test:coverage": "vitest run --coverage",
|
|
@@ -80,11 +80,11 @@
|
|
|
80
80
|
"directory": "packages/aveazul"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@jchip/error": "^2.
|
|
84
|
-
"xaa": "^3.
|
|
83
|
+
"@jchip/error": "^2.1.0",
|
|
84
|
+
"xaa": "^3.1.0"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
|
87
|
-
"node": ">=22.
|
|
87
|
+
"node": ">=22.18.0"
|
|
88
88
|
},
|
|
89
89
|
"sideEffects": false
|
|
90
90
|
}
|