diff --git a/src/main/ts/pipes/flp.ts b/src/main/ts/pipes/flp.ts index fb49404..0aa1627 100644 --- a/src/main/ts/pipes/flp.ts +++ b/src/main/ts/pipes/flp.ts @@ -30,9 +30,9 @@ export const eventifyPipe: IPipe = { } const batched = await Promise.all( - data - // @ts-ignore - .map((data) => eventifyPipe.execute({ data }, identity)), + data.map((data) => + eventifyPipe.execute({ data } as ITransmittable, identity), + ), ) const [arrayRejected, arrayResolved] = batched.reduce( diff --git a/src/main/ts/pipes/httpBatch.ts b/src/main/ts/pipes/httpBatch.ts index 8bb78c2..0105850 100644 --- a/src/main/ts/pipes/httpBatch.ts +++ b/src/main/ts/pipes/httpBatch.ts @@ -1,4 +1,4 @@ -import { HttpMethod } from '@qiwi/substrate' +import { HttpMethod, Extends } from '@qiwi/substrate' import { IPipe } from '../interfaces' import { IHttpHeaders } from './http' @@ -11,6 +11,9 @@ export type IHttpBatchPipeOpts = { headers?: IHttpHeaders } +const asArray = (value: T): Extends => + (Array.isArray(value) ? value: [value]) as Extends + export const createHttpBatchPipe = ({ url, batchUrl, @@ -22,7 +25,7 @@ export const createHttpBatchPipe = ({ .map((url) => ({ url, headers, method })) const batchOpts = batchUrl - ? ([] as string[]).concat(batchUrl).map((url) => ({ url, headers, method })) + ? (asArray(batchUrl) as string[]).map((url) => ({ url, headers, method })) : opts const httpPipe = createHttpPipeFallback(opts)