From 194947383325fa3d896a73c2e0613f517d236bcd Mon Sep 17 00:00:00 2001 From: SieR-VR Date: Tue, 27 Sep 2022 00:04:16 +0900 Subject: [PATCH] Reflect review --- src/async.ts | 9 ++++----- src/pipeline.ts | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/async.ts b/src/async.ts index 06ac627..73f55ef 100644 --- a/src/async.ts +++ b/src/async.ts @@ -16,7 +16,7 @@ export type ListFactoryFunc = keyof T extends K : (count: number, item: RecPartial & Omit) => Promise; function isPromise(t: T | Promise): t is Promise { - return typeof (t as any)["then"] === "function"; + return !!t && typeof (t as any)["then"] === "function"; } export function lift(t: T | Promise): Promise { @@ -272,14 +272,13 @@ async function buildBase( seqNum: number, builder: Builder | Promise> ): Promise> { - if (isPromise(builder)) - builder = await builder; + const resolvedBuilder = await lift(builder); const t: { [key: string]: any } = {}; - const keys = Object.getOwnPropertyNames(builder); + const keys = Object.getOwnPropertyNames(resolvedBuilder); const derived: BaseDerived[] = []; for (const key of keys) { - const v = (builder as any)[key]; + const v = (resolvedBuilder as any)[key]; let value = v; if (!!v && typeof v === "object") { if (isPromise(v)) { diff --git a/src/pipeline.ts b/src/pipeline.ts index 3fcb500..8d65c22 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -93,6 +93,6 @@ export class Pipeline

= {}> implements Promise } toFactory(): Async.Factory

{ - return Async.makeFactory(this.current as Promise>); + return Async.makeFactory(this.current as Promise>); } } \ No newline at end of file