Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tarsisexistence/fuzion

shortcut fu⚡️ion for TypeScript
https://github.com/tarsisexistence/fuzion

fp functional-programming javascript shortcut-fusion typescript

Last synced: 19 days ago
JSON representation

shortcut fu⚡️ion for TypeScript

Awesome Lists containing this project

README

        

# Fuzion

Runtime implementation of shortcut fusion for JavaScript and TypeScript.


#### Definition ([haskell docs](https://wiki.haskell.org/Short_cut_fusion))
Shortcut fusion is an optimizer method that merges some function calls into one. E.g., `map f * map g` can be substituted by `map (f * g)`, and `filter p * filter q` can be substituted by `filter (\x -> q x && p x)`. It can also help to remove intermediate data structures. E.g., computing `sum [1..n]` does not require an explicit list structure, and the expression is actually translated into a simple loop.


#### API

So far, it supports the following operators:

- fuzion - performs left-to-right function composition. In some libraries this function is named `pipe`, `sequence`.
- map - applies another function to a list of elements and returns a new result on every element in the calling array.
- filter - invokes a provided predicate function for each array element and includes it into the result.
- forEach - executes a provided function once for each array element.
- take - cuts the length of the produced result. It helps to save operators calls to other operators on array elements that will not be included in the final result.