Skip to content

Commit

Permalink
chore: tweak up asArray helper
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Feb 6, 2023
1 parent 9f5e876 commit 1309128
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/ts/pipes/httpBatch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Extends, HttpMethod } from '@qiwi/substrate'
import { HttpMethod } from '@qiwi/substrate'

import { IPipe } from '../interfaces'
import { IHttpHeaders } from './http'
Expand All @@ -11,8 +11,8 @@ export type IHttpBatchPipeOpts = {
headers?: IHttpHeaders
}

const asArray = <T>(value: T): Extends<T, any[], T, T[]> =>
(Array.isArray(value) ? value : [value]) as Extends<T, any[], T, T[]>
const asArray = <T>(value: T): Array<T extends any[] ? T[number] : T> =>
(Array.isArray(value) ? value : [value]) as any

export const createHttpBatchPipe = ({
url,
Expand All @@ -25,7 +25,7 @@ export const createHttpBatchPipe = ({
.map((url) => ({ url, headers, method }))

const batchOpts = batchUrl
? (asArray(batchUrl) as string[]).map((url) => ({ url, headers, method }))
? asArray(batchUrl).map((url) => ({ url, headers, method }))
: opts

const httpPipe = createHttpPipeFallback(opts)
Expand Down

0 comments on commit 1309128

Please sign in to comment.