Skip to content

[Proposal]: add pipe utility function #87

@EhsanKey

Description

@EhsanKey

Function Signature

function pipe<T>(...fns: Array<(arg: T) => T>): (input: T) => T {}

Motivation

In functional programming, it’s common to apply multiple transformations to a value in sequence.

The pipe function allows us to write code more declaratively and clearly by chaining multiple functions from left to right:

const result = pipe(
  double,
  increment,
  square
)(2); // ((2 * 2) + 1)^2 = 25

This approach improves code readability and makes understanding function composition easier compared to nested calls like square(increment(double(2))).

Metadata

Metadata

Assignees

Labels

proposalNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions