Skip to content

feat: add pipe function #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nusohiro
Copy link
Contributor

@nusohiro nusohiro commented Mar 7, 2025

Summary

This PR adds the pipe function.
The function applies a series of functions to an initial value in sequence, passing the result of each function to the next. It returns the final transformed value without modifying the original input.

Related issue, if any:

N/A

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed
  • Release notes in next-minor.md or next-major.md have been added, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size 1
A src/function/pipe.ts 59

Footnotes

  1. Function size includes the import dependencies of the function.

@nusohiro nusohiro requested a review from aleclarson as a code owner March 7, 2025 11:47
@radashi-bot
Copy link

Benchmark Results

Name Current
pipe: piping a number through simple transformations 4,423,195.7 ops/sec ±0.42%
pipe: piping a string through multiple transformations 1,921,938.39 ops/sec ±0.12%
pipe: piping an array through multiple transformations 2,447,191.54 ops/sec ±0.48%
pipe: piping a large dataset through transformations 88,709.24 ops/sec ±1.06%

Performance regressions of 30% or more should be investigated, unless they were anticipated. Smaller regressions may be due to normal variability, as we don't use dedicated CI infrastructure.

@aleclarson
Copy link
Member

Hey @nusohiro, thanks for putting this together! I appreciate you thinking about ways to improve Radashi. The pipe function is a fine approach that I'm sure many developers find useful.

That said, I'm hesitant to merge this in because it feels like it might be opening the door to bringing in more pure functional utilities. For developers wanting this kind of functionality, I'd suggest using one of the dedicated libraries that specialize in functional programming patterns.

I'll keep the PR open so others in the community can find it and easily add it to their own Radashi implementations if they prefer this approach.

@aleclarson aleclarson added open library This PR should be listed in the Open Library won't merge A rejected proposal. labels Mar 13, 2025
@nusohiro
Copy link
Contributor Author

@aleclarson
Thank you for reviewing my PR and for your thoughtful feedback.

I understand your concerns and appreciate the suggestion.
I’ll keep an eye on the discussion.

Thanks for maintaining Radashi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open library This PR should be listed in the Open Library won't merge A rejected proposal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants