aveazul 2.0.1 → 2.1.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/README.md CHANGED
@@ -16,7 +16,7 @@ Further, if you like Bluebird's API but want to use native Promises, AveAzul giv
16
16
 
17
17
  ## Requirements
18
18
 
19
- - node.js version >= 22.12
19
+ - node.js version >= 22.18
20
20
 
21
21
  ## Installation
22
22
 
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,12 +57,40 @@ 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
63
78
  * no need to explicitly wrap returns in new AveAzul(). This behavior is standard across all
64
79
  * spec-compliant JS engines (V8, SpiderMonkey, JavaScriptCore, etc).
65
80
  */
81
+ /**
82
+ * The instance-side counterpart to the `declare static` block above, and for the same reason:
83
+ * `then`/`catch`/`finally` construct through `this` (SpeciesConstructor), so each one really
84
+ * hands back an AveAzul -- but `Promise`'s lib types say plain `Promise`, so the first link in
85
+ * any chain loses every bluebird method and callers need `as AveAzulInstance<T>` to get them
86
+ * back. These are `declare`, so nothing is emitted and no runtime behavior changes.
87
+ *
88
+ * `AveAzul<T>` still satisfies `Promise<T>`/`PromiseLike<T>` after this, since the returned
89
+ * AveAzul is itself a Promise - await and interop are unaffected.
90
+ */
91
+ then: <TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null) => AveAzul<TResult1 | TResult2>;
92
+ catch: <TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null) => AveAzul<T | TResult>;
93
+ finally: (onfinally?: (() => void) | undefined | null) => AveAzul<T>;
66
94
  /**
67
95
  * Bluebird-style tap() method that lets you perform side effects in a chain
68
96
  * Similar to Bluebird's Promise.prototype.tap()
@@ -195,7 +223,7 @@ declare class AveAzul<T> extends Promise<T> {
195
223
  * @param options - Additional options
196
224
  * @returns The same promise instance
197
225
  */
198
- asCallback(cb: ((err: Error | null, value?: T) => void) | undefined | null, options?: AsCallbackOptions): AveAzul<T>;
226
+ asCallback(cb: ((err: Error | null, value?: T) => void) | ((err: Error | null, ...values: any[]) => void) | undefined | null, options?: AsCallbackOptions): AveAzul<T>;
199
227
  nodeify(cb: ((err: Error | null, value?: T) => void) | undefined | null, options?: AsCallbackOptions): AveAzul<T>;
200
228
  /**
201
229
  * Bluebird-style call() method for calling a method on the resolved value
package/dist/aveazul.js CHANGED
@@ -17,12 +17,6 @@ class AveAzul extends Promise {
17
17
  constructor(executor) {
18
18
  super(executor);
19
19
  }
20
- /**
21
- * Note: Per ECMAScript specification, when extending Promise, both .then() and static methods
22
- * (resolve, reject, all, etc) must return instances of the derived class (AveAzul), so there's
23
- * no need to explicitly wrap returns in new AveAzul(). This behavior is standard across all
24
- * spec-compliant JS engines (V8, SpiderMonkey, JavaScriptCore, etc).
25
- */
26
20
  /**
27
21
  * Bluebird-style tap() method that lets you perform side effects in a chain
28
22
  * Similar to Bluebird's Promise.prototype.tap()
@@ -415,6 +409,10 @@ class AveAzul extends Promise {
415
409
  * @returns Promise that resolves with the function's return value
416
410
  */
417
411
  static try(fn) {
412
+ // xaa.wrap() reports the function's declared return type, so a fn returning a
413
+ // thenable comes back as Promise<T | PromiseLike<T>>; pinning resolve()'s type
414
+ // argument to that keeps the inference off the narrower outer T. The awaited
415
+ // value is a T, which is what the cast records.
418
416
  return AveAzul.resolve(xaa.wrap(fn));
419
417
  }
420
418
  /**
@@ -1,4 +1,11 @@
1
- import type { AveAzulClass } from "./aveazul.js";
2
- export declare function createInstanceNotImplemented(AveAzul: AveAzulClass): string[];
3
- export declare function createStaticNotImplemented(AveAzul: AveAzulClass): string[];
4
- export declare function setupNotImplemented(AveAzul: AveAzulClass): void;
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;
@@ -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.0.1",
3
+ "version": "2.1.1",
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 && npm run test:bluebird",
22
22
  "vitest": "vitest run",
23
23
  "test:watch": "vitest",
24
24
  "test:coverage": "vitest run --coverage",
@@ -80,11 +80,22 @@
80
80
  "directory": "packages/aveazul"
81
81
  },
82
82
  "dependencies": {
83
- "@jchip/error": "^2.0.0",
84
- "xaa": "^3.0.0"
83
+ "@jchip/error": "^2.1.1",
84
+ "xaa": "^3.1.1"
85
+ },
86
+ "devDependencies": {
87
+ "@fynjs/ts-resolve": "^1.0.1",
88
+ "@types/node": "^26.4.1",
89
+ "@vitest/coverage-v8": "^5.0.0",
90
+ "bluebird": "^3.7.2",
91
+ "publish-util": "^3.1.1",
92
+ "run-verify": "^2.1.1",
93
+ "typescript": "^7.0.2",
94
+ "vite": "^8.2.2",
95
+ "vitest": "^5.0.0"
85
96
  },
86
97
  "engines": {
87
- "node": ">=22.12.0"
98
+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
88
99
  },
89
100
  "sideEffects": false
90
101
  }