Skip to content

Commit 9a313d3

Browse files
committed
refactor(@angular-devkit/architect): remove usage of isPromise
The isPromise utility was only used in one place in create-job-handler.ts. It has been replaced with an inline check for thenables. The utility is now marked as deprecated in @angular-devkit/core.
1 parent 652c0fd commit 9a313d3

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

packages/angular_devkit/architect/src/jobs/create-job-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { BaseException, JsonValue, isPromise, logging } from '@angular-devkit/core';
9+
import { BaseException, JsonValue, logging } from '@angular-devkit/core';
1010
import {
1111
Observable,
1212
Observer,
@@ -161,7 +161,7 @@ export function createJobHandler<A extends JsonValue, I extends JsonValue, O ext
161161
subject.next({ kind: JobOutboundMessageKind.Start, description });
162162
let result = fn(argument, newContext);
163163
// If the result is a promise, simply wait for it to complete before reporting the result.
164-
if (isPromise(result)) {
164+
if (typeof (result as PromiseLike<O>)?.then === 'function') {
165165
result = from(result);
166166
} else if (!isObservable(result)) {
167167
result = of(result);

packages/angular_devkit/core/src/utils/lang.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/**
1212
* Determine if the argument is shaped like a Promise
13+
*
14+
* @deprecated Use `typeof obj?.then === 'function'` instead.
1315
*/
1416
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1517
export function isPromise(obj: any): obj is Promise<any> {

0 commit comments

Comments
 (0)