Skip to content

Commit

Permalink
🐛 Fix pipe function logic
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Jun 3, 2021
1 parent f174755 commit f216443
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import { AnyFn } from './types/index.ts'
*/
const pipe: Pipe =
(...args: AnyFn[]) =>
(initialArg: unknown) =>
args.reduce((acc, cur) => cur(acc), initialArg)
(...initialArg: unknown[]) =>
args.reduce(
(acc, cur, index) => cur(...(index === 0 ? acc : [acc])) as unknown[],
initialArg
)

export { pipe }

Expand Down

0 comments on commit f216443

Please sign in to comment.