Simplify chaining of transforms#22994
Conversation
|
|
||
| // Chain together and initialize each transformer. | ||
| const transformation = chain(...transformers)(context); | ||
| const transformersWithContext = transformers.map(t => t(context)); |
There was a problem hiding this comment.
Can you verify the performance of this change against a large project? The original version was written so that the final transformation of a file would basically be a function like x => d(c(b(a(x)))) for simple cases rather than relying on array iteration. If anything, I would have been tempted to expand compose and chain to ensure a simple compiled function for a larger number of inputs before falling back to array iteration. To be honest though, since we don't use it heavily the performance characteristics of this approach may be negligible unless you have a large project with a lot of small files.
|
Thanks for your contribution. This PR has not been updated in a while and cannot be automatically merged at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to continue working on this PR, please leave a message and one of the maintainers can reopen it. |
The function is used in one place and only ever called variadically, so it's really just a for-loop with a map ahead of time to fill in context.